Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 tasks done
zahnooo opened this issue Jul 2, 2024 · 5 comments · Fixed by #1813 or #1828

Comments

@zahnooo
Copy link

zahnooo commented Jul 2, 2024

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:

  • Monthly, paid subscription, no free trial, no promotional price
  • Annually, paid subscription, free trial (1 month), no promotional price.

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

Additional context
I yesterday created a [question on the RevenueCat Community](I yesterday posted a question on the RevenueCat Community which might be related to this question: https://community.revenuecat.com/sdks-51/bug-amazonstoreproduct-period-is-null-when-it-contains-a-free-trial-4743?fid=51&tid=4743), however, I think this is actually a bug of some sorts and hence opening an issue here.

@RCGitBot
Copy link
Contributor

RCGitBot commented Jul 2, 2024

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

@zahnooo
Copy link
Author

zahnooo commented Jul 4, 2024

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:

  • Debug: Faked products from Amazon App Tester App -> "SemiAnnually" and "Annually"
  • Release: Real in-app products from the store -> "SemiAnnual" and "Annual"

@michaelAtRC
Copy link

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!

@tessmerandre
Copy link
Contributor

I'm having the same issue, any news here? @michaelAtRC

tonidero pushed a commit that referenced this issue Aug 30, 2024
### Checklist
- [x] If applicable, unit tests
- [x] If applicable, create follow-up issues for `purchases-ios` and
hybrids

### Motivation
<!-- Why is this change required? What problem does it solve? -->
Amazon subscription periods were being incorrectly parsed.

https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html#successful-request

<!-- Please link to issues following this format: Resolves #999999 -->
Resolves #1771

### Description
Amazon returns annual and semiannual subscription periods as `Annual`
and `SemiAnnual`. Please look at the
[docs](https://developer.amazon.com/docs/in-app-purchasing/iap-implement-iap.html#successful-request)
for more information.
Copy link

github-actions bot commented Sep 7, 2024

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants