File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ typedef void(^PaymentTransactionStateRestored)(NSArray *transactions);
2828
2929- (void )requestProductsWithIdentifiers : (NSSet *)productsSet productsReturnedSuccessfully : (ProductsReturnedSuccessfully)productsReturnedSuccessfullyBlock invalidProducts : (InvalidProducts)invalidProductsBlock failure : (Failure)failureBlock ;
3030
31+ - (void )configurePaymentTransactionStatePurchasing : (PaymentTransactionStatePurchasing)paymentTransactionStatePurchasingBlock paymentTransactionStatePurchased : (PaymentTransactionStatePurchased)paymentTransactionStatePurchasedBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock paymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock failure : (Failure)failureBlock ;
32+
33+ /* *
34+ * Only if configure payment transaction blocks before calling that method
35+ *
36+ * @param product the product to buy
37+ */
38+ - (void )requestPaymentForProduct : (SKProduct *)product ;
39+
3140- (void )requestPaymentForProduct : (SKProduct *)product paymentTransactionStatePurchasing : (PaymentTransactionStatePurchasing)paymentTransactionStatePurchasingBlock paymentTransactionStatePurchased : (PaymentTransactionStatePurchased)paymentTransactionStatePurchasedBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock paymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock failure : (Failure)failureBlock ;
3241
3342- (void )restorePurchasesPaymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock failure : (Failure)failureBlock ;
Original file line number Diff line number Diff line change @@ -82,6 +82,32 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu
8282 }
8383}
8484
85+ - (void )configurePaymentTransactionStatePurchasing : (PaymentTransactionStatePurchasing)paymentTransactionStatePurchasingBlock paymentTransactionStatePurchased : (PaymentTransactionStatePurchased)paymentTransactionStatePurchasedBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock paymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock failure : (Failure)failureBlock {
86+
87+ self.paymentTransactionStatePurchasingBlock = paymentTransactionStatePurchasingBlock;
88+ self.paymentTransactionStatePurchasedBlock = paymentTransactionStatePurchasedBlock;
89+ self.paymentTransactionStateFailedBlock = paymentTransactionStateFailedBlock;
90+ self.paymentTransactionStateRestoredBlock = paymentTransactionStateRestoredBlock;
91+ self.failureBlock = failureBlock;
92+ }
93+
94+ - (void )requestPaymentForProduct : (SKProduct *)product {
95+ SKPayment *payment = [SKPayment paymentWithProduct: product];
96+
97+ if ([SKPaymentQueue canMakePayments ])
98+ {
99+ [[SKPaymentQueue defaultQueue ] addTransactionObserver: self ];
100+ [[SKPaymentQueue defaultQueue ] addPayment: payment];
101+ }
102+ else
103+ {
104+ if (failureBlock)
105+ {
106+ failureBlock ([NSError errorWithDomain: SCPStoreKitDomain code: SCPErrorCodePaymentQueueCanNotMakePayments errorDescription: @" SKPaymentQueue can not make payments" errorFailureReason: @" Has the SKPaymentQueue got any uncompleted purchases?" errorRecoverySuggestion: @" Finish all transactions" ]);
107+ }
108+ }
109+ }
110+
85111- (void )requestPaymentForProduct : (SKProduct *)product paymentTransactionStatePurchasing : (PaymentTransactionStatePurchasing)paymentTransactionStatePurchasingBlock paymentTransactionStatePurchased : (PaymentTransactionStatePurchased)paymentTransactionStatePurchasedBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock paymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock failure : (Failure)failureBlock
86112{
87113 self.paymentTransactionStatePurchasingBlock = paymentTransactionStatePurchasingBlock;
You can’t perform that action at this time.
0 commit comments