File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-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,34 @@ - (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+ [[SKPaymentQueue defaultQueue ] addTransactionObserver: self ];
94+ }
95+
96+ - (void )requestPaymentForProduct : (SKProduct *)product {
97+ SKPayment *payment = [SKPayment paymentWithProduct: product];
98+
99+ if ([SKPaymentQueue canMakePayments ])
100+ {
101+ [[SKPaymentQueue defaultQueue ] addTransactionObserver: self ];
102+ [[SKPaymentQueue defaultQueue ] addPayment: payment];
103+ }
104+ else
105+ {
106+ if (self.failureBlock )
107+ {
108+ self.failureBlock ([NSError errorWithDomain: SCPStoreKitDomain code: SCPErrorCodePaymentQueueCanNotMakePayments errorDescription: @" SKPaymentQueue can not make payments" errorFailureReason: @" Has the SKPaymentQueue got any uncompleted purchases?" errorRecoverySuggestion: @" Finish all transactions" ]);
109+ }
110+ }
111+ }
112+
85113- (void )requestPaymentForProduct : (SKProduct *)product paymentTransactionStatePurchasing : (PaymentTransactionStatePurchasing)paymentTransactionStatePurchasingBlock paymentTransactionStatePurchased : (PaymentTransactionStatePurchased)paymentTransactionStatePurchasedBlock paymentTransactionStateFailed : (PaymentTransactionStateFailed)paymentTransactionStateFailedBlock paymentTransactionStateRestored : (PaymentTransactionStateRestored)paymentTransactionStateRestoredBlock failure : (Failure)failureBlock
86114{
87115 self.paymentTransactionStatePurchasingBlock = paymentTransactionStatePurchasingBlock;
You can’t perform that action at this time.
0 commit comments