5

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)
TonyMit
  • 51
  • 1
  • I have exactly the same issue. Did you manage to find a solution? – Jean Azzopardi Jan 31 '22 at 18:00
  • @JeanAzzopardi Hello! Not yet :( – TonyMit Feb 02 '22 at 09:51
  • an idea that i've been playing around with is to automatically retry to show upon failure.. it has worked but it does add a bit of a delay. However, I'm very much aware that this is just a workaround. – Jean Azzopardi Feb 07 '22 at 15:53
  • @JeanAzzopardi we have tried smth similar, and faced the delay that you have mentioned. Seems that there is other way to resolve it. – TonyMit Feb 09 '22 at 12:33
  • TonyMit @jean-azzopardi one more with the same issue here! Did you manage to find a working solution, or just used the workaround? – saltukkos Sep 02 '22 at 06:54

0 Answers0