IOS app purchase Summary

Source: Internet
Author: User

I will first attach several articles:

1. In app purchases: A full Walkthrough

This article is very detailed, and the code can be copied.

2. Store kit Guide (in APP purchase) Translation

If you do not know what IAP is, take a look at the translation of Apple documents.

3. Apple official documentation

When you need to pay attention to the details, you need to write a word into this document.

4. Verify transactionreceept upon purchase of iPhone, In, app, and purchase

This article teaches you how to verify the transaction receipt

 

 

The above articles basically cover the entire IAP process. Here I will add details based on my experience (not necessarily accurate:

1. Upload product information (for more information, see the iTunes connect developer guide ). You do not have to upload the app first. You can upload the app after testing all the programs. However, because each product is linked to a unique application, you must first create an application to obtain its app ID. That is to say, as long as there is an app ID, you can add its product and perform a test.
2. If your product has not been approved, after several hours, your product will enter the sandbox. At this time, we can use the test account to purchase and test it. If the sandbox mode is tested, Apple will not actually take the credit card deduction step.

3. You can add the test account through itnunes connect. You can simply add the account information. Note that this account can only be used for sandbox testing of our applications. It is not used for normal product purchase (for example, to buy a product in an application that has been shelved ), otherwise, Apple will disable this account.

4. When we confirm to purchase a product, we will get a skpaymenttransaction object, and the transactionreceipt in it is the verification information (which is a set of JSON strings). We will encrypt it with base64, then, the address is sent to the verification address in the format specified by Apple (For details, refer to the documentation. After the verification is successful, the information returned by App Store contains the specific information of the purchased product, which can be used for reconciliation.

5. After purchasing the product, a new object will be created in our local transaction queue, Which is saved on the local hard disk. The transaction object will not be deleted unless we call finishtransaction. If the transaction queue is not empty, IOS will notify us that the transaction queue status is updated, we need to process the transaction object based on its status.

Skpaymenttransactionstatepurchased: the transaction is successful, and the money has been deducted. Make sure that the product is sent to the user.

Skpaymenttransactionstatefailed transaction failed for many reasons (you can use skpaymenttransaction. Error. Code to view the specific cause of failure), the most common is skerrorpaymentcancelled (the user canceled the transaction), or did not enter a valid iTunes ID

Skpaymenttransactionstaterestored the non-consumable item has already been purchased. At this time, we will deal with it based on the transaction success.

6. If the transaction fails, we can directly remove the transaction from the transaction queue. If the verification succeeds, the system initiates the verification and waits for the verification result to be processed. There are no more than three results, such as successful verification, illegal verification, and incorrect verification.

Whether the transaction is successful or illegal, we need to say that the transaction object is removed from the transaction queue. The verification error may be that the verification server is faulty. We should not delete the transaction object. After the program is restarted, verify again until it succeeds or fails.

7. Some Articles have mentioned this point: "We should call addtransactionobserver when the program is started to add the observer; otherwise, the transaction object may be omitted"

I personally think this statement is incorrect. IOS calls paymentqueue to notify us that the transaction status update is after the observer is added. If no observer is added, IOS will not process the transaction queue. We need to ensure that our program can process all transactions (for example, successfully logging on to the server) before adding the observer. Otherwise, the IOS calls the callback function to update the transaction queue status, however, our program cannot deal with this transaction.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.