Android - 如何检查订阅是否续订? [英] Android - How to check if subscription is renewed?

查看:1292
本文介绍了Android - 如何检查订阅是否续订?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可更新的每月订阅的Android应用程序。在这个应用程序中,我想在下个月他的订阅继续时通知用户一些信息。

I have an android app with renewable monthly subscriptions. In this app I want to notify user some info when his subcription continues in next month.

因为我可以看到商家中心的续订(orderId以例如..0结尾) ,.1),但在查询库存时,我的采购订单ID与当前情况相同。

As I can see renewals in merchant center(orderId ends with eg. ..0, ..1), but when querying the inventory my purchase orderId is same as befor eq.

{
    "orderId": "GPA.XXXX-YYYY-XXXX-ZZZZZ",
    "packageName": "my.packageName",
    "productId": "my.sku",
    "purchaseTime": 1456398623654,
    "purchaseState": 0,
    "developerPayload": "mypayload",
    "purchaseToken": "token",
    "autoRenewing": true
}

令我烦恼的是,buyTime也不会改变。

What bothers me more is that purchaseTime also doesn't change.

所以我的问题是:如果有任何方法可以在app中检测到更新发生了吗?

So my question is: If there is any way to detect in app that renewal occured?

编辑:

我正在使用Google Play Developer API获取订阅信息,然后计算续订次数我自己。

I'm using Google Play Developer API to get subscription info and then calculate number of renewals myself.

推荐答案

所有重复的订单ID都在 orderId 字段中返回 INAPP_PURCHASE_DATA JSON字段(在V3中),每个周期性事务附加一个整数。

Order id for all recurrences are returned in orderId field of the INAPP_PURCHASE_DATA JSON field (in V3) with each recurring transaction appended by an integer.

订阅订单号


为了帮助您跟踪与给定订阅相关的交易,
Google付款会为订阅的所有
重复次数提供基本商家订单号,并通过附加表示每个定期交易
整数如下:

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) ...

但由于本地缓存您可能无法获得最新信息。因此,请尝试从应用程序管理器清除缓存,首先查看您是否获得了正确的购买信息。

But due to local caching you might not get the latest information. So try clearing cache from application manager to first see if you get correct purchase information.

由于购买查询这种方式不可靠,因此调用Google Play Developer更有意义从后端 Purchases.subscriptions:get API获取 Purchases.subscriptions资源将返回 expiryTimeMillis 当前订阅。

Since purchase query this way is not reliable, it makes more sense to call Google Play Developer Purchases.subscriptions: get API from a backend to get Purchases.subscriptions resource which will return expiryTimeMillis of current subscription.

{
  "kind": "androidpublisher#subscriptionPurchase",
  "startTimeMillis": long,
  "expiryTimeMillis": long,
  "autoRenewing": boolean,
  "priceCurrencyCode": string,
  "priceAmountMicros": long,
  "countryCode": string,
  "developerPayload": string,
  "paymentState": integer,
  "cancelReason": integer
}

这篇关于Android - 如何检查订阅是否续订?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