Monday, 28 October 2019

iOS ApplePay PKPaymentAuthorizationViewController not appearing in Xcode11/iOS 13

Our application has had ApplePay implemented for a number of years. Just recently I hit the button to trigger it to only find out the pay sheet from PKPaymentAuthorizationViewController doesn't appear. It won't slide up in a sandbox (i.e. simulator or device connected to Xcode) environment, but putting a breakpoint shows that it is being created successfully. It's been awhile since I've tested this, but I am suspecting something change with Xcode11 or iOS 13.

My code is pretty standard Apple Pay, but posted below.

        let item = PKPaymentSummaryItem()
        item.label = "Our Label"
        let price = NSDecimalNumber(mantissa: UInt64(totalPrice), exponent: -2, isNegative: false)
        item.amount = price

        items.append(item)

        request.paymentSummaryItems = items

        if let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request) {
            applePayController.delegate = self
            present(applePayController, animated: true)
        }


from iOS ApplePay PKPaymentAuthorizationViewController not appearing in Xcode11/iOS 13

No comments:

Post a Comment