Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
  2. {
  3. for (SKPaymentTransaction *transaction in transactions)
  4. {
  5. switch (transaction.transactionState)
  6. {
  7. case SKPaymentTransactionStatePurchasing:
  8. {
  9. NSLog(@"Purchasing Product From Store!");
  10. }
  11. break;
  12.  
  13. case SKPaymentTransactionStatePurchased:
  14. {
  15. NSLog(@"Purchased Product From Store! %@", transaction.description);
  16. [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
  17. if(buyProductBlock != nil)
  18. {
  19. buyProductBlock(TRUE, nil);
  20. buyProductBlock = nil;
  21. }
  22. }
  23. break;
  24.  
  25. case SKPaymentTransactionStateRestored:
  26. {
  27. //SKPaymentTransactionStateRestored is only issued after you call restoreCompletedTransactions.
  28. NSLog(@"Restored");
  29. [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
  30. }
  31. break;
  32.  
  33. case SKPaymentTransactionStateFailed:
  34. {
  35. NSLog(@"Purchase failed %@ %@", transaction.payment.productIdentifier, transaction.payment.debugDescription);
  36. [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
  37.  
  38. if(buyProductBlock != nil)
  39. {
  40. if (transaction.error.code == SKErrorPaymentCancelled)
  41. buyProductBlock(FALSE, nil);
  42. else
  43. buyProductBlock(FALSE, transaction.error.localizedDescription);
  44. buyProductBlock = nil;
  45. }
  46.  
  47. }
  48. break;
  49.  
  50.  
  51. default:
  52. break;
  53. }
  54. }
  55. }
  56.  
  57. Test an Interrupted Transaction
  58.  
  59. Set a breakpoint in your transaction queue observer’s paymentQueue:updatedTransactions: method
  60. so you can control whether it delivers the product. Then make a purchase as usual in the test
  61. environment, and use the breakpoint to temporarily ignore the transaction—for example, by
  62. returning from the method immediately using the thread return command in LLDB. Terminate and
  63. relaunch your app. Store Kit calls the paymentQueue:updatedTransactions: method again shortly
  64. after launch; this time, let your app respond normally. Verify that your app correctly delivers
  65. the product and completes the transaction.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement