The issue:
When testing a Mac Catalyst app built and run from Xcode, I now receive the following Xcode-console-logged errors, in the order listed here, upon attempting a non-consumable in-app purchase using a sandbox user account:
- No UI context available for payment sheet request.
- Received error that does not have a corresponding StoreKit Error: Error Domain=SKInternalErrorDomain Code=4 "An unknown error occurred. Please try again."
- Purchase did not return a transaction: Error Domain=SKInternalErrorDomain Code=4 "An unknown error occurred. Please try again."
- There was a problem with the App Store. This could also indicate the purchase dialog was cancelled.
Potentially relevant additional info:
- The errors have occurred consistently over a 24-hour period, suggesting that it is not just a temporary problem with Apple’s sandbox server.
- The errors only occur during sandbox testing of the Mac Catalyst version of the app; they do not occur during sandbox testing of the iOS and iPadOS versions of the app.
- The errors only recently started occurring with the Mac Catalyst version of the app; previously, purchases made on the Mac using a sandbox user account were successful.
- The only change in the purchasing code I’ve made recently was to update the RevenueCat SDK yesterday from version 4 to version 5 (specifically, version 5.28.1), but the errors above occurred *both* before *and* after the update. In fact, it was the occurrence of the errors before the update that made me think I should update the RevenueCat SDK version being used.
- The version of macOS being used for the sandbox testing is macOS 15.5 Sequoia. The version of Xcode being used to build the app is Xcode 16.4.
- I have tried the following sequence of troubleshooting steps: clearing my sandbox user accounts’ purchase history via App Store Connect, logging out of the current sandbox user account via the App Store app on the Mac, deleting the app’s preference and cache files, rebooting the Mac, signing into another sandbox user account via the App Store app, doing a clean build of the app via Xcode, and then retrying the in-app purchase. The errors above still result.
- I have also tried archiving the app in Xcode, and then exporting it with the direct distribution option in Xcode that outputs a notarized version of the app. Running that version of the app has the same result as the version run directly from Xcode: failure to complete the purchase.
- Given error message (1) above, I wondered whether perhaps the error is a version of the UI-involving iOS 18.2 error documented here: https://www.revenuecat.com/docs/known-store-issues/storekit/ios-18-2-purchase-sheet-may-fail-to-appear. I confirmed, though, that the purchasing viewController is being presented by the rootViewController of the scene’s key window, so it doesn’t appear to be a version of the iOS 18.2 error. I still wonder, though, what the “No UI context available for payment sheet request” error means.
- Error messages (2) and (3) above contain other info, including the following additional initial part of an AMSServerPayload dictionary:
“customerMessage = "Sign in with Apple\U00a0Account";
dialog = {
cancelButtonString = Cancel;
defaultButton = Buy;
explanation = "Enter the password for %%appleId%% to authorize this transaction.\n\n[Environment: Sandbox]."
That part of the AMSServerPayload dictionary still appears in the Xcode console log even after I am prompted to log in to a sandbox account (and do successfully log in) while attempting the app’s in-app purchase (having previously logged out of the sandbox account in order to force the log-in prompt).
Perhaps the in-app purchase failures occur only in sandbox testing (and in its direct distribution notarized app counterpart described above), and not in the release build that will ultimately be made available via the Mac App Store. Still, though, I’m uncomfortable submitting this version of the app for review without first knowing whether the in-app purchase mechanism will work in production, especially since I have no way of testing the in-app purchase mechanism once the app is released on the Mac App Store.
Does anyone have any ideas what the problem might be that prevents the sandbox in-app purchase attempt from going through? Alternatively, does anyone have any ideas about how otherwise to test the in-app purchase mechanism on the Mac? Thanks for any suggestions you have.