Android - Billing 5.0.0 - Data structure explanation?
Asked Answered
F

3

8

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?

JUST TO CLARIFY

The weird thing is that the option with the full price comes two times in two different SubscriptionOfferDetails items. The third highlighted item in the picture is what doesn't make sense because that option is already present in the previous SubscriptionOfferDetails item but with a different offerToken.

enter image description here

Frequentation answered 20/6, 2022 at 19:46 Comment(1)
I think this shows that you are having 2 base-plan for that subscription, one having offer(of free-trial) with base-plan and another having only base-plan. Please refer below link for more details about subscription, base-plan and offers :- support.google.com/googleplay/android-developer/answer/12154973Cassicassia
C
0

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).

Cordage answered 22/6, 2022 at 22:33 Comment(2)
I don't have multiple offers. I created the subscriptions 2 years ago, before the revent billing framework changes. It's just a simple monthly subscription with a 2 weeks free trial. I can understand getting one SubscriptionOfferDetails item with two pricing phases 1 for free and one with a price. But I cannot understand why I receive 2 SubscriptionOfferDetails items.Frequentation
Do you remember if you had the configuration of one SKU being the one with the normal price and one SKU with the 2 weeks free trial? In the automated migration, each SKU (even if they had some duplication in terms of offering the same benefits/entitlements) they got ported to a subscription product entity. So if you had for example 2 SKUs, one was a monthly with regular pricing and one monthly w/trial. Those get changed to 2 SubscriptionOfferDetails items, one offer is the regular pricing and one is with the trial. It doesn't automatically consolidate the SKUs for youCordage
M
0

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.

Merrow answered 29/8, 2022 at 8:29 Comment(0)
N
0

I also faced this problem.

You can now use the first value of subscriptionOfferDetails. And it has a list of pricingPhases.pricingPhaseList, in which the first value will be "free period", and the second the full cost. Use this.

Example:

val offerPricesMonth = listSkuDetails[TARIFF_MONTH].subscriptionOfferDetails[0].pricingPhases.pricingPhaseList

// For get free trial
val formattedFreeTrialMonth = offerPricesMonth[0].formattedPrice

// For get cost tariff
val formattedPriceMonth = offerPricesMonth[offerPricesMonth.lastIndex].formattedPrice
Nebula answered 1/12, 2022 at 14:47 Comment(1)
Yes I know, that is what I did as well. But what I'm looking for here is an explanation of why this happens.Frequentation

© 2022 - 2024 — McMap. All rights reserved.