Error: Apple pay not completed

前端 未结 3 2094
猫巷女王i
猫巷女王i 2020-12-20 21:19

I have implemented apple pay in my iOS application using Passkit framework. I did all of these things fully to set up apple pay. I am using sandbox account. I added

相关标签:
3条回答
  • 2020-12-20 21:58

    There are still cases when you do have completion/handler properly called in PKPaymentAuthorizationViewControllerDelegate functions that expect this handler, but your internal payment API happen to be set to a longer timeout time than ApplePay dialog expects (as of iOS 13 it would timeout in around 30 secs).

    In these cases you may get "Apple pay not completed" error in slow networks (try to block your API artificially to simulate such a situation).

    A solution might be in proactively dismissing the ApplePay dialog yourself just before it gives up and shows the error. More details on how to do this can be found in this answer to a similar question being discussed.

    0 讨论(0)
  • 2020-12-20 22:00

    Recently I faced the same issue and I found a solution.

    Everything is fine only we have to update the handler with the success or failure like this:

    func paymentAuthorizationViewController(_ controller: 
    PKPaymentAuthorizationViewController, didAuthorizePayment payment: 
    PKPayment, handler completion: @escaping 
    (PKPaymentAuthorizationResult) -> Void) { 
    

    If the payment data are nil or not check for simulator always its nil :

    do {
                let jsonResponse = try JSONSerialization.jsonObject(with: paymentStatus.paymentData, options: .mutableContainers)
                print(jsonResponse as! NSDictionary)
                completion(PKPaymentAuthorizationResult(status: .success, errors: nil))
                
            }
            catch let error
            {
                print(error)
                completion(PKPaymentAuthorizationResult(status: .failure, errors: nil))
                
            }
    

    It should solve the problem.

    0 讨论(0)
  • 2020-12-20 22:02

    In each implemented delegate function of PKPaymentAuthorizationViewControllerDelegate that have completion/handler you must call that block with the appropriate parameters and most importantly with appropriate status.

    On iOS 11 not calling the block within (approximately) 15-20s, the iOS is killing the Payment with the error you are seeing. On iOS 10, it will let you spin on Processing indefinitely until the completion blocks are called.

    I had the same issue and it turned out that I was not calling the handler block at all in one of the edge cases.

    0 讨论(0)
提交回复
热议问题