1 year ago
#90908
TonyMit
PKPaymentAuthorizationController is not presented sometimes
We ran into a problem that the PKPaymentAuthorizationController
is not presented, although everything is done, as described in the examples. A PKPaymentRequest
is created in the code, passed to the PKPaymentAuthorizationController
initializer, after which the present
method is called on this PKPaymentAuthorizationController
as well. This behavior is reproduced steely the first time you try to show the controller in a freshly installed application. Also, the bug can be reproduced randomly during the subsequent use of the application; in this case, it is impossible to find any explicit way of reproducing.
The issue is definitely not a typo in any of the values required to create the PKPaymentRequest
, I mean merchantIdentifier
, supportedNetworks
, merchantCapabilities
, countryCode
, currencyCode
and paymentSummaryItems
, we have already checked this more than once. The issue is also not about converting a Double
price value into NSDecimalNumber
, as was written in one of the answers to a similar question on Stack Overflow. We used the debugger, which showed that the PKPaymentRequest
is successfully created, just like the PKPaymentAuthorizationController
itself. But when the present
method is called, nothing happens on the screen. We would be grateful if you could help us solve the issue. Here is a sample code:
let request = PKPaymentRequest()
request.merchantIdentifier = "HERE_IS_OUR_M_ID"
request.supportedNetworks = [.amex, .visa, .masterCard]
request.merchantCapabilities = .capability3DS
request.countryCode = "US"
request.currencyCode = "USD"
request.paymentSummaryItems = [
PKPaymentSummaryItem(label: "BUY_ITEM_TEXT", amount: NSDecimalNumber(value: buyItemPrice)),
PKPaymentSummaryItem(label: "COMPANY_NAME", amount: NSDecimalNumber(value: buyItemPrice), type: .final)
]
let applePayController = PKPaymentAuthorizationController(paymentRequest: request)
applePayController.delegate = self
applePayController.present(completion: nil)
ios
swift
applepay
passkit
0 Answers
Your Answer