What is the response for RESTORE_TRANSACTIONS in case of subscription bought twice?

最后都变了- 提交于 2019-12-12 05:40:04

问题


I can't test this myself, because there is no way to completely terminate subscription, apparently.

So, I want to test the following use case: user buys subscription, cancel's it (or it expires), than user buys same subscription.

What will I get with RESTORE_TRANSACTIONS response? Will I get two items with same item id, different purchase tokens and different state? Or purchaseToken will remain the same? I'm afraid that there will be only one subscription with different order ID and purchase token, and the information on previous subscriptions will be lost, but I can't confirm it right now. Also, will orderId be changed with every recurring purchase inside a subscription?

Why I need this - subscription will supply user with new content daily, so when user cancel subscription (subscription A) and later buys a new one (subscription B) I need to show to user content released during time-frame of subscription A,and content in a time-frame of subscription B, but not the content released in period used didn't had active subscription.


回答1:


Note: You should use the RESTORE_TRANSACTIONS request type only when your application is installed for the first time on a device or when your application has been removed from a device and reinstalled.

Using RESTORE_TRANSACTIONS on a regular basis is not recommended because of performance impacts.

Taken right from Android Developers http://developer.android.com/guide/google/play/billing/billing_overview.html

Although I do understand your concern for the Subscription Billing. Google is pretty good about their API and how you should interact with purchases.

When you send a RESTORE_TRANSACTIONS request you will get two broadcast back. A RESPONSE_CODE and a PURCHASE_STATE_CHANGED. Here's the table from Google stating the different values you could receive.

Coming back to your question about buying two subscriptions: you should check to see if the user has bought a subscription with the GET_PURCHASE_INFORMATION request, if the Subscription is in the list check the Purchase State of the Subscription to see if you should continue with the purchase.

As for what you would get if you "Could" buy two of the same subscriptions, its (I want to say impossible) unlikely... But you will get two order transactions.

As long as you're always aware of the user transactions on your part, Google's API will do the rest. Good luck!



来源:https://stackoverflow.com/questions/12563733/what-is-the-response-for-restore-transactions-in-case-of-subscription-bought-twi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!