Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check the status of In-App Subscription in Android

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??

Thank you in advace

like image 608
Gaurang Avatar asked Aug 12 '15 06:08

Gaurang


People also ask

How do I find out what my subscriptions are?

Manage Subscriptions on iOS or AndroidNavigate to Settings > [your name] > Subscriptions (if you don't have any, this will not appear) to view your services. Tap the service you want to cancel and select Cancel Subscription. On a Mac, you unsubscribe from Settings. Android users can do the same from Google Play.

Can I cancel app subscription?

If you purchased your subscription via Google Play: Check if you're signed in to the correct Google Account. Tap Menu Subscriptions. Select the subscription you want to cancel. Tap Cancel subscription.

Why is my subscription not showing up?

If you can't find your subscriptions, check that you're signed in to the correct account. Make sure to sign in to the Google Account that has your subscriptions. Learn how to add an account or switch accounts. The email you used with the subscription app may be different than your Google Account.


2 Answers

I haven't tested this, but could you use the autoRenewing field in 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.

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.

like image 59
Juuso Ohtonen Avatar answered Sep 18 '22 18:09

Juuso Ohtonen


You can check the purchased subscriptions inside the app via

Edit: For subscriptions use "subs", for inapp-purchases use "inapp" e.g.:

Inapp-Purchases: mService.getPurchases(3, getPackageName(), "inapp", null);

Subscriptions: mService.getPurchases(3, getPackageName(), "subs", null);

See also Querying for Purchased Items at 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).

source: http://developer.android.com/google/play/billing/billing_subscriptions.html under 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.

like image 25
spcial Avatar answered Sep 17 '22 18:09

spcial