@@ -134,7 +134,7 @@ - (void)handleProductRequestMethodCall:(FlutterMethodCall *)call result:(Flutter
134134- (void )createPaymentWithProductID : (FlutterMethodCall *)call result : (FlutterResult)result {
135135 if (![call.arguments isKindOfClass: [NSString class ]]) {
136136 result ([FlutterError
137- errorWithCode: @" storekit_invalide_argument "
137+ errorWithCode: @" storekit_invalid_argument "
138138 message: @" Argument type of createPaymentWithProductID is not a string."
139139 details: call.arguments]);
140140 return ;
@@ -145,7 +145,7 @@ - (void)createPaymentWithProductID:(FlutterMethodCall *)call result:(FlutterResu
145145 result ([FlutterError
146146 errorWithCode: @" storekit_product_not_found"
147147 message: @" Cannot find the product. To create a payment of a product, you must query "
148- @" the product with SKProductRequestMaker.startProductRequest."
148+ @" the product with SKProductRequestMaker.startProductRequest first ."
149149 details: call.arguments]);
150150 return ;
151151 }
@@ -156,38 +156,37 @@ - (void)createPaymentWithProductID:(FlutterMethodCall *)call result:(FlutterResu
156156
157157- (void )addPayment : (FlutterMethodCall *)call result : (FlutterResult)result {
158158 if (![call.arguments isKindOfClass: [NSDictionary class ]]) {
159- result ([FlutterError errorWithCode: @" storekit_invalide_argument "
159+ result ([FlutterError errorWithCode: @" storekit_invalid_argument "
160160 message: @" Argument type of addPayment is not a map"
161161 details: call.arguments]);
162162 return ;
163163 }
164164 NSDictionary *paymentMap = (NSDictionary *)call.arguments ;
165165 NSString *productID = [paymentMap objectForKey: @" productID" ];
166166 SKPayment *payment = [self .paymentsCache objectForKey: productID];
167- // User can use payment object with mutable = true and add simulatesAskToBuyInSandBox = true to
167+ // User can use payment object with usePaymentObject = true and add simulatesAskToBuyInSandBox = true to
168168 // test the payment flow.
169- if (!payment || [paymentMap[@" mutable " ] boolValue ] == YES ) {
169+ if (!payment || [paymentMap[@" usePaymentObject " ] boolValue ] == YES ) {
170170 SKMutablePayment *mutablePayment = [[SKMutablePayment alloc ] init ];
171171 mutablePayment.productIdentifier = productID;
172172 NSNumber *quantity = [paymentMap objectForKey: @" quantity" ];
173- if (quantity) {
174- mutablePayment.quantity = quantity.integerValue ;
175- }
173+ mutablePayment.quantity = quantity?quantity.integerValue :1 ;
176174 NSString *applicationUsername = [paymentMap objectForKey: @" applicationUsername" ];
177175 mutablePayment.applicationUsername = applicationUsername;
178176 if (@available (iOS 8.3 , *)) {
179177 mutablePayment.simulatesAskToBuyInSandbox =
180178 [[paymentMap objectForKey: @" simulatesAskToBuyInSandBox" ] boolValue ];
181179 }
182- [self .paymentQueueHandler addPayment: payment ];
180+ [self .paymentQueueHandler addPayment: mutablePayment ];
183181 } else {
184182 [self .paymentQueueHandler addPayment: payment];
185183 }
184+ result (nil );
186185}
187186
188187- (void )finishTransaction : (FlutterMethodCall *)call result : (FlutterResult)result {
189188 if (![call.arguments isKindOfClass: [NSString class ]]) {
190- result ([FlutterError errorWithCode: @" storekit_invalide_argument "
189+ result ([FlutterError errorWithCode: @" storekit_invalid_argument "
191190 message: @" Argument type of finishTransaction is not a string."
192191 details: call.arguments]);
193192 return ;
@@ -211,24 +210,25 @@ - (void)finishTransaction:(FlutterMethodCall *)call result:(FlutterResult)result
211210 details: e.description]);
212211 return ;
213212 }
213+ result (nil );
214214}
215215
216216#pragma mark - delegates
217217
218218- (void )handleTransactionsUpdated : (NSArray <SKPaymentTransaction *> *)transactions {
219219 NSMutableArray *maps = [NSMutableArray new ];
220- for (SKPaymentTransaction *transcation in transactions) {
221- [maps addObject: [FIAObjectTranslator getMapFromSKPaymentTransaction: transcation ]];
220+ for (SKPaymentTransaction *transaction in transactions) {
221+ [maps addObject: [FIAObjectTranslator getMapFromSKPaymentTransaction: transaction ]];
222222 }
223- [self .callbackChannel invokeMethod: @" updatedTransaction " arguments: maps];
223+ [self .callbackChannel invokeMethod: @" updatedTransactions " arguments: maps];
224224}
225225
226226- (void )handleTransactionsRemoved : (NSArray <SKPaymentTransaction *> *)transactions {
227227 NSMutableArray *maps = [NSMutableArray new ];
228- for (SKPaymentTransaction *transcation in transactions) {
229- [maps addObject: [FIAObjectTranslator getMapFromSKPaymentTransaction: transcation ]];
228+ for (SKPaymentTransaction *transaction in transactions) {
229+ [maps addObject: [FIAObjectTranslator getMapFromSKPaymentTransaction: transaction ]];
230230 }
231- [self .callbackChannel invokeMethod: @" removedTransaction " arguments: maps];
231+ [self .callbackChannel invokeMethod: @" removedTransactions " arguments: maps];
232232}
233233
234234- (void )handleTransactionRestoreFailed : (NSError *)error {
@@ -252,7 +252,7 @@ - (void)updatedDownloads:(NSArray<SKDownload *> *)downloads {
252252}
253253
254254- (BOOL )shouldAddStorePayment : (SKPayment *)payment product : (SKProduct *)product {
255- // We alwasy return NO here. And we send the message to dart to process the payment; and we will
255+ // We always return NO here. And we send the message to dart to process the payment; and we will
256256 // have a incerpection method that deciding if the payment should be processed (implemented by the
257257 // programmer).
258258 [self .productsCache setObject: product forKey: product.productIdentifier];
0 commit comments