Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Billing Library: Determine base plan / expiry of subscription purchase

I am using the Google Play Billing Library 5 and have a subscription product with different base plans.

When processing the purchases in the PurchasesUpdatedListener or in the callback of queryPurchasesAsync, I receive a list of Purchase objects which contain inter alia the product IDs, purchase time and whether it's auto-renewing.

But how do I know which base plan was selected by the user, and when it expires?

The PurchaseHistoryRecord returned from queryPurchaseHistoryAsync also seems not to contain this info.

I know the Play Developer API returns the expiry time with purchases.subscriptionsv2.get, but is the inconvenience of using the API directly necessary?

like image 532
konrad_sx Avatar asked Sep 11 '25 09:09

konrad_sx


1 Answers

The conclusion I am coming to is that it is best to ignore the whole multiple base plans feature.

Create the subscriptions individually instead so you have Silver_Plan_Monthly --> Silver_Monthly_Base --> Silver_monthly_free_trial_offer. Then a separate subscription. Silver_Plan_Yearly --> Silver_Yearly_Base --> Silver_yearly_free_trial_offer. And so on for however many subscription levels you want Silver, Gold, Platinum etc.

This way when you get the users purchases you can immediately tell what sub/level/renewal period they bought by the productId which will be the subscription name (Silver_Plan_Monthly).

This is annoying in having to create all these subs but the billing library doesn't give enough info otherwise.

And you should be able to now easily upgrade/downgrade user between these levels and the billing periods.

like image 121
mbwasi Avatar answered Sep 14 '25 00:09

mbwasi