purchases-ios icon indicating copy to clipboard operation
purchases-ios copied to clipboard

Testing macOS IAP in sandbox

Open beeloo42 opened this issue 1 year ago • 26 comments

Describe the bug In sandbox, when running a macOS app with .storekit configuration, even if it's launched with Xcode or Finder, the StoreKit products are visible. But when one of them is purchased, or when restoring purchase, the error is: The receipt is missing.

Otherwise, in the StoreKit transaction debugger, Xcode says "⚠️ The transaction has not been finished by calling [SKPaymentQueue finishTransaction:]", on each "purchased" product

In other terms, RevenueCat in sandbox IAP environment can't tell which entitlement is active.

  1. Environment

    1. Platform: macOS 13
    2. SDK version: 4.20.0
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): No
    4. OS version: 13.5 Beta (22G5027e)
    5. Xcode version: 14.3 (14E222b)
    6. Affects all users, 100%
  2. Debug logs that reproduce the issue

On .purchase call:

[Purchases] - INFO: 💰 Purchasing Product 'myProduct' from package in Offering 'default' [Purchases] - DEBUG: ℹ️ Adding payment for product 'myProduct'. 2 transactions already in the queue. [Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x000060000303fc60) updatedTransaction: myProduct 0 1 [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple. [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished [Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account. [Purchases] - ERROR: 🍎‼️ The receipt is missing. [Purchases] - ERROR: 💰 Product purchase for 'myProduct' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={readable_error_code=MISSING_RECEIPT_FILE, source_function=handlePurchasedTransaction(_:storefront:restored:), NSLocalizedDescription=The receipt is missing., source_file=RevenueCat/PurchasesOrchestrator.swift:744}

On .restorePurchases call:

[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: xxxx-A0BD-49FD-BF4A-xxxx [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple. [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished [Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account. Error: loadedEmptyReceipt [Purchases] - WARN: 🍎‼️ App running in sandbox without a receipt file. Restoring transactions won't work until a purchase is made to generate a receipt. This should not happen in production unless user is logged out of Apple account. [Purchases] - ERROR: 🍎‼️ The receipt is missing.

  1. Steps to reproduce, with a description of expected vs. actual behavior

Add needed products on RevenueCat.com and follow the guides to configure the SDK in a macOS app. Configure the .storekit file and link it into the app's scheme in Xcode. Login with a valid sandbox user in App Store. Build app to call .purchase(package: Package) async throws Build app to call .restorePurchases(completion: ((CustomerInfo?, PublicError?) -> Void)?). Both calls fail with error The receipt is missing. Open Xcode's StoreKit Transactions. Observe that transactions are not finished (see screenshot).

It's expected to successfully purchase a product, generate a receipt, and to return the active entitlement through the CustomerInfo.

  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Purchase success Transactions are not finished

beeloo42 avatar May 27 '23 10:05 beeloo42