How to use the sandbox user on MacOS app to test IAP? - macos

As usual, all the existing answers on Stackoverflow relate to iOS and nothing is out there for MacOS.
I have signed out of Mac AppStore.
When I try to attempt a IAP purchase on my app I get this error message shown:
Account Not In This Store Your account is not valid for use in the
U.S. store.
You must switch to the U.K. store before purchasing.
[Environment: Sandbox]
I have created fresh Sandbox users, but the app is not asking me to enter them. And based on the documentation of Apple I shouldn't enter them into the AppStore login or I get them wasted.
I have deleted the ~/Library/Containers/app-bundle-id, rebooted the dev machine and cleared once again the build folder. But I can't get it working.
How do I get a prompt for entering the sandbox user?
Any advice would be appreciated.

Related

How to test an IAP using a sandbox account on Apple Watch

I'm trying to test the purchase and restore code I've written for an IAP for an Apple Watch app. In the iOS world I would make sure my device was logged in to a sandbox account under the sandbox section of Settings and then I could test an IOS IAP. I'm trying to do the same for a watchOS app and getting an error.
Here's a screenshot of the error:
The phone my watch is paired with is logged into a sandbox account (in the sandbox section of Settings).
Is the error implying that I need to be logged in on my phone using the sandbox account as the regular iCloud account? Something else? Has anyone successfully tested an IAP purchase on Apple Watch, and if so were there any special steps you needed to take to use a sandbox account?
I'd appreciate any tips and tricks. Thanks!
Russ

No accounts with App Store Connect access have been found for the team

I got this error when submitting an iOS app to the App Store. Product → Archive, clicking "Distribute App" in the Organizer in Xcode 10.
No accounts with App Store Connect access have been found for the team "[My Team Name]". App Store Connect access is required for App Store distribution.
I've logged into App Store Connect as the correct user account and verified that I have administrative access.
App Store Connect used to be called "iTunes Connect," and so this question was answered by another Stack Overflow answer.
When this happens to me, closing Xcode completely and re-opening it solves the problem.
Restarting Xcode fixed the problem for me, too.
Hopefully now that I've posted this question, someone can Google for "App Store Connect" and find the right answer.
Awesome. Quick restart and fixed.
If you don't have an account in App Store Connect the provided solution (i.e. closing and re-opening Xcode) will not work.
Kindly see the following section from official Apple documentation (https://developer.apple.com/support/app-store-connect/).
The person who enrolled in the Apple Developer Program is the main account holder and has the Legal role in App Store Connect, which includes binding authority for contracts, full access to App Store Connect, and more.
The Legal user can provide access to additional team members by setting up accounts for them in App Store Connect. Please note that adding members to a development team on the Apple Developer website will not automatically create accounts for those members in App Store Connect.
Add users by entering their names and email addresses in Users and Access. You can limit each user’s access level for App Store Connect and specific apps. If a user needs full access to App Store Connect, you can assign them the Admin role.
In my case, we had a lot of expired iOS distribution certificates. Yes, not Mac ones, iOS ones. Deleting those solved the problem ¯\_(ツ)_/¯
Quitting the XCode completely and restarting it still gets the issue fixed. But check if your certificates are still valid if this problem persists.

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:
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:
Having selected 'Buy', a short wait after that, this next popup appears:
After selecting 'Cancel' (as recommended here), after a short wait, the next popup appears:
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'.
However, now the purchase transaction never completes:
What might I be doing wrong? Do I need to log out of anything (e.g. iCloud) in Settings > Internet Accounts too?
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).

Can I use In-App-Purchases when distributing outside of Apple's App Store?

I'm new to mac os app development and the documentation doesn't ever say that this is not supported (as far as I could tell).
Can I use IAPs if I don't submit to the App Store?
Is there anything different that I should do to setup IAPs when distributing outside of the App Store?
It looks like this is not possible, as documented here:
https://developer.apple.com/macos/distribution/
Only iCloud and Push Notifications are available.
I think its possible by following instructions below.
Go to itunesConnect , Users and Roles, Create a sandbox user . I am thinking you have already made the in app purchase items in your app in itunes connect. Now in your device log out the Appstore ID from settings. Do the in app purchase using the Test user credentials you created, and it will make the in app using a sandbox environment.
For more info about In App follow this link :
https://www.raywenderlich.com/122144/in-app-purchase-tutorial

In-App purchase not working after creating new iTunes connect test user

My problem is testing In-App purchase in my Mac OS X application; it seems to me that the problem is related to my test account. I could test IAP on my own Mac quite well with a test user account before. But a few weeks ago while I was trying to make a purchase in sandbox a dialog box showed up saying that I should review my account information on App Store, I made a mistake by logging into the real App Store and my test account can't be used for testing now.
Here is the problem: I deleted the old test account and created a new one. Now, when I want to test the IAP the dialog box that asks if I want to purchase a product in sandbox environment and the next one that prompts for user/pass don't show up.
Using NSLog I figured out that when I enter In-App store, products are being loaded and when I click on a product to buy it, app starts buying product with product ID. If I am right, at this stage the prompt should show up saying: do you want to buy product myproduct [sandbox environment]? But this dialog box never shows up! I never experienced the same problem with the old test account.
Any suggessions?
The problem is resolved. I can now test IAP using my new test user account AFTER I updated iTunes!

Resources