Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
- {
- for (SKPaymentTransaction *transaction in transactions)
- {
- switch (transaction.transactionState)
- {
- case SKPaymentTransactionStatePurchasing:
- {
- NSLog(@"Purchasing Product From Store!");
- }
- break;
- case SKPaymentTransactionStatePurchased:
- {
- NSLog(@"Purchased Product From Store! %@", transaction.description);
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
- if(buyProductBlock != nil)
- {
- buyProductBlock(TRUE, nil);
- buyProductBlock = nil;
- }
- }
- break;
- case SKPaymentTransactionStateRestored:
- {
- //SKPaymentTransactionStateRestored is only issued after you call restoreCompletedTransactions.
- NSLog(@"Restored");
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
- }
- break;
- case SKPaymentTransactionStateFailed:
- {
- NSLog(@"Purchase failed %@ %@", transaction.payment.productIdentifier, transaction.payment.debugDescription);
- [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
- if(buyProductBlock != nil)
- {
- if (transaction.error.code == SKErrorPaymentCancelled)
- buyProductBlock(FALSE, nil);
- else
- buyProductBlock(FALSE, transaction.error.localizedDescription);
- buyProductBlock = nil;
- }
- }
- break;
- default:
- break;
- }
- }
- }
- Test an Interrupted Transaction
- Set a breakpoint in your transaction queue observer’s paymentQueue:updatedTransactions: method
- so you can control whether it delivers the product. Then make a purchase as usual in the test
- environment, and use the breakpoint to temporarily ignore the transaction—for example, by
- returning from the method immediately using the thread return command in LLDB. Terminate and
- relaunch your app. Store Kit calls the paymentQueue:updatedTransactions: method again shortly
- after launch; this time, let your app respond normally. Verify that your app correctly delivers
- the product and completes the transaction.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement