Question

"Receipt not valid" error when using local StoreKit testing in Xcode with a Mac Catalyst app

  • 28 July 2021
  • 4 replies
  • 101 views

Badge +1

At WWDC 2020, Apple introduced the ability to do local StoreKit testing in Xcode (that is, testing without connecting to App Store servers and without using sandbox accounts). I am interested in an answer to the question of whether RevenueCat supports local StoreKit testing in Xcode for a RevenueCat-enabled Mac Catalyst app.  As you’ll see below, I’ve been getting a “receipt not valid” error when I attempt that kind of testing for a RevenueCat-enabled Mac Catalyst app.

Apple's documentation on StoreKit testing in Xcode indicates that local StoreKit testing does work for Mac apps (on a Mac running Xcode 12 or later, and macOS 11 or later). And in its own documentation, RevenueCat gives instructions for setting up local StoreKit testing in Xcode. What's not clear is whether StoreKit testing in Xcode works with the combination of RevenueCat and Mac Catalyst apps.

I followed RevenueCat's instructions (just noted in the last paragraph) for setting up local StoreKit testing in Xcode (importantly, also uploading the public certificate to RevenueCat's website). That local StoreKit testing works perfectly with the iOS version of my app. And the local StoreKit testing initially appears to work perfectly with the Mac Catalyst version of the app. Here, though, is what happens when I try testing the Mac Catalyst version:

  1. When I attempt to make a purchase in the Mac Catalyst version, I get the standard Apple prompt with the title, "Confirm Your In-App Purchase", the question, "Do you want to buy [in-app purchase X]?", and the specification of "[Environment: Xcode]."

  2. When I click the "Buy" button on that prompt, I get the standard Apple prompt for a successful purchase, "You're all set. Your purchase was successful. [Environment: Xcode]."

  3. When I click the "OK" button on that prompt, though, I am subsequently greeted with an "Invalid App Store Receipt" error message.

Here is the relevant RevenueCat debug log from Xcode (with two {}-bracketed descriptions where specific values appeared in the log):

[Purchases] - DEBUG: ℹ️ makePurchase[Purchases] - DEBUG: 💰 Purchasing product from package  - com.appsolutelyfun.ArguMap.freeTrial in Offering TrialPlusPro[Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: com.appsolutelyfun.ArguMap.freeTrial (null) ((null)) (null) - 0[Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: com.appsolutelyfun.ArguMap.freeTrial 6 ((null)) 4 - 1[Purchases] - DEBUG: ℹ️ Loaded receipt from url Contents/_MASReceipt/receipt -- file://{path to built app in Xcode's Derived Data folder}/Build/Products/Debug-maccatalyst/ArguMap.app/[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: {specific RCAnonymousID}[Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST /receipts[Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts[Purchases] - DEBUG: ℹ️ API request completed with status: POST /v1/receipts 400[Purchases] - ERROR: 😿‼️ The receipt is not valid.[Purchases] - DEBUG: ℹ️ Serial request done: POST /receipts, 0 requests left in the queue[Purchases] - DEBUG: 💰 Finishing transaction com.appsolutelyfun.ArguMap.freeTrial 6 (4)[Purchases] - DEBUG: ℹ️ PaymentQueue removedTransaction: com.appsolutelyfun.ArguMap.freeTrial 6 (4 (null)) (null) - 1

 

Does anyone have any idea why the "receipt is not valid" error occurs? Everything seems to work fine up until the receipt validation step by the RevenueCat SDK.

(As noted above, I did, indeed, upload the public certificate to RevenueCat.)

Does RevenueCat not support Xcode's local StoreKit testing of Mac Catalyst apps (or at least the receipt validation part of it)?  Or is there some other explanation of the "receipt is not valid" error above? Thanks for any info you have.


4 replies

Userlevel 3
Badge +7

Hey @Chad Mohler!

Thanks for reporting this- I was actually able to reproduce this on my end as well. I filed a bug report with our engineering team for further research here.

I’ll follow up when I have more information!

Badge +1

Thanks for the update, Cody; I appreciate the quick reply.  I look forward to hearing more info when it becomes available.

Badge +1

Hello,

I’m running into this exact problem on my Mac app. It’s not a Catalyst app, just a SwiftUI Mac App that is part of a universal app.

Any updates? I too have got the public certificate loaded, and everything is working well on the iOS version of the app. It’s just the receipt validation that’s failing.

Badge +1

Hi, Matt.

I originally was getting the “receipt not valid” error with the Purchases SDK v. 3.12.2.  Today I saw that a new version (3.12.3) is available, and I installed it.  Unfortunately, the error still occurs with that new SDK version as well.

Reply