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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.