Stripe-ios: Apple Pay support for 0.00 grand total amounts

Created on 3 Mar 2020  路  5Comments  路  Source: stripe/stripe-ios

Summary

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

Code to reproduce

    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"}]
        );
    }

iOS version

12.0+

Installation method

Embedded Static Framework

SDK version

15.0.1

Other information

Is this a configuration issue or are 0.00 amount values not supported?

bug triaged

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Andrewangeta picture Andrewangeta  路  6Comments

coolcool1994 picture coolcool1994  路  4Comments

valheru7 picture valheru7  路  4Comments

billinghamj picture billinghamj  路  6Comments

aurelhubert picture aurelhubert  路  6Comments