Debugging applications using a test account. The App Store is a trading environment, any user can purchase applications in this environment, but for payment, if you want to test the application during the development process, we cannot be in the real Apple store. Apple provides developers with a test sandbox for debugging purchase behavior, it completely copies the application store’s trading application environment, but in the sandbox environment we cannot use a regular Apple account, but you need to use a test account. (As long as there is an application identifier, you can add products and test it.) On the iTunesConnect home page, you can click "User Management" to go to the user management page, then select "Test User" to create a test account. According to the latest thanks from Apple Developer, to create a test account, you must use a real email address, and the password must be compatible, the test account must be used in the mail after activation. The one created here can be used to purchase a premium account during the application development process, it must be remembered that the account cannot be used to test the real application store and shopping behavior in the production environment, or your iTunes account will most likely be stopped. (You can add a test account using the itnunes connection, just add the account information in the line here to note that this account can only be used to test the test environment of our application, and not for ordinary goods purchased (for example, for purchase was applied inside the goods shelf), otherwise Apple will disconnect the account.) When we confirm the purchase of the product, we will receive the SKPaymentTransaction object inside the transactionReceipt to verify the information (i.e. json string set), we use w frovanie the base64, and then follow the format that Apple is required (for example, see. document) is sent to the address checking on it. After successful authentication, the information returned to the application store for the purchase of goods contains certain information that can be used, can be agreed.
After purchasing goods, a new object will appear in our local transaction queue, transaction queues will be saved on the local hard drive unless we call finishTransaction, otherwise the transaction object will not be deleted. And when the program is open (here we must note that it will be discussed in detail below), if the transaction queue is not empty, then we will inform about updates to the status of the ios transaction queue, we will be processed in accordance with the state of the transaction object. Transaction SKPaymentTransactionStatePurchased is successful, then the money was deducted, we want to make sure that the product will be sent to the user Transaction failed SKPaymentTransactionStateFailed for many reasons (you can view the specific reason for the failure SKPaymentTransaction.error.code), the most common is SKErrorPaymentCancelled (the user does not cancel the transaction) or valid itunes identifier SKPaymentTransactionStateRestored durable goods that have already been purchased, then we must deal in accordance with successful success.
If the transaction failed, we can remove the transaction from the transaction queue. If successful, they must initiate authentication, the verification result is expected to be processed. As a result, no more than three, validation will be successful, check for illegal verification errors. We should talk about successful completion and illegal operation with a transactional object, due to a verification error, the authentication server is likely to fail, we should not delete the transaction object in order to return to the program again, to check until it succeeds or completes