java 在 Android 中检查应用内订阅的状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31957406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check the status of In-App Subscription in Android
提问by Gaurang
I have created an application in which there is in-app purchases which has monthly auto renewal.. on first time successful payment i have called a web-service in which i have made the user to premium class.
我创建了一个应用程序,其中有应用程序内购买,每月自动续订.. 在第一次成功付款时,我调用了一个网络服务,我已经让用户进入高级课程。
Now if the user has cancelled the payment manually from the google server, how could i know that user has cancelled his/her subscription.
现在如果用户从谷歌服务器手动取消付款,我怎么知道用户已经取消了他/她的订阅。
Is there is some PHP code query or from android i have to called something in background to check the status??
是否有一些 PHP 代码查询或来自 android 我必须在后台调用一些东西来检查状态?
Thank you in advace
提前谢谢你
采纳答案by spcial
You can check the purchased subscriptions inside the app via
您可以通过以下方式检查应用程序内购买的订阅
Edit:For subscriptions use "subs", for inapp-purchases use "inapp" e.g.:
编辑:订阅使用“subs”,inapp-purchases使用“inapp”,例如:
Inapp-Purchases: mService.getPurchases(3, getPackageName(), "inapp", null);
Inapp-购买: mService.getPurchases(3, getPackageName(), "inapp", null);
Subscriptions: mService.getPurchases(3, getPackageName(), "subs", null);
订阅: mService.getPurchases(3, getPackageName(), "subs", null);
See also Querying for Purchased Items
at http://developer.android.com/google/play/billing/billing_integrate.html
另请参见Querying for Purchased Items
在http://developer.android.com/google/play/billing/billing_integrate.html
So you can implement a task in your app where you check if the user still has a subscription. If not, you can remove the premium status. Moreover this information could be useful for you:
因此,您可以在您的应用程序中实施一项任务,您可以在其中检查用户是否仍有订阅。如果没有,您可以删除高级状态。此外,这些信息可能对您有用:
When the user cancels a subscription, Google Play does not offer a refund for the current billing cycle. Instead, it allows the user to have access to the canceled subscription until the end of the current billing cycle, at which time it terminates the subscription. For example, if a user purchases a monthly subscription and cancels it on the 15th day of the cycle, Google Play will consider the subscription valid until the end of the 30th day (or other day, depending on the month).
当用户取消订阅时,Google Play 不会提供当前计费周期的退款。相反,它允许用户在当前计费周期结束之前访问已取消的订阅,届时它会终止订阅。例如,如果用户购买了月度订阅并在周期的第 15 天取消,则 Google Play 将认为订阅有效至第 30 天(或其他日期,取决于月份)。
source: http://developer.android.com/google/play/billing/billing_subscriptions.htmlunder subscription cancelled
来源:http: //developer.android.com/google/play/billing/billing_subscriptions.html下subscription cancelled
Hope this could help you
希望这可以帮助你
Edit2:Because the AIDL library which is mentioned in my answer is deprecated and deactivated in the future, it is recommended to switch to the new Google Play Billing Library.
Edit2:因为我的回答中提到的AIDL库在以后被弃用和停用,建议切换到新的Google Play Billing Library。
回答by Juuso Ohtonen
I haven't tested this, but could you use the autoRenewing
field in INAPP_PURCHASE_DATA?
我还没有测试过这个,但是你可以使用autoRenewing
INAPP_PURCHASE_DATA 中的字段吗?
If true, the subscription is active, and will automatically renew on the next billing date. If false, indicates that the user has canceled the subscription.
如果为 true,则订阅处于活动状态,并将在下一个计费日期自动续订。如果为 false,则表示用户已取消订阅。
http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent
http://developer.android.com/google/play/billing/billing_reference.html#getBuyIntent
Apparently, the autoRenewing
field was added or at least documented in the beginning of 2015.
显然,该autoRenewing
领域在 2015 年初被添加或至少记录在案。