Android – 如何检查订阅是否续订?
作者:互联网
我有一个可更新的每月订阅的Android应用程序.在这个应用程序中,我想在下个月他的订阅继续时通知用户一些信息.
正如我可以看到商家中心的续订(orderId以例如.0,..1结尾),但在查询库存时,我的采购订单ID与efor eq相同.
{
"orderId": "GPA.XXXX-YYYY-XXXX-ZZZZZ",
"packageName": "my.packageName",
"productId": "my.sku",
"purchaseTime": 1456398623654,
"purchaseState": 0,
"developerPayload": "mypayload",
"purchaseToken": "token",
"autoRenewing": true
}
令我困扰的是,buyTime也没有改变.
所以我的问题是:如果有任何方法可以在应用程序中检测到更新发生了吗?
编辑:
我正在使用Google Play Developer API获取订阅信息,然后自行计算续订数量.
解决方法:
所有重复的订单ID在INAPP_PURCHASE_DATA JSON字段的orderId字段中返回(在V3中),每个重复的事务都附加一个整数.
To help you track transactions relating to a given subscription,
Google payments provides a base Merchant Order Number for all
recurrences of the subscription and denotes each recurring transaction
by appending an integer as follows:
GPA.1234-5678-9012-34567 (base order number)
GPA.1234-5678-9012-34567..0 (first recurrence orderID)
GPA.1234-5678-9012-34567..1 (second recurrence orderID)
GPA.1234-5678-9012-34567..2 (third recurrence orderID) ...
但由于local caching,您可能无法获得最新信息.因此,请尝试从应用程序管理器清除缓存,先查看是否获得了正确的购买信息
由于购买查询这种方式不可靠,因此从后端调用Google Play Developer Purchases.subscriptions: get API获取Purchases.subscriptions resource会更有意义,这将返回当前订阅的expiryTimeMillis.
{
"kind": "androidpublisher#subscriptionPurchase",
"startTimeMillis": long,
"expiryTimeMillis": long,
"autoRenewing": boolean,
"priceCurrencyCode": string,
"priceAmountMicros": long,
"countryCode": string,
"developerPayload": string,
"paymentState": integer,
"cancelReason": integer
}
标签:android,in-app-purchase,in-app-billing 来源: https://codeday.me/bug/20191006/1861161.html