Iap-in APP Purchase Process

Source: Internet
Author: User

Recently used to IAP built-in purchase, read the official documents, find some information on the Internet, here for the collation, so as to find and modify, the main flow direction to determine, documents and related reproduced content screenshots not one point, Google a bunch.

1. Find the official documents, two table of contents screenshots, the main process of general understanding:

Official documents:

https://developer.apple.com/library/mac/#documentation/networkinginternet/conceptual/storekitguide/ Introduction/introduction.html


2.In App Purchase programming Guide

Purchase Program Wizard

Adding a Store to Your application

Add a store to your application

This is chapter provides guided steps for adding a store to your application.

This section describes the detailed steps for adding a store to your application.

The step-by-step Process

When your set up is project, make sure to link tostorekit.framework. Can then add a store by following these steps:

When installing the project, be sure to link to storekit.framework, and then follow the steps below to add a store to your application.

(1) Decide what products for your wish to deliver with your application.

First determine which product you want to deliver to your application
There are limitations on the types of features can offer. Store Kit does not allow your application to patch itself or download code. Products must either work with existing code in your application or must to implemented using data files delivered from a Remote server. If you are wish to add a feature so requires changes to your source code, you are need to ship a updated version of your ation.

There are some limitations on the type of functionality you can provide. Store kit does not allow your application to patch itself or download additional source code. The product must be run with a data file that is downloaded from your application or through a remote server. If you want to add some features to the product, you need to change your source code, you need to send an updated version of your application.

(2) Register product information for each product with ITunes Connect.

Register product information for each product associated with the itunes connect.
You are revisit this step every time for your want to add a new product to your application ' store. Every product requires a unique product identifier string. The app Store uses this string to look up product information and to process payments. Product identifiers are specific to your itunes connect account and are registered with itunes Connect in a way similar to How do you registered your application.

Repeat this step every time you add a new product to your application. Each product requires a unique product identifier string. The App Store uses this string to view product information and process payments. The product identifier is specific to your itunes connect account, and it is registered with itunes connect similar to registering your application.
The process to create and register product information are described in the ITunes Connect Developer Guide.

The process of the new product needs to generate and register product information, which is described in the itunes Connect Developer Guide.

(3) Determine whether payments can be processed.

Determine if payment can be processed.
A user can disable the ability to make purchases inside applications. Your application should check to the whether payments can be purchased before new queuing payment. Your application might do this before displaying a store to the user (as shown here) or it may defer this check until the User actually attempts to purchase a item. The latter allows the user to the "to" and "they could purchase when payments are enabled.

Users can disable the purchase of this feature within the program. Your application should confirm that the payment can be purchased before the new payment request is queued. Your application can also verify that the store is available for purchase or if the user is actually trying to purchase an item before it can be displayed to the user, and the latter allows the user to see what items they can buy when the payment is enabled.

if ([[[Skpaymentqueue Defaultqueue] canmakepayments])

{

..//Display a store to the user.

Show a store to the user

}

Else

{

...//Warn the user that purchases are disabled.

Warn users not to trade

}


(4) Retrieve information about products.

Retrieving information about a product
Your application creates a Skproductsrequest object and initializes it with a set of product identifiers for the wish to sell, attaches adelegate to the request, and then starts it. The response holds the localized product information for all valid product identifiers.

Your application creates a Skproductsrequest object and initializes the Skproductsrequest object with the product identifier of the series of items you want to sell. Attach a delegate to this request, and then start. The response information contains localized product information for all valid product identifiers.

   skproductsrequest *request= [[Skproductsrequest alloc] Initwithproductidentifiers: [Nsset Setwithobject:kmyfeatureidentifier]];

* td> tr>

-(void) requestproductdata

{

   request.delegate = self;

   [request start];

}

-(void) Productsrequest: (skproductsrequest *) Request Didre Ceiveresponse: (skproductsresponse *) response

{

& nbsp   Nsarray *myproduct = response.products;

   //populate UI

   //  fill interface

    [request autorelease];

}

(5) Add a user interface that displays the user.

Add a user interface to display the product to the user

Store Kit does not provide user interface classes. The look and feel an offer to your customers are up to you!

The store kit does not provide user interface classes. The interface style of the product you provide is customized by you.

(6) Register a transaction observer with the payment queue.

Use a pay queue to register a trading observer.
Your application should instantiate a transaction observer and add it as an observer of the payment queue.

Your application should instantiate a transaction observer and add it as a paid-queue observer.

Mystoreobserver *observer = [[Mystoreobserver alloc] init];

[[Skpaymentqueue Defaultqueue] addtransactionobserver:observer];


Your application should add the Observer when Your application. The App Store remembers queued transactions even if your application exited before all completing. Adding an observer during initialization ensures-all previously queued transactions are-seen by your application.

Your application should add a transaction observer when it starts. Even if your application exits before it completes all transactions, the App store can remember the transactions placed in the queue. Adding a transaction observer to the initialization process ensures that your application can see all the transactions placed in the queue that have not been performed before.

(7) Implement ThepaymentQueue:updatedTransactions:method on Mystoreobserver.

Implement Paymentqueue:updatedtransactions on Mystoreobserver:
The Observer ' s PaymentQueue:updatedTransactions:method is called whenever new transactions are or created.

Observer's Paymentqueue:updatedtransactions: method is invoked when a new transaction is created or updated.

-(void) Paymentqueue: (Skpaymentqueue *) queue updatedtransactions: (Nsarray *) transactions

{

For (Skpaymenttransaction *transaction in Transactions)

{

Switch (transaction.transactionstate)

{

Case skpaymenttransactionstatepurchased:

[Self completetransaction:transaction];

Break

Case skpaymenttransactionstatefailed:

[Self failedtransaction:transaction];

Break

Case skpaymenttransactionstaterestored:

[Self restoretransaction:transaction];

Default

Break

}

}

}

(8) Your Observer provides the product when the user successfully purchases a item.

When a user buys a project successfully, your observer will provide you with the product you just purchased.

-(void) Completetransaction: (skpaymenttransaction *) transaction

{

Your application should implement these two methods.

Your application should implement both of these methods

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.