是否可以通过BillingClient检测宽限期?



我正在尝试使用BillingClient检测宽限期。

文档说:

订阅在整个生命周期中会经历各种状态变化,你的应用需要对每个变化做出响应。要检查订阅者的状态,您的应用程序可以使用BillingClient.queryPurchasesAsync()在Google Play计费库或购买查询。订阅:进入Google Play开发者API。

不幸的是,在我看来,使用BillingClient无法区分活动订阅和宽限期。两种情况下,isAutoRenewing的标志位都设置为true,purchaseState的标志位都设置为1。至少当我尝试在测试环境中复制这种情况时,我看到的是这样的:使用Test card, always approves购买订阅,然后在更新订阅之前更改为Test card, always declines

任何想法?

我认为不行,因为你需要采购。订阅:获取API,如下所述:

订阅在整个生命周期中会经历各种状态变化,你的应用需要对每个变化做出响应。要检查订阅者的状态,您的应用程序可以使用BillingClient.queryPurchasesAsync()在Google Play计费库或购买查询。订阅:进入Google Play开发者API。

[…]

宽限期

  • expiryTimeMillis is in the future//Purchases.subscriptions:get
  • paymentState = pending//purchasessubscriptions:get
  • autorenew = true。//购买。订阅:get或BillingClient

我也有同样的问题,并问了谷歌的一位开发者关系工程师(我在他们那里发了tweet)。

  • 这是他们告诉我的:
  1. The most secure and recommended way is to have a backend for your app and call subscriptionsv2.get. This will return a purchase object with the field SubscriptionState. Check out ClassyTaxi Server for an example implementaton:HERE

  2. 如果您没有后端,您可以使用BillingClient:

    推断宽限期
  • PurchaseState is pending
  • autorenew是True,即不是预付子
  • "授权已激活">

最新更新