xcodemacosin-app-purchaseapp-storemac-app-store

macOS In-App Purchase in sandbox environment not authorised


I'm trying to get In-App Purchases (IAPs) working in a macOS app using the same Swift code, sandbox testers, and iTunes Connect account that I used for my iOS app. However, I can't get it to work. I'm using macOS High Sierra 10.13.6.

Open app

Apple's IAP testing recommendations are found here:

On a development macOS device, sign out of the Mac App Store. Then build your app in Xcode and launch it from the Finder.

If the text “[Environment: Sandbox]” doesn’t appear, you’re using the production environment. Make sure you’re running a development-signed build of your app. Production-signed builds use the production environment.

I have followed these steps by signing out of the Mac App Store, and building my app – signed for development – then launching it from the Finder. This means I don't get debug logs, unfortunately.

Navigate to table of products in-app

Here's my table of products:

Products table

I can buy a product by pressing the "Free" button or the "£4.99" button.

Attempt to buy product by pressing "Free"

After a short wait, brings up this popup saying 'Sign-in required'. I sign in using one of my sandbox testers (note: I have tried five different test accounts now, all of which worked on an iOS app under the same iTunes Connect account), registered with email addresses that aren't Apple IDs:

Sign-in required

Having selected 'Buy', a short wait after that, this next popup appears:

Account not in this store

After selecting 'Cancel' (as recommended here), after a short wait, the next popup appears:

You are not authorized

You are not authorized to make purchases of this InApp in Sandbox at this time.
[Environment: Sandbox]

So I'm not sure whether it logged me in or not, and I assume that my purchase has failed (my table UI doesn't update to say 'purchased'). Note that I have also tried pressing 'Change Store' here, and it still fails ultimately.

Attempt to buy product by pressing "Free" again

This time, I'm not prompted to log in; I'm instead asked immediately whether I'd like to purchase the product. I click 'Confirm'.

Do you want to get

However, now the purchase transaction never completes:

Processing

What might I be doing wrong? Do I need to log out of anything (e.g. iCloud) in Settings > Internet Accounts too?


Solution

  • Seems lame, but I eventually solved this by making new Sandbox tester accounts (tip: this time, I configured them as being US-based to avoid the complication of switching stores during the payment flow).

    I think the problem was that I hadn't verified the Sandbox tester accounts I'd been using. This is either because Apple's email asking me to verify/activate the Sandbox tester accounts got sorted into my junk mail and missed completely, or because their backend had been having problems when I did click the link in their emails (I experienced both of these behaviours).