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

Testing macOS IAP in sandbox #2558

Open
beeloo42 opened this issue May 27, 2023 · 26 comments
Open

Testing macOS IAP in sandbox #2558

beeloo42 opened this issue May 27, 2023 · 26 comments
Labels

Comments

@beeloo42
Copy link

beeloo42 commented May 27, 2023

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 beeloo42 added the bug label May 27, 2023
@RCGitBot
Copy link
Contributor

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

@beeloo42 beeloo42 changed the title macOS Sandbox IAP testing macOS IAP with sandbox May 27, 2023
@beeloo42 beeloo42 changed the title macOS IAP with sandbox Testing macOS IAP in sandbox May 27, 2023
@aboedo
Copy link
Member

aboedo commented May 29, 2023

@beeloo42 thanks for reporting!!
For clarity, since there are a few ways of having a mac app nowadays, is this:

  • native mac app
  • iOS app on mac (through apple silicon)
  • mac catalyst

I have a feeling that what might be happening internally is that appStoreReceiptURL might be returning the wrong value on one of these.

@beeloo42
Copy link
Author

@aboedo thanks for replying!! :)
This is a full native SwiftUI Mac App.
I can find a Zero byte receipt in Contents/_MASReceipt/ now.
But I can't also find a 2 Bytes one, sometimes

@aboedo
Copy link
Member

aboedo commented May 29, 2023

I can reproduce. It didn't happen to me the first time, weirdly enough, but after making the first purchase, I get the same result.

Interesting thing is that the receipt is there, it's just an empty file.

@aboedo
Copy link
Member

aboedo commented May 29, 2023

I'm going to file a radar, including a sample app that can be used to easily reproduce. I sincerely wish there was more we could do here, but without a receipt, it's basically impossible for us to process a purchase.

Thanks for reporting!

@aboedo
Copy link
Member

aboedo commented May 29, 2023

Filed as FB12211772. I'll keep this thread updated if / when I get a response.

@beeloo42
Copy link
Author

beeloo42 commented Jun 5, 2023

If you have been able to reproduce, did get a chance to debug ?

Here are some logs of 4.21.0.
That's very strange.
Also it tries to connect to http://localhost:49891/WebObjects/MZFinance.woa/wa/createAppReceipt, see below.

on start:

