Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to consume the subscription type in app product purchase

I have implemented the subscription type in-app products in my app like 1 month or 2 months package, once a user subscribe to the product I let the server know and deal with him/her accordingly and it is working very fine.

According to Google at completion of subscription period:

Google auto-cut the credit and renew the package.

My problem: How do I get to know the user who have paid for next the month or not?

like image 1000
Mohsin Avatar asked Feb 02 '26 13:02

Mohsin


2 Answers

Answering the question: You cant consume the subscriptions. You can consume only inapps.

Quote from docs:

Important: Unlike in-app products, subscriptions cannot be consumed. Source: https://developer.android.com/google/play/billing/api.html

That page leads to these two: https://developer.android.com/google/play/billing/billing_subscriptions.html https://developer.android.com/google/play/billing/billing_integrate.html#Subs

Also notice that when offering subscription, it is best to allow user to restore the subscription. For example if a user logged in in your app, purchased a subscription and then logged in with another username, the subscription should be available there too, because it is attached to users google play account.

To do that you should query for purchased subs like marmor specified.

like image 86
lxknvlk Avatar answered Feb 05 '26 02:02

lxknvlk


You can get a list of active purchases from Google Play, and then update your server accordingly (e.g. daily).

IInAppBillingService service = ...;
Bundle items = service.getPurchases(API_VERSION, PACKAGE_NAME, "subs", null);
int response = getResponseCodeFromBundle(items);
if (response != RESULT_OK) {
  // handle error
}
ArrayList<String> productIDs = items.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
// update server with active product ids
like image 33
marmor Avatar answered Feb 05 '26 03:02

marmor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!