How to test touch dialog and perform real in-app purchase? - ios

I have submitted my iOS app. The status is now pending developers release . In-app auto renewable subscriptions are approved. When I test, the app still prompt sandbox dialog for me to enter sandbox account password to verify my purchase. I cannot test real purchase and cancel under this situation . Would you please tell me what is the next step?

To test in-app in Production environment, not Sandbox, you need to have the appropriate build.
If you are running from Xcode, you are automatically acting in Sandbox.
To have a Production environment, you need to make an AdHoc build (distributed via services like diawi.com) or AppStore build (distributed via Testflight).

Related

How to test IAP with Sandbox User in the Sandbox environment?

I can test in the Xcode environment.
I can test with TestFlight which uses a REAL Apple Id to make purchases in the Sandbox Environment.
But how do I test with a Sandbox User in the Sandbox Environment? Because I need to be able to clear out my Sandbox user purchase history so that I can test first purchases again.
I've been reading through the documents and I feel like each particular doc jumps over the piece of info that I need. It explains how to create a Sandbox Test User and I've done that. I did plenty of IAP work many years ago, but things have changed enough that it's not working as I expect. When I read the docs, I feel like I can't find the missing piece.
When I test in a simulator with Xcode, it does my IAP transactions in the Xcode environment. That makes sense.
https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox
This page says:
To run your app using your Sandbox Apple ID, build and run your app
from Xcode.
But when I test on a physical device installing directly from Xcode, it also does my IAP transactions in the Xcode environment. I thought this would put me in the Sandbox environment, but it didn't. The Xcode transactions manager shows the transactions. The initial purchase view controller didn't reference the Sandbox at all and the "You're All Set" alert shows Environment: Xcode instead of Environment: Sandbox.
When I put a test build into TestFlight and test using that version, my IAP transactions are happening in production using my real Apple Id (but I'm not actually charged for any transactions).
I assumed that testing in TestFlight would give me the Sandbox environment, but it happens in the Production environment. (The purchase view controller doesn't show Sandbox and the "You're All Set" alert doesn't show Sandbox.)
So, how do I test in the Sandbox? Every way I try to test either puts me in the Xcode environment or the Production Environment.
What am I missing?
I've logged out of my real Apple id on my phone and then logged in with the Sandbox User credentials I created in AppStore Connect. But when I tried to test the app, by installing from Xcode it still says I'm in the Xcode test environment. When I create transactions, those transactions show up in the Xcode Transaction Manager.
How do I test in the Sandbox environment?
The difference between IAP being in "Xcode" mode versus being in "Sandbox" mode is whether you setup a StoreKit Configuration or not on your target's scheme.
In Xcode select the Product menu and go to Scheme, then "Edit Scheme...". Select Run on the left side and then go to the Options tab.
For the "StoreKit Configuration" setting you will get Xcode mode if you select a specific configuration. You will get Sandbox mode if you set this option to None even when running the app from Xcode.
None of this applies when running from TestFlight. In TestFlight you are in full production mode.
To verify this I logged into a sandbox account in the Settings app under App Store -> SANDBOX ACCOUNT. I then ran my app via Xcode and went through some IAP in my app. When the StoreKit Configuration was set to None the IAP screens showed "Sandbox". When the StoreKit Configuration was set to a specific storekit file the IAP screens showed "Xcode".

how to switch from Sandbox to live in In App purchase

I am using In App purchase and it is working fine when i am testing it from the sandbox account. But when i tried to purchase the online subscription by making amount zero by live account. it is giving an error of
[you are not authorised to make purchase in this inApp in SandBox at this time Environment Sandbox]
i guess it was setup in sand box mode. So As i tested in sandbox and it is working fine ho can i make it live to that any one can purchase it.
I got my answer for the apple document that app installed from Xcode is always in Sandbox environment and app download from live itunes is Live. thanks a lot to all and specially for one who commented heae on post and guided me.
=>
StoreKit connects to the sandbox environment when you launch your application from Xcode, from your test device (iOS), or from the Finder (OS X). It connects to a production environment for applications that were downloaded from the App Store. You must not use your test user account to sign into the production environment. This will result in your test user account becoming invalid. Invalid test accounts cannot be used to test In-App Purchase again.
<=
Apple Document
You can not test live app with sandbox test ID as sandbox email ID has no real credit. If In App Purchase is working for sandbox ID, it will work for real IDs too.

How to test in App purchase for an live app

I saw this question but its not what i need :- Testing in-app purchase after going live\
I want to provide limited set of testers free access to In App Purchase for testing purposes.The first version of app is live i wish to upload new version. What are my options?
I can make every thing free through code on development build and install it on testers device but i don't want to go this way.
Will the IAP test accounts work if one version of app is live already?
For Testing In-App purchase you have to login into your developer account and add Test user account for In-App purchase . Search for Sandbox In-App purchase testing and app you will get relevant steps.

iOS In App Purchase: test a real purchase without submitting to Apple

I implemented in app purchase in my iOS app and I want to do a real test (not a sandbox) before submitting this new version to Apple
Of course, the current version of the app (in the App Store) was validated with a product
So, I archived the app using an Ad Hoc distribution profile and I generated an IPA file for Ad Hoc deployment. But when I installed the app via Testflight on my device, I discovered that the app was in sandbox environment!
Is there a way to do a "real" purchase before submitting the app to the App Store ?
You can actually test the in-app purchasing in the sandbox environment, basically you'll need to set up an test user account in your iTunesConnect.
Check the apple documentation here:
http://developer.apple.com/library/ios/#technotes/tn2259/_index.html
You'll be able to find all the information related to In-App Purchasing, including sandbox testing.
Short answer: you can't test a real purchase (aka, spend real money). It isn't possible.
Slightly longer answer: You'll automatically hit the sandbox environment unless it's an apple-signed release build. Even ad-hoc signed builds hit the sandbox.
To test a new IAP: create your IAP (it will be in "needs approval mode" until submitted with the final build and test against the sandbox - that's fine). If your purchase works against the sandbox, it should work against prod with real money as well. It would be great to do a trial run with real money, but that's just not possible until the IAP is approved and you get the production signed version of the app from the app store.
Just create a test account on iTunes Connect. Then log out from the device and run your app from Xcode.
To get access to the purchase you need apple signature, because you are connecting with the apple servers.
I assume that your app, is doesnt have that signature, so your request goes to the sandbox.

Debug in-app purchase outside of sandbox?

I have an app that uses non-consumable in-app purchases to provide content to the user.
These purchases work fantastically when I run from Xcode (via sandbox) or via ad-hoc builds (for some reason, also via sandbox). It's been approved by Apple and put on the AppStore. But when I download the production version from the store and click the "buy" button it fails.
Seeing as the problem only occurs in production, I'm a bit stymied as to how to debug it. I suspect it has something to do with purchasing through the sandbox vs. production servers, but even ad-hoc is done through the sandbox.
Is there anyway to debug this problem short of adding a bunch of alert dialogs and submitting to Apple again?
You are totally right;
You need all your Contracts (in iTunes Connect) to be active, otherwise you wont be able to make in-app purchases.

Resources