Trouble Testing IAP with Sandbox

614 Views Asked by At

I cannot sign in with Sandbox tester ID (the fields are not even displayed in Settings-App Store).

I am running Xcode 14.2 and attempting to test on a developer-signed physical device (iOS 16.1.2). Following the steps in Apple documentation ("Setting up StoreKit Testing in Xcode"), I have been able to run tests using using local StoreKit configuration file. All works well. I next wanted to try to use Sandbox Testing. Following the same documentation,

  • I set up a Sandbox Tester in Apple Store Connect.

  • I saved a Public Certificate from the storekit configuration file in the project.

  • I removed the local StoreKit configuration file from the scheme’s run options (by setting to "none").

  • I added the following conditional compilation block to my store manager:

     #if DEBUG
         let certificate = "StoreKitTestCertificate"
     #else
         let certificate = "AppleIncRootCertificate"
     #endif   
    

It is my understanding that an option to sign in with the SandBox ID should appear in device's App Store Settings after the first time I attempt to make a purchase when running on the device physically connected to my Mac. This is not happening. Am I missing a step? One possible mistake I made was placing the (above) conditional compilation block in the wrong place. Can someone recommend the best place for this? The documentation says to paste it in with my receipt validation code. Another suspected oversight might be something else I need to do in Apple Store Connect. Not sure. Any help appreciated! Addendum - I get this message in the console:

Error enumerating unfinished transactions for first transaction listener: Error Domain=ASDErrorDomain Code=509 "No active account" UserInfo={storefront-country-code=USA, client-environment-type=Sandbox, AMSServerErrorCode=0, NSLocalizedDescription=No active account}

1

There are 1 best solutions below

0
Sukwon On

I had an issue while attempting to test my product using a sandbox account, and it took me a few hours to troubleshoot and find a solution. Here's what ultimately helped me get it working while building from Xcode:

  1. Verify that the bundle identifier and product identifier match correctly. Subscription product will not show up as a result if these ids do not match.
  2. Ensure that all necessary information in App Store Connect is filled out accurately, including content rights, age rating, agreements, banks, taxes, and other relevant details. Subscription product will not show up as a result if these are not properly configured. Make sure that Status for Paid Apps is "Active" under Agreements.
  3. From Settings, log into iCloud using a valid Apple account and make sure to set up a payment method if you haven't already. I was getting this error without this step. Error Domain=ASDErrorDomain Code=509 "No active account"
  4. Confirm that your iOS device is running not too old version of iOS. In my case, I had to use a different iOS device with a higher version (16.5.1).(I had to download latest Xcode...) Previous iOS device with iOS 15.7.7 seems to have a bug when adding payment method in my case.

By following these steps, I was able to successfully view the in-app purchase product and conduct tests using the sandbox environment.