Apple App Store in app payment (In-app Purchase)
IAP Introduction
the full name of the IAP is In-app Purchase, in-app billing. This business model allows users to download the trial for free, choose to consume the items that are available in the app, such as buying game props, purchasing game levels, etc. In the case of a fully charged application, an in-app pay-as-you-go scenario will not deprive a good application of a consumer from a lack of user awareness, and there is no need for developers to release a free, streamlined version separately for the user to try. Detailed steps for in-app payments are detailed below:
1. Tap the app and click Manager In-app purchases
2. Click to add a new app
3. Select the appropriate type
the IAP has two key words, product and trade (Transaction). A product can be a virtual prop, a hidden level or map, but it must be intuitive, allowing users to directly benefit from the purchase. The product of IAP is divided into four kinds from the nature of consumption:consumable items, such as game props, bullets, pharmaceuticals, etc. Since this type of product can be consumed, repeat purchases are supported. The Apple Store does not keep a record of purchases of such items, and if they are to be saved, they need to be synced to their servers. non-consumable items such as game levels, hidden maps, and more. This type of product can only be purchased once, and every user in the Apple App Store has a record of purchases of non-consumable items that can be restored on different devices, a recovery process called restore. automatic reset subscription, such as E-magazine, reading, etc. When a consumer buys such a product, it selects an expiry date from the list, and the seller chooses to add an expiration date from a fixed set of options when defining the item, such as 7 days, one months, and two months. After the expiry date, the purchase status of the item is automatically reset to not purchased, and you will need to subscribe again if you want to continue to get the content. This type of product, like non-expendable items, stores the purchase record in the Apple Store. Non-auto-reset subscriptions, such as when users subscribe to e-magazines and reading journals, need to select a period from a custom term list, rather than the fixed options offered by Apple, such as 9 days, 1.5 months, or any time. In this case, the Apple Store cannot control the expiration of the subscription according to the deadline, so everything needs to be written by the developer to implement the corresponding logic. A transaction is a user's purchase of a product, and when a user clicks to buy a product, a new payment is added to the pay queue, which is a system thread, even if the application terminates and continues execution.
4. Add the appropriate application information
Reference name App namethe ID of the Product ID appadd a language and pay the name
Add the appropriate price Add the appropriate pictureClick Save
5. Test the IAP preparation process
If you are a registered Apple developer, accept the latest Apple developer agreement and sign up for an iOS paid app contract, you can continue with the IAP test. using a device that is not jailbrokenThe Apple App Store is a trading environment where any user can purchase an app, but if you want to test in-app payments that are under development, we can't do it in the real Apple store. Apple provides developers with a test sandbox for debugging purchases, which completely replicates the marketplace's trading environment, but in a sandbox environment we don't use the usual Apple account, but we need a test account. on Itunesconnect's homepage You can click Manage users to go to the User Management page and then select Test user to create a test account. Based on the latest thanks from Apple developers, creating a test account must use a real email address, and the password must be compliant, and the test account needs to be activated in the mail before it can be used. The account created here can be used to purchase in-app payments during development, but it must be remembered that the test account cannot be used to log into the real App Store and make purchases in the product environment, or your itunes account may be deactivated.
6. Implementing iOS Development
Test code: http://easymorse-iphone.googlecode.com/svn/trunk/PurchaseTest/add observer to app delegate[[Ecpurchase shared] addtransactionobserver];. Set Ecpurchase product delegate (Products list agent), transaction delegate (purchase result agent), authentication method[[Ecpurchase shared] setproductdelegate:self];[[Ecpurchase shared] settransactiondelegate:self];[[Ecpurchase shared] setverifyrecepitmode:ecverifyrecepitmodeiphone];. Request a Product list[[Ecpurchase shared] requestproductdata:identifiers];implementing the Proxy function drawing UI-(void) Didreceivedproducts: (Nsarray *) products;. Purchase goods[[Ecpurchase shared] addpayment:proidentifier];. Confirm the resultsIf you do not need the receipt authentication to implement the agent function-(void) Didfailedtransaction: (NSString *) proidentifier;-(void) Didrestoretransaction: (NSString *) proidentifier;-(void) Didcompletetransaction: (NSString *) proidentifier;otherwise implement the proxy function-(void) Didcompletetransactionandverifysucceed: (NSString *) proidentifier;-(void) didcompletetransactionandverifyfailed: (NSString *) proidentifier witherror: (NSString *) error;to run an internal payment demo, click Test:logic for internal payments:The IOS APP sends a request to Developer Server to get a list of products (typically product IDs). getting a list of products requires the iOS App to get active, so you can add products without upgrading iOS. Developer Server Returns a list of Product IDs that are included with the IOS App. The IOS app sends a request to the app Store and expects to get information about the product.
Apple App Store developer account from application, verification, to release app (4)