1

I am using version 5 of billing library. I have a subscription with product id "MySub" that has two offers. One monthly and one yearly with offer ids "sum.monthly" and "sub.yearly".

When I purchase for example the monthly option, the purchase object I receive from the billing library only has the product id "MySub". But it's not telling me which offer the user purchased. How do I extract that information from the Purchase object?

Anonymous
  • 4,470
  • 3
  • 36
  • 67

1 Answers1

0

The offer id is not stored in the "Purchase" object returned by the Google Play Billing Library. You can keep track of the offer ID's in your own database or in app or local database and associate the Purchase object with the corresponding offer id based on the time period of the subscription.

For example; If the sub is valid for 30 days you can assume that it's monthly offer, if it's valid for 365 days, you can assume that it's yearly offer.

You can check this with a simple if else struct.

I suggest create another sub plan or create base plan.