Google 应用内购订阅

Google IAP subscriptions

我刚刚读到这个:Google Play Developer API: "startTimeMillis" is updated when it should not

但是比较旧。有人可以确认它是否像那样工作吗?

目前的问题是,在我们的系统中,对于其他支付方式,我们创建了自己的订阅。当此订阅结束时,我们取消订阅并且不再允许用户。如果用户稍后重新订阅,这对我们来说是新订阅。

但是,如果用户重新订阅,我们将获得新的 purchaseToken,这部分可以正常工作。但是旧的订阅应该保持未支付。但是,如果用户订阅并且旧令牌再次激活并且两个不同的令牌将 return 相同的结果,那就有点问题了。

我们将使用这个端点:https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get which should have this result: https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource

我们能否以某种方式发现旧令牌已被取消,然后重新订阅并且我们应该期待新的订阅?

我们已经模拟了它,这是结果:

这是要求:

注册新用户

购买订阅

保存响应字段以便能够将其调用到评论中https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get

调用上一个端点并将响应保存到评论中

取消订阅

等待 1 个月到期

调用端点,检查是否过期并保存响应

重新订阅

使用旧数据调用端点,使用重新订阅的数据调用端点,保存对评论的回复


购买第一个订阅:

{ "orderId": "GPA.3353-9191-0752-74136", "packageName": "xxx", "productId": "xxx", "purchaseTime": 1526543042663, "purchaseState": 0, "developerPayload": "ee40691d0a3e5f3600df9f35e3346ba7", "signature": "xxx", "purchaseToken": "xxx", "autoRenewing": true }

Google 对第一个订阅的响应:

{ "kind": "androidpublisher#subscriptionPurchase", "startTimeMillis": "1526543042663", "expiryTimeMillis": "1526543456810", "autoRenewing": true, "priceCurrencyCode": "GBP", "priceAmountMicros": "11990000", "countryCode": "GB", "developerPayload": "xxx", "paymentState": 1, "orderId": "GPA.3353-9191-0752-74136", "purchaseType": 0 }

购买第二个订阅:

{ "orderId": "GPA.3348-1559-2255-63309", "packageName": "xxx", "productId": "de.mp.ft.01.test", "purchaseTime": 1526543263033, "purchaseState": 0, "developerPayload": "xxx", "purchaseToken": "mibhepofikjpphaoimomekai.AO-J1Oytkgta2QbLt9lQa7y66eVnqqU1-yjOQJ9B4Sq5Md3Y1OvXJzE-MaazMhAr8gdazydx5sUHTPYg_93mocy37UW8c2M4RFDd0HmbP36lz9HIT7SJmAU", "autoRenewing": true }

Google 对第二次订阅的回复:

{ "kind": "androidpublisher#subscriptionPurchase", "startTimeMillis": "1526543263033", "expiryTimeMillis": "1526543756810", "autoRenewing": true, "priceCurrencyCode": "GBP", "priceAmountMicros": "11990000", "countryCode": "GB", "developerPayload": "xxx", "paymentState": 1, "orderId": "GPA.3348-1559-2255-63309..0", "linkedPurchaseToken": "ldblmpncfnknbgdmojghdkgj.AO-J1Oy6BqXGaqL355JjzOTQrwfzmLPtckmXmQLfgxX-pwVM3iRin81_AiYVUKsg4FX_ojD_MZabwj886prQhI2jjTXiDWjGqYPp5ZJVbGhZwdHQJkyi2WQ", "purchaseType": 0 }

Google 对在测试流程结束时调用的第一个订阅的响应 (8.)

{ "kind": "androidpublisher#subscriptionPurchase", "startTimeMillis": "1526543042663", "expiryTimeMillis": "1526543336810", "autoRenewing": false, "priceCurrencyCode": "GBP", "priceAmountMicros": "11990000", "countryCode": "GB", "developerPayload": "xxx", "cancelReason": 0, "userCancellationTimeMillis": "1526543175826", "orderId": "GPA.3353-9191-0752-74136", "purchaseType": 0 }

结论 - 原始订阅(幸运的是)不是新订阅的克隆,这两个令牌之间不共享诸如 expiryTimeMillis 之类的字段。然而,两者的 startTimeMillis 是相同的