【问题标题】:Android - Billing 5.0.0 - Data structure explanation?Android - Billing 5.0.0 - Data structure explanation?
【发布时间】:2022-12-02 07:44:16
【问题描述】:

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.

【问题讨论】:

标签: android in-app-billing in-app-subscription play-billing-library


【解决方案1】:

When you try to retrieve the subscriptionOfferDetails, it returnsallthe 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).

【讨论】:

  • 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.
  • 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 you
【解决方案2】:

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.

【讨论】:

    【解决方案3】:

    I also faced this problem.

    You can now use the first value of subscriptionOfferDetails. And it has a list of pricingPhases.pricingPhaseList, in which thefirst value will be "free period", and thesecond 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
    

    【讨论】:

    • Yes I know, that is what I did as well. But what I'm looking for here is an explanation of why this happens.
    猜你喜欢
    • 2022-07-16
    • 1970-01-01
    • 2022-12-01
    • 2016-04-29
    • 2016-04-08
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    相关资源
    最近更新 更多