4 Replies
      Latest reply on May 16, 2018 3:39 PM by iQser_Developer
      iQser_Developer Level 1 Level 1 (0 points)

        It's seems to be very tricky to test in-app purchases of a macOS app. This is what I've done:

         

        1. Defining two products with prodict identifiers in iTunesConnnct. Theyx are ready for submission.
        2. Creating a new version of the app linked to a new build and the said products.
        3. Closing the additional contract with Apple in iTunesConnect.
        4. Creating a sandbox user in iTunesConnect.
        5. Implementing the in-app store.
        6. Logging out from the app store on my developer machine.
        7. Building the app and starting the app in finder. The debug log should be a confirmation of the developer mode.
        8. Testing retrieving product information in the app successtully.

         

        In several tests, sometimes the popup für a login into the app store appears. Sometimes the message "sandbox environement" was shown, mostly not. Last time the additional message was shown, that the user was't allowed to buy in the US store and login would be redirected to the national store. After this, nothing returned from the payment queue. In further tests, the popup doesn't appear any more and the payment queue doesn't return any event, even not an error.

         

        This is, what I've checked:

         

        1. I checked, that there is nothing in a non persistant cache by restarting my developer machine.
        2. I checked, that the sandbox user still exists.
        3. I chacked, that the product identifiers are still valid.
        4. I checked, that the sandbox container and preferences are deleted by an Autormator script.
        5. I chacked, that my developer machine is connected to the USA by VPN, to avoid the redirect, that seems to make problems.
        6. I chacked, that the projects target was cleaned and the app rebuild.
        7. I checked, that the bundle identifier and version is the same as the version n the app store, that is linked to the products.

         

        I have no more ides. Can someone help? Is there a way to reset the application? Maybe I missed to delte any persisted cache or receipt.

        • Re: How to force the app to show the sandbox environment login?
          PBK Level 6 Level 6 (2,520 points)

          One more check - if there is an approved version of the app, have you deleted that approved version from your device before installing a build from XCode?

            • Re: How to force the app to show the sandbox environment login?
              iQser_Developer Level 1 Level 1 (0 points)

              Thanks for your recommendation.

               

              • I have successfully checked, whether the build is the only one my machine. I have only two release builds, embedded in an xcarchive. This shouldn't affect the behaviour of the tested app.
              • I also checked, whether the app behaves in the same way, if I move the app to the app folder.

               

              I assume, that there somewhere a cache, that I have to delete.

                • Re: How to force the app to show the sandbox environment login?
                  PBK Level 6 Level 6 (2,520 points)

                  >I have only two release builds, embedded in an xcarchive. This shouldn't affect the behaviour of the tested app.

                   

                  I'm never sure about "shouldn't" but in iOS it does affect the environment selected.  Writing over a release build (i.e. not deleting an old build - which itself may have written over a release build) will result in a 'signature' on the app that points IAP to the production environment.  In iOS you must delete all old builds and log out of the app store before reinstall from XCode and waiting to log into the app store until told to do so by StoreKit.  I suspect you must similarly delete production builds from a Mac - perhaps also from archives, perhaps also from Trash.

                    • Re: How to force the app to show the sandbox environment login?
                      iQser_Developer Level 1 Level 1 (0 points)

                      Thanks for your response. The xcarchive files are created by the organizer of Xcode for the archive. I have zipped the archive and dropped in into the trash and checked the in-app purchase again.

                       

                      The behaviour of the system is quite similar. I could log in with the sandbox user and the following message is shown:

                       

                      Account Not In This Store

                      Your account is not valid to use in the US store. You must switch to the German store before purchasing.

                      [Environment: Sandbox]

                       

                      In this message the hint of the sandbox environment is shown, that is now shown in the login popup. If I click on "Change Store" the  Store app openes with the message, that no access to the store could be established.

                      ____________

                       

                      I could manage so solve this issue with the following steps:

                       

                      1. Creating a sandbox user for the store area USA
                      2. Deleting all app files in the Library folder with an Automator script
                      3. Rebooting the developer machine to force a login promt for in-app purchases
                      4. Cleaning and rebuilding the app for debugging.
                      5. Startting the app in Finder
                      6. Ignoring, that sanbox environment is not shown for the login.

                       

                      This experience is maybe helpfull for other developers.