RevenueCat / purchases-flutter

Flutter plugin for in-app purchases and subscriptions. Supports iOS, macOS and Android.
https://www.revenuecat.com/
MIT License
607 stars 168 forks source link

Introduction price not applied for new sandbox user(iOS) #274

Closed mrgnhnt96 closed 2 years ago

mrgnhnt96 commented 2 years ago

Describe the bug

Subscription Data:

As expected, checkTrialOrIntroductoryPriceEligibility is IntroEligibilityStatus.introEligibilityStatusEligible for both Monthly & Yearly subscriptions because the sandbox user has no subscriptions.

When I attempt to purchase the Monthly subscription, the purchase prompt offers the intro price, which is expected. When I attempt to purchase the Yearly subscription, the purchase prompt does NOT offer the intro price, which is not expected.

I think that this is because my personal apple id has a past yearly subscription & its being referenced to determine whether to offer the intro price to the sandbox user.

As we are handling multiple apple ids (personal & sandbox) in a debug environment, I don't believe that this is a production issue, only testing.

Additional Details

  1. Environment
    • Debug mode
    • physical iOS device
      1. Output of flutter doctor
        • found below
      2. How widespread is the issue. Percentage of devices affected
        • N/A
  2. Debug logs that reproduce the issue
    • found below
  3. Steps to reproduce, with a description of expected vs. actual behavior
    • I would expect to have the intro promo offered for both monthly & yearly for a new sandbox account

Flutter Doctor

Flutter Doctor ```console [✓] Flutter (Channel stable, 2.5.3, on macOS 11.5.2 20G95 darwin-x64, locale en-US) [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] VS Code (version 1.62.1) [✓] VS Code (version 1.44.1) [✓] Connected device (3 available) ```

Debug Logs

Monthly Logs ```console [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/5AA169DF-BFF9-412E-8364-0E5A0ECB2CF8/StoreKit/sandboxReceipt [Purchases] - DEBUG: ℹ️ Attempting to check intro eligibility locally [Purchases] - INFO: ℹ️ Receipt parsed successfully [Purchases] - DEBUG: ℹ️ Skipping products request because products were already cached. products: {( CSECommunityMonthlyiOS )} [Purchases] - DEBUG: ℹ️ Local intro eligibility computed locally. Result: { CSECommunityMonthlyiOS = 2; } flutter: Intro Eligibility for "CSECommunityMonthlyiOS": "IntroEligibilityStatus.introEligibilityStatusEligible" [Purchases] - DEBUG: ℹ️ Vending Offerings from cache [Purchases] - DEBUG: ℹ️ makePurchase [Purchases] - DEBUG: 💰 Purchasing product from package - CSECommunityMonthlyiOS in Offering default [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: CSECommunityMonthlyiOS (null) ((null)) (null) - 0 ```
Yearly Logs ```console [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/5AA169DF-BFF9-412E-8364-0E5A0ECB2CF8/StoreKit/sandboxReceipt [Purchases] - DEBUG: ℹ️ Attempting to check intro eligibility locally [Purchases] - INFO: ℹ️ Receipt parsed successfully [Purchases] - DEBUG: ℹ️ Skipping products request because products were already cached. products: {( CSECommunityYearlyiOS )} [Purchases] - DEBUG: ℹ️ Local intro eligibility computed locally. Result: { CSECommunityYearlyiOS = 2; } flutter: Intro Eligibility for "CSECommunityYearlyiOS": "IntroEligibilityStatus.introEligibilityStatusEligible" [Purchases] - DEBUG: ℹ️ Vending Offerings from cache [Purchases] - DEBUG: ℹ️ makePurchase [Purchases] - DEBUG: 💰 Purchasing product from package - CSECommunityYearlyiOS in Offering default [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: CSECommunityYearlyiOS (null) ((null)) (null) - 0 ```
codykerns commented 2 years ago

Hey @mrgnhnt96!

The SDK is reporting both as eligible, because the sandbox user that is testing has never made a purchase of either of those products, and the SDK was able to find the introductory price object on the product object, indicating there should be an introductory price. A separate Apple ID having previously made a purchase won't affect this method's result.

Ultimately it's up to Apple to actually apply that introductory price in the system payment sheet- our SDK doesn't do anything to specifically apply it to the purchase as it happens automatically. Somehow, Apple's system sheet is determining that this purchase should not apply the intro price (my best guess is that it's just a sandbox quirk, maybe a propagation issue if you recently added that introductory price).