我有一个 Android 应用程序,可以按月续订。在此应用中,我想在下个月继续订阅时通知用户一些信息。
我可以在商家中心看到续订(orderId 以 eg..0, ..1 结尾),但是在查询库存时,我的采购订单 Id 与 befor eq 相同。
{
"orderId": "GPA.XXXX-YYYY-XXXX-ZZZZZ",
"packageName": "my.packageName",
"productId": "my.sku",
"purchaseTime": 1456398623654,
"purchaseState": 0,
"developerPayload": "mypayload",
"purchaseToken": "token",
"autoRenewing": true
}
更让我困扰的是 purchaseTime 也没有改变。
所以我的问题是:是否有任何方法可以在应用程序中检测到发生了续订?
编辑:
我正在使用 Google Play Developer API 获取订阅信息,然后自己计算续订次数。
最佳答案
所有重复的订单 ID 在 INAPP_PURCHASE_DATA
JSON 字段(在 V3 中)的 orderId
字段中返回,每个重复交易都附加一个整数。
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 开发者 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 - 如何检查订阅是否续订?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36591498/