2

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.

Eric Hua
  • 976
  • 2
  • 11
  • 29
  • Is this on a simulator or a physical device? It wouldn't really surprise me if Apple Pay is broken on the new version of the simulator, it seems to happen every time until they fix it. https://stackoverflow.com/questions/58563489/ios-applepay-pkpaymentauthorizationviewcontroller-not-appearing-in-xcode11-ios-1 – karllekko Sep 30 '20 at 09:00
  • @karllekko It's broken on both simulators and real devices D: – Eric Hua Sep 30 '20 at 16:52
  • @EricHua did you find a solution? Please share! – Mumtaz Hussain Oct 22 '21 at 14:23
  • 1
    @MumtazHussain Hi unfortunately I didn't, maybe you can submit a ticket to Stripe – Eric Hua Oct 23 '21 at 02:33

0 Answers0