[Purchases] - VERBOSE: DeviceCache.init: DeviceCache (0x00006000016cc540)
[Purchases] - VERBOSE: StoreKit1Wrapper.init: StoreKit1Wrapper (0x00006000016faa00)
[Purchases] - DEBUG: 👤 Identifying App User ID
[Purchases] - VERBOSE: PurchasesOrchestrator.init: PurchasesOrchestrator (0x000000013676c800)
[Purchases] - DEBUG: ℹ️ Debug logging enabled
[Purchases] - DEBUG: ℹ️ SDK Version - 4.21.0
[Purchases] - DEBUG: ℹ️ Bundle ID - app.bundle.id
[Purchases] - DEBUG: ℹ️ System Version - Version 13.5 (Build 22G5038d)
[Purchases] - DEBUG: ℹ️ Not using a simulator.
[Purchases] - DEBUG: 👤 Initial App User ID set
[Purchases] - VERBOSE: Purchases.init: created new Purchases instance: Purchases (0x00000001367050e0)
StoreKit Wrapper: left(<RevenueCat.StoreKit1Wrapper: 0x6000016faa00>)
[Purchases] - DEBUG: ℹ️ Delegate set
[Purchases] - WARN: 🍎‼️ SKPaymentQueue sent 115 updated transactions. This high number is unexpected and is likely due to using an old sandbox account on a new device. If this is impacting performance, using a new sandbox account is recommended.
[Purchases] - DEBUG: ℹ️ Configuring SDK using RevenueCat's UserDefaults suite.
[Purchases] - VERBOSE: DeviceCache.init: DeviceCache (0x00006000016cc540)
[Purchases] - VERBOSE: StoreKit1Wrapper.init: StoreKit1Wrapper (0x00006000016faa00)
[Purchases] - DEBUG: 👤 Identifying App User ID
[Purchases] - VERBOSE: PurchasesOrchestrator.init: PurchasesOrchestrator (0x000000013676c800)
[Purchases] - DEBUG: ℹ️ Debug logging enabled
[Purchases] - DEBUG: ℹ️ SDK Version - 4.21.0
[Purchases] - DEBUG: ℹ️ Bundle ID - app.bundle.id
[Purchases] - DEBUG: ℹ️ System Version - Version 13.5 (Build 22G5038d)
[Purchases] - DEBUG: ℹ️ Not using a simulator.
[Purchases] - DEBUG: 👤 Initial App User ID set
[Purchases] - VERBOSE: Purchases.init: created new Purchases instance: Purchases (0x00000001367050e0)
StoreKit Wrapper: left(<RevenueCat.StoreKit1Wrapper: 0x6000016faa00>)
Purchases] - DEBUG: ℹ️ Delegate set
[Purchases] - WARN: 🍎‼️ SKPaymentQueue sent 115 updated transactions. This high number is unexpected and is likely due to using an old sandbox account on a new device. If this is impacting performance, using a new sandbox account is recommended.
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00006000016faa00) updatedTransaction: subscription_id_1 100 0 1
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: APP_USER_ID
[Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00006000016faa00) updatedTransaction: subscription_id_1 101 0 1
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: APP_USER_ID
[Purchases] - DEBUG: ℹ️ Throttled request to refresh receipt.
[Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account.
Error: loadedEmptyReceipt
[Purchases] - DEBUG: ℹ️ Receipt empty, refreshing
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00006000016faa00) updatedTransaction: subscription_id_1 102 0 1
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: APP_USER_ID
[Purchases] - DEBUG: ℹ️ Throttled request to refresh receipt.
[Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account.

(looping last lines of previous logs 113 times)

[Purchases] - DEBUG: ℹ️ CustomerInfo cache is stale, updating from network in foreground.
[Purchases] - DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground

(...merged with some of the previous loop., and also..)

[Purchases] - DEBUG: ℹ️ Found unfinished transactions, will post receipt in lieu of fetching CustomerInfo:
[<StoreTransaction:
    identifier="203"
    product="subscription_id_2"
    date="2023-06-05 16:09:29 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="202"
    product="subscription_id_2"
    date="2023-06-05 16:09:18 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="201"
    product="subscription_id_2"
    date="2023-06-05 16:09:07 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="200"
    product="subscription_id_2"
    date="2023-06-05 16:08:56 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="199"
    product="subscription_id_2"
    date="2023-06-05 16:08:45 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="198"
    product="subscription_id_2"
    date="2023-06-05 16:08:34 +0000"
    quantity=1
>, <StoreTransaction:
    identifier="197"
    pro

(...then looping again, and also...)

<SKReceiptRefreshRequest: 0x600003276fc0>: Finished refreshing receipt with error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={AMSStatusCode=0, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <511BB4EA-A2EE-44F4-A537-D0F1FA61CE8F>.<1>, NSErrorFailingURLKey=http://localhost:49891/WebObjects/MZFinance.woa/wa/createAppReceipt, _kCFStreamErrorDomainKey=10, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <511BB4EA-A2EE-44F4-A537-D0F1FA61CE8F>.<1>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=http://localhost:49891/WebObjects/MZFinance.woa/wa/createAppReceipt, NSUnderlyingError=0x600003c80f30 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey_desc=satisfied (Path is satisfied), interface: lo0, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _kCFStreamErrorCodeKey=-72000}

(...then looping again, and also...)

[Purchases] - WARN: ⚠️ Attempt to update CustomerInfo from network failed.
The operation couldn’t be completed. (RevenueCat.BackendError error 3.)
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 🍎‼️ SKProductsRequest took longer than 30 seconds, cancelling request and returning an empty set. This seems to be an App Store quirk. If this is happening to you consistently, you might want to try using a new Sandbox account. More information: https://rev.cat/skproductsrequest-hangs
[Purchases] - ERROR: 🍎‼️ SKProductsRequest took too long to complete.
[Purchases] - ERROR: 🍎‼️ Error fetching offerings - The operation couldn’t be completed. (RevenueCat.OfferingsManager.Error error 2.)
The operation couldn’t be completed. (RevenueCat.ErrorCode error 32.)
Underlying error: SKProductsRequest took too long to complete.
[Purchases] - ERROR: 🍎‼️ Store products request failed! Error: A server with the specified hostname could not be found.
[Purchases] - ERROR: 😿‼️ callback not found for failing request: <SKProductsRequest: 0x6000032cce20>

on .purchase:

[Purchases] - INFO: 💰 Purchasing Product 'subscription_product_id' from package in Offering 'default'
[Purchases] - DEBUG: ℹ️ Adding payment for product 'subscription_product_id'. 40 transactions already in the queue.
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x0000600000dbe160) updatedTransaction: subscription_product_id 101 0 1
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: APP_USER_ID
[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
4309:71462] [Purchases] - ERROR: 🍎‼️ The receipt is missing.
4309:71462] [Purchases] - ERROR: 💰 Product purchase for 'subscription_product_id' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={source_file=RevenueCat/TransactionPoster.swift:96, source_function=handlePurchasedTransaction(_:data:completion:), NSLocalizedDescription=The receipt is missing., readable_error_code=MISSING_RECEIPT_FILE}

on . restorePurchases:

[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: APP_USER_ID
[Purchases] - DEBUG: ℹ️ Throttled request to refresh receipt.
[Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account.
Error: loadedEmptyReceipt
[Purchases] - DEBUG: ℹ️ Receipt empty, refreshing
[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.

@beeloo42 beeloo42 closed this as completed Jun 5, 2023
@beeloo42 beeloo42 reopened this Jun 5, 2023
@beeloo42
Copy link
Author

I'm not sure, but I think the bugs are located in the RevenueCat framework.
Would you have a chance to fix this ?

@Scure21
Copy link

Scure21 commented Jun 13, 2023

Any updates on this issue? running into a "The receipt is missing." error that prevents purchases from being successful in sandbox env in Xcode.

Details:

  • RevenueCat SDK v 4.21.1

  • Using a sandbox account to test purchases

  • I've added placeholders in the logs for:

    • PRODUCT_ID Revenuecat product id
    • SUBSCRIBER_ID RevenueCat user id
    • PATH File path for the receipt
  • I see the in app purchase UI comes up and walks me through the purchase flow indicating that the environment is sandbox

  • After getting the purchase successful message in the UI and hitting ok to continue, I see a debug log that says the purchase was not successful because of the missing receipt

  • Checking the RevenueCat customer data with the sandbox option checked, doesn't show the purchase. So the error seems to prevent the purchase from going through

Logs:

[Purchases] - INFO: 💰 Purchasing Product PRODUCT_ID from package in Offering 'default'
[Purchases] - DEBUG: ℹ️ Adding payment for product PRODUCT_ID. 0 transactions already in the queue.
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x000000012078ec70) updatedTransaction: PRODUCT_ID 0
[Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/SUBSCRIBER_ID (304)
[Purchases] - DEBUG: ℹ️ Sending latest CustomerInfo to delegate.
[Purchases] - DEBUG: 😻 CustomerInfo updated from network.
[Purchases] - DEBUG: ℹ️ Detected active subscriptions changed. Clearing trial or intro eligibility cache.
[Purchases] - DEBUG: ℹ️ GetCustomerInfoOperation: Finished
[Purchases] - DEBUG: ℹ️ PurchasedProductsFetcher: invalidating cache
[Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/SUBSCRIBER_ID, 0 requests left in the queue
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x000000012078ec70) updatedTransaction: PRODUCT_ID 2000000349402311 1
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: SUBSCRIBER_ID
[Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
[Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started
<SKReceiptRefreshRequest: 0x1218069b0>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedDescription=Request throttled, NSLocalizedFailureReason=Unified receipt is valid and current}
[Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished
[Purchases] - WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account.
Error: Error Domain=NSCocoaErrorDomain Code=260 "The file "receipt" couldn't be opened because there is no such file." UserInfo={NSFilePath=PATH/Contents/_MASReceipt/receipt, NSUnderlyingError=0x121917490 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
[Purchases] - ERROR: 🍎‼️ The receipt is missing.
[Purchases] - ERROR: 💰 Product purchase for PRODUCT_ID failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={NSLocalizedDescription=The receipt is missing., source_file=RevenueCat/TransactionPoster.swift:96, source_function=handlePurchasedTransaction(_:data:completion:), readable_error_code=MISSING_RECEIPT_FILE}

@beeloo42
Copy link
Author

Using StoreKit 2 directly, I can purchase and parse the receipt

@hma17
Copy link

hma17 commented Jun 13, 2023

SOLUTION: the file path for the receipt saves in the wrong location.

Go to Product (in XCode Toolbar) --> Show Build Folder in Finder

Expected File path: /Build/Products/Debug/[App Name].app/Contents/PlugIns/[Extension name].appex/Contents/_MASReceipt/receipt

Actual File path: /Build/Products/Debug/[App Name].app/Contents/_MASReceipt/receipt

Moving the '_MASReceipt' folder to the correct place makes it that we can see the purchases in RC sandbox accounts.

@NachoSoto
Copy link
Contributor

NachoSoto commented Jun 13, 2023

Interesting, did you find the receipt in /Build/Products/Debug/[App Name].app/Contents/PlugIns/[Extension name].appex/Contents/_MASReceipt/receipt or in /Build/Products/Debug/[App Name].app/Contents/_MASReceipt/receipt?

The RevenueCat SDK loads it from Bundle.appStoreReceiptURL. If we can determine that this is wrong in sandbox macOS apps we can do a similar workaround to what we did in #330

@hma17
Copy link

hma17 commented Jun 13, 2023

I found it in Build/Products/Debug/[App Name].app/Contents/_MASReceipt/receipt but it was looking for it in the first file path you mentioned

@aboedo
Copy link
Member

aboedo commented Jun 14, 2023

@hma17 thanks for reporting! I guess it's time for another StoreKit Bug Workaround ™️

@NachoSoto
Copy link
Contributor

Looking into this right now.
Question: are you testing this only in macOS version: 13.5 Beta? I'm testing this on 13.4 and it's able to find the receipt without issues under the file in Bundle.appStoreReceiptURL.

I found it in Build/Products/Debug/[App Name].app/Contents/_MASReceipt/receipt but it was looking for it in the first file path you mentioned

The SDK uses Bundle.main. Which target is initializing the SDK? I wonder if you're initializing it from an extension.
In your debug logs, I see you have this:

[Purchases] - DEBUG: ℹ️ Bundle ID - app.bundle.id

I imagine you redacted that, but this is the bundle we're using to look up appStoreReceiptURL. Does that match your main app's bundle ID?

@NachoSoto
Copy link
Contributor

It appears that the problem here is that the receipt is empty after a successful purchase in sandbox, which is a bug.
We're in the process of better supporting StoreKit 2 so we don't have to rely on the presence of the receipt in the SDK. In the mean time we're still waiting to hear back from Apple (FB12211772).

NachoSoto added a commit that referenced this issue Jun 14, 2023
I wanted to support it to be able to look into #2558.
NachoSoto added a commit that referenced this issue Jun 14, 2023
…ntext

Added `rc_receipt_url` and `rc_receipt_file_exists`. This is useful when debugging issues like #2558.
Example:
```
[Purchases] - ERROR: 💰 Product purchase for 'rc_1099_1w' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={NSLocalizedDescription=The receipt is missing., readable_error_code=MISSING_RECEIPT_FILE, source_function=handlePurchasedTransaction(_:data:completion:), rc_receipt_url=file:///.../Build/Products/Debug/...app/Contents/_MASReceipt/receipt, rc_receipt_file_exists=true, source_file=RevenueCat/TransactionPoster.swift:96}
```
NachoSoto added a commit that referenced this issue Jun 14, 2023
…ntext (#2650)

Added `rc_receipt_url` and `rc_receipt_file_exists`. This is useful when
debugging issues like #2558.
This goes from this:
> [Purchases] - ERROR: 💰 Product purchase for 'rc_1099_1w' failed with
error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is
missing." UserInfo={NSLocalizedDescription=The receipt is missing.,
readable_error_code=MISSING_RECEIPT_FILE,
source_function=handlePurchasedTransaction(_:data:completion:),
source_file=RevenueCat/TransactionPoster.swift:96}

To this:
> [Purchases] - ERROR: 💰 Product purchase for 'rc_1099_1w' failed with
error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is
missing." UserInfo={NSLocalizedDescription=The receipt is missing.,
readable_error_code=MISSING_RECEIPT_FILE,
source_function=handlePurchasedTransaction(_:data:completion:),
rc_receipt_url=file:///.../Build/Products/Debug/...app/Contents/_MASReceipt/receipt,
rc_receipt_file_exists=true,
source_file=RevenueCat/TransactionPoster.swift:96}

In this case, we can see the file does exist, so it must be empty.
NachoSoto added a commit that referenced this issue Jun 15, 2023
Useful when debugging issues like #2558.
NachoSoto added a commit that referenced this issue Jun 15, 2023
@hma17
Copy link

hma17 commented Jun 15, 2023

Looking into this right now. Question: are you testing this only in macOS version: 13.5 Beta? I'm testing this on 13.4 and it's able to find the receipt without issues under the file in Bundle.appStoreReceiptURL.

I found it in Build/Products/Debug/[App Name].app/Contents/_MASReceipt/receipt but it was looking for it in the first file path you mentioned

The SDK uses Bundle.main. Which target is initializing the SDK? I wonder if you're initializing it from an extension. In your debug logs, I see you have this:

[Purchases] - DEBUG: ℹ️ Bundle ID - app.bundle.id

I imagine you redacted that, but this is the bundle we're using to look up appStoreReceiptURL. Does that match your main app's bundle ID?

@NachoSoto Thanks for the reply!

After looking into this we found that Bundle.main.appStoreReceiptURL is returning Contents/_MASReceipt/receipt -- file:///Users/[username]/Library/Developer/Xcode/DerivedData/[App Name]/Build/Products/Debug/[App Name].app/Contents/PlugIns/[ExtensionName].appex/

The initial solution I mentioned in this thread still works - where we move the receipt folder to the extension's content folder from the main app content folder where it saves initially

Our receipt is not empty after a purchase, but it looks like the SDK is saving the receipt folder in the main app, rather than in the extension.

@NachoSoto
Copy link
Contributor

The SDK doesn't save the receipt itself, that's done by StoreKit.
Can you confirm that you're configuring the SDK from an extension target? I'm curious what your setup looks like.

We might be able to add a configuration parameter to Purchases.configure so that you can inject a custom Bundle, but I'm curious where your discrepancy is coming from.

@Scure21
Copy link

Scure21 commented Jun 15, 2023

@NachoSoto Hi! I'm working with @hma17. We're configuring the SDK from an extension target. Could we set up some time to chat through zoom and walk through the issue/setup? :)

@NachoSoto
Copy link
Contributor

Yeah that would be great, I’d love to understand your setup better to see how the SDK can work out of the box.

Mind sending an email to [email protected]?
Thanks!

@andrewtheis
Copy link

Wondering if any movement on this? I'm getting the same error but I'm not using an app extension. Receipt file is 0 bytes. RevenueCat is also not seeing the purchase.

@JWambaugh
Copy link

I am having this issue with a macos app using the flutter SDK as well. My bundle does not have a plugins folder.
using xcode 15.0.0 on macos14.
Logs:

WARN: 🍎‼️ Unable to load receipt, ensure you are logged in to a valid Apple account.
Error: loadedEmptyReceipt
ERROR: 🍎‼️ The receipt is missing.
ERROR: 💰 Product purchase for 'basic_monthly_99' failed with error: Error Domain=RevenueCat.ErrorCode Code=9 "The receipt is missing." UserInfo={NSLocalizedDescription=The receipt is missing., source_function=handlePurchasedTransaction(_:data:completion:), source_file=RevenueCat/TransactionPoster.swift:114, rc_receipt_file_exists=true, rc_receipt_url=file:///Users/jordan/Library/Developer/Xcode/DerivedData/Runner-hcepkghvlcefyfbbzrdyhekqmxfb/Build/Products/Debug/RefRef.app/Contents/_MASReceipt/receipt, readable_error_code=MISSING_RECEIPT_FILE}

the file at /Users/jordan/Library/Developer/Xcode/DerivedData/Runner-hcepkghvlcefyfbbzrdyhekqmxfb/Build/Products/Debug/RefRef.app/Contents/_MASReceipt/receipt does exist, but has zero bytes.

This seems like a pretty big issue. Is there any updates on this?

@NachoSoto
Copy link
Contributor

Sorry to hear you're experiencing problems with this. We filed a Feedback with Apple (FB12211772) back in May, but haven't heard back from them:

Screenshot 2023-12-06 at 12 33 28

@CameronSima
Copy link

Is this still an active issue? I'm just implementing IAP in my app now .. should I move away from Revenuecat?

@aboedo
Copy link
Member

aboedo commented Jan 19, 2024

We're in late beta stages with full end-to-end StoreKit 2 support, which should fix this issue for anyone on macOS.
If you're running into this issue, would you mind trying out the 4.32.0-beta.1 and enabling StoreKit 2 on it (instructions in the link) and letting us know whether things work as expected with it?

@beeloo42
Copy link
Author

beeloo42 commented Jun 2, 2024

This isn't an Apple side issue.
I switched to my own in-app engine and everything is running with receipts.
Hope this help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants