hmunoz-stripe

PKPaymentAuthVC

Sep 1st, 2020
1,794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.88 KB | None | 0 0
  1.     func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
  2.        
  3.         STPAPIClient.shared().createToken(with: payment) { (token: STPToken?, error: Error?) in
  4.             guard let token = token, error == nil else {
  5.                 completion(.failure)
  6.                 return
  7.             }
  8.  
  9.             API_Client.sharedInstance.attachToCustomerAndCharge(tokenId: token.stripeID) { (error) in
  10.                 if error != nil {
  11.                     // Notify payment authorization view controller
  12.                     completion(.failure)
  13.                 }
  14.                 else {
  15.                     // Notify payment authorization view controller
  16.                     completion(.success)
  17.                 }
  18.             }
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment