Stripe ApplePayContext fails to present payment sheet on iOS 14

1.2k Views Asked by At

I'm trying to implement Apple Pay payment throught Stripe and PassKit. I've done the following to create an STPAppleyPayContext, and use its presentApplePay(on:completion:) method to display the Apple Pay payment sheet.

let merchantId = "A_VALID_MERCHANT_ID_HERE"
let currency = "usd"
let country = "US"
let paymentReq = Stripe.paymentRequest(withMerchantIdentifier: merchantId, country: country, currency: currency)

// Configure the line items on the payment request
let charge = NSDecimalNumber(value: 1000)
let summaryItems = [PKPaymentSummaryItem(label: "Service", amount: charge)]
paymentReq.paymentSummaryItems = summaryItems

if let applePayContext = STPApplePayContext(paymentRequest: paymentReq, delegate: self) {
    print("--- presenting apple pay sheet")
    applePayContext.presentApplePay(on: self, completion: nil)
} else {
    print("--- failed to create STPApplePayContext, may be a problem with the Apple Pay config")
}

In the logs, "--- presenting apple pay sheet" was printed, so I believe applePayContext.presentApplePay(on:completion:) was successfully called. However, no sheet was presented, and I can't find any error logs.

The exact same code worked when we build the App on iOS 13, but it doesn't work on iOS 14. I am wondering if it is related some update to the Apple Pay system in iOS 14, or something else went wrong.

0

There are 0 best solutions below