Error: Apple pay not completed

前端 未结 3 2098
猫巷女王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条回答
  •  萌比男神i
    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.

提交回复
热议问题