Orders purchased in iOS correspond to replenishment orders, and ios orders correspond

Source: Internet
Author: User

Orders purchased in iOS correspond to replenishment orders, and ios orders correspond

Key types of internal purchases:

1. SKPayment (SKMutablePayment can correspond one-to-one parameters to the payment generated by Apple)

2. TransactionObserver: This method is executed when the transaction status is updated. This method will pass in the transaction SKPaymentTransaction array, traverse the array, and perform corresponding operations on different states.

(SKPaymentTransactionStatePurchasing, SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestored, SKPaymentTransactionStateDeferred)

3. SKPaymentTransaction: Includes transactionreceept, payment, transactionIdentifier, and other key attributes. transactionReceipt is the key for backend signature verification.

 

Internal purchase process 1:

SKPayment * payment = [SKPayment paymentWithProductIdentifier: productID]; // input productID
[[SKPaymentQueue defaultQueue] addTransactionObserver: self]; // Add an observer and execute the Protocol to update the payment status

// Observer proxy method
-(Void) paymentQueue :( SKPaymentQueue *) queue updatedTransactions :( NSArray *) transactions
{
For (SKPaymentTransaction * transaction in transactions)
{
Switch (transaction. transactionState)
{
Case SKPaymentTransactionStatePurchased:
// Perform operations on the payment status
Break;
Case SKPaymentTransactionStateFailed:
// Failed payment operation
Break;
Case SKPaymentTransactionStateRestored:
// Operations on non-consumable products
Break;
Default:
Break;
}
}
}
If the user has already paid but the verification signature is not passed, a free recovery dialog box will be generated when the payment continues. In this case, even if the payment is added, it is in the purchasing status, you must pass [[SKPaymentQueue defaultQueue] finishTransaction: transaction] To the paymentque to execute the order in the purchasing State one by one (this is for the same productIdentifier product ), different productIdentifier products can still be paid normally

 

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.