Apple developer documentation says that Apple Pay paymentSummaryItems support a grand total amount for 0.00 as of iOS 12.0, however, the Stripe iOS SDK source code says it is not supported: https://github.com/stripe/stripe-ios/blob/master/Stripe/PublicHeaders/STPPaymentContext.h#L229-L230
NSMutableArray *summaryItems = [NSMutableArray array];
PKPaymentSummaryItem *summaryItem = [[PKPaymentSummaryItem alloc] init];
summaryItem.label = @"Total Amount";
summaryItem.amount = [NSDecimalNumber zero];
[summaryItems addObject:summaryItem];
PKPaymentRequest *paymentRequest = [Stripe paymentRequestWithMerchantIdentifier:merchantId];
[paymentRequest setPaymentSummaryItems:summaryItems];
if ([Stripe canSubmitPaymentRequest:paymentRequest]) {
PKPaymentAuthorizationViewController *paymentAuthorizationVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
paymentAuthorizationVC.delegate = self;
[RCTPresentedViewController() presentViewController:paymentAuthorizationVC animated:YES completion:nil];
} else {
// There is a problem with your Apple Pay configuration.
promiseRejector = nil;
promiseResolver = nil;
requestIsCompleted = YES;
reject(
[NSString stringWithFormat:@"%ld", (long)1],
@"Apple Pay configuration error",
[NSError errorWithDomain:@"StipeNative" code:1 userInfo:@{NSLocalizedDescriptionKey:@"Apple Pay configuration error"}]
);
}
12.0+
Embedded Static Framework
15.0.1
Is this a configuration issue or are 0.00 amount values not supported?
hello @todesignandconquer !
The SDK should support $0 values for summaryItems, even on v15.0.1. Can you try it out?
The comment/documentation might need to be updated.
I updated the issue with a more thorough example. The short of it is that [Stripe canSubmitPaymentRequest:paymentRequest] returns null.
Changing the code to a try/catch resolved the issue, but seemingly canSubmitPaymentRequest should not be returning null when attempting to submit a grand total of $0.00.
@todesignandconquer thanks for updating this!
ah yes that is something that would need to be changed in canSubmitPaymentRequest
I believe this is the line of code that affects this issue: https://github.com/stripe/stripe-ios/blob/master/Stripe/STPAPIClient.m#L417
馃憤 I'm fixing this in https://github.com/stripe/stripe-ios/pull/1499/files#diff-6ce78242d6db3a6591d35c527d8dff93R418