Android - Billing 5.0.0 - Data structure explanation?

Viewed 503

I'm confused about the new version (5) of android billing library. I have a few subscriptions in my app and each one has a monthly cycle and a 2 weeks free trial. Now I want to show to the users the pricing details for my subscriptions.

And when I get the product details for each subscription it's always the same thing. I get 2 items in the subscriptionOfferDetails list where the first has two PricingPhase items, one with 0 price (free trial) and one with the valid subscription price. And then the second SubscriptionOfferDetails item one has one PricingPhase with the valid subscription price.

So what's up with that? Why is Google returning my subscriptions details in this weird structure? Why do I receive 2 SubscriptionOfferDetails items instead of 1?

Which item should I use to show the proper subscription price ? Also which one should I use to initiate the payment flow when the user wants to buy one? The offer tokens are different.

Note: I have different prices for some countries. Does that somehow come into play here?

enter image description here

2 Answers

When you try to retrieve the subscriptionOfferDetails, it returns all the offers the user is eligible for based on the eligibility criteria.

If an offer has two pricingPhases items, it means that it has a free-trial or intro-offer pricing followed by the regular base plan pricing after the free-trial or intro-offer period has completed.

If the user qualifies for multiple offers, you can use the new tags functionality in the Billing Library v5 to retrieve the chosen offer that the user can buy and use the offerToken to build the billingFlowParams needed to launch the purchase flow (https://developer.android.com/google/play/billing/migrate-gpblv5#launching-offer).

That behavior seems to be correct. For each subscription, you get both “offers”, when the user is qualified to see both offers. Both offers means, the regular subscription (base plan) and the free trial offer (free trial and than base plan). If the user had those subscription before, he won’t see the offer with free trial.

Related