1
votes

So my goal is to have the Apple Pay sheet show up when I tap on the Apple Pay button in my app. So I went through the documentation regarding integrating Apple Pay with the Stripe API and I followed step by step, even the troubleshooting issue, created a new merchant ID and all that jazz and it showed up on my sandbox testing iCloud account I made in App Store Connect.

Now I read that you can't save Stripe test cards into the Wallet app in iOS which absolutely sucks, and from my experience, I'm assuming you can't use Apple sandbox test cards while using the Apple Pay integrated with Stripe. I could be wrong about that, but every time I try to pay with Apple Pay using a Sandbox test card that Apple provides, it always says 'Payment Not Completed'. I also seen that you can use live cards and not get charged so I signed into my main iCloud, added my debit card to the Wallet, but when I simulate the app on my phone and click the Apple Pay button, it doesn't present the Apple Pay sheet, I use the exact same code and it works with my Sandbox Account so I'm confident there's nothing wrong with the code.

Here is the code block either way:

 @objc func applePayTapped() {
    let text = actualCostOfEvent.text
    let textWithout$ = text?.replacingOccurrences(of: "$", with: "")
    let finalCost = Double(textWithout$ ?? "")
    let fee = Double(0.50) * Double(stepperValue.value)
    let total = finalCost! + fee
    
    let paymentRequest = StripeAPI.paymentRequest(withMerchantIdentifier: "merchant.xxxxx.xxxxx.xxxxx", country: "CA", currency: "CAD")
    
    paymentRequest.paymentSummaryItems = [
        PKPaymentSummaryItem(label: navigationItem.title ?? "" , amount: NSDecimalNumber(value: finalCost!)),
        PKPaymentSummaryItem(label: "Service Fee", amount: NSDecimalNumber(value: fee)),
        PKPaymentSummaryItem(label: "Company", amount: NSDecimalNumber(value: total))
    ]

    if let applePayController = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) {
        if StripeAPI.canSubmitPaymentRequest(paymentRequest) {
            applePayController.presentApplePay()
            startCheckout()
        }
    } else {
        print("There was an issue presenting the Apple Pay VC")

    }
}

While writing this I've already reached out to Stripe support, but in the meanwhile, any suggestions for what I can do currently?

1

1 Answers

0
votes

In order for this to work I needed to add .interac to the supported networks with Apple Pay.

StripeAPI.additionalEnabledApplePayNetworks = [.interac]

The Apple Pay sheet shows up fine now.