RevenueCat / purchases-android

Android in-app purchases and subscriptions made easy.
https://www.revenuecat.com/
MIT License
234 stars 44 forks source link

`AmazonStoreProduct` `period` is `null` for subscription with free trial during Live App Testing on the Amazon App Store. #1771

Open zahnooo opened 6 days ago

zahnooo commented 6 days ago

Describe the bug Summary: AmazonStoreProduct period is null for subscription with free trial during Live App Testing on the Amazon App Store.

In the Amazon Developer Console we have set up one subscription in-app items with two terms:

When testing our app with Amazon Live App Testing, we found that the annual subscription package object from RevenueCat (type AmazonStoreProduct) does not have a period set (it’s “period=null”), however, the monthly subscription has a period set as expected (“period=Period(value=1, "unit=MONTH", iso8601=P1M)”). The main difference between the two is that the annual subscription has a free trial period.

This hinders us from displaying our available packages as desired with the proper subscription period.

I noticed that in the RevenueCat documentation, StoreProduct period has documented

    /**
     * Subscription period.
     *
     * Note: Returned only for Google subscriptions. Null for Amazon or for INAPP products.
     */
    val period: Period?

(also see this issue), whereas the AmazonStoreProduct period has documented

    /**
     * Subscription period.
     *
     * Note: Returned only for subscriptions. Null for INAPP products.
     */
    override val period: Period?

So is it expected to be null or not, and why is it then not null for the monthly subscription?

We’re using RevenueCat v8.1.0.

My device is a Amazon Fire HD 8 (12th Generation), running Android 11 (SDK 30).

Here are the RevenueCat Package objects, logged from a Live App Testing build of our app from the Amazon App Store:

Monthly:

   Package("identifier=$rc_monthly",
   "packageType=MONTHLY",
   "product=AmazonStoreProduct(id=XXX",
   "type=SUBS",
   "name=Pro Access",
   "title=Pro Access",
   "description=XXX",
   period=Period(value=1,
   "unit=MONTH",
   iso8601=P1M),
   price=Price(formatted=XXX €,
   amountMicros=XXX,
   "currencyCode=EUR)",
   "subscriptionOptions=null",
   "defaultOption=null",
   "iconUrl=XXX,
   "freeTrialPeriod=null",
   "originalProductJSON="{
      "sku":"XXX",
      "productType":"SUBSCRIPTION",
      "description":"XXX",
      "price":"XXX €",
      "smallIconUrl":"XXX",
      "title":"Pro Access",
      "coinsRewardAmount":0,
      "subscriptionPeriod":"Monthly"
   },
   presentedOfferingContext=PresentedOfferingContext(offeringIdentifier=XXX,
   "placementIdentifier=null",
   "targetingContext=null))",
   presentedOfferingContext=PresentedOfferingContext(offeringIdentifier=XXX,
   "placementIdentifier=null",
   "targetingContext=null))") 

Annual:

   "Package(identifier=$rc_annual",
   "packageType=ANNUAL",
   "product=AmazonStoreProduct(id=XXX",
   "type=SUBS",
   "name=Pro Access",
   "title=Pro Access",
   "description=XXX",
   "period=null",
   price=Price(formatted=XXX €,
   amountMicros=XXX,
   "currencyCode=EUR)",
   "subscriptionOptions=null",
   "defaultOption=null",
   "iconUrl=XXX,
   freeTrialPeriod=Period(value=1,
   "unit=MONTH",
   iso8601=P1M),
   "originalProductJSON="{
      "sku":"XXX",
      "productType":"SUBSCRIPTION",
      "description":"XXX",
      "price":"XXX €",
      "smallIconUrl":"XXX",
      "title":"Pro Access",
      "coinsRewardAmount":0,
      "subscriptionPeriod":"Annual",
      "freeTrialPeriod":"Monthly"
   },
 presentedOfferingContext=PresentedOfferingContext(offeringIdentifier=XXX,
   "placementIdentifier=null",
   "targetingContext=null))",
 presentedOfferingContext=PresentedOfferingContext(offeringIdentifier=XXX,
   "placementIdentifier=null",
   "targetingContext=null))"

Please also note that, when using Amazon App Tester App with the amazon.sdktester.json exported from the Amazon developer console and a debug build from our app, the in-app products are received as expected from the RevenueCat SDK, and here, the annual subscription has both a period and the freeTrialPeriod info set. It only is broken with Amazon Live App Testing.

  1. Environment

    1. Platform: Android (Amazon)

    2. SDK version: 8.1.0

    3. OS version: Android 11 (SDK 30)

    4. Android Studio version: Android Studio Jellyfish | 2023.3.1 Patch 1 Build #AI-233.14808.21.2331.11842104, built on May 15, 2024 Runtime version: 17.0.10+0-17.0.10b1087.21-11572160 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 15.0 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 12 Metal Rendering is ON Registry: ide.experimental.ui=true

    5. How widespread is the issue. Percentage of devices affected: Not live yet, but 100% reproducible in Amazon Live App Testing

  2. Debug logs that reproduce the issue: See above
  3. Steps to reproduce, with a description of expected vs. actual behavior: See above
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
RCGitBot commented 6 days ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

zahnooo commented 4 days ago

In the meantime I think I have identified the issue, and it doesn't have anything to do with the free trial period. In RevenueCat's storeProductConversions.kt internal fun String.createPeriod(): Period? (line 40), there is a match for "SemiAnnually" and "Annually". However, Amazon returns as subscriptionPeriod (and assumably also freeTrialPeriod) "SemiAnnual" and "Annual", see https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html#successful-request .

Looks like there is a difference in Debug and Release though:

michaelAtRC commented 3 days ago

Hey @zahnooo ,

Thanks for reaching out and for the info here.

On Amazon Appstore, when an eligible user attempts to purchase a product that has an introductory offer (e.g. a free trial) the offer will be applied automatically. Are you possibly checking for eligibility before displaying this to user/starting the free trial? If you are, is it reporting that the user is eligible when you are running this in the debug environment?

I will share this with the rest of the team to get some more eyes on this, thanks for all the info provided here!