Created
October 4, 2017 22:52
-
-
Save farhan-syed/79ad3952ce00a2fa7ae2f20f92ee6b41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) { | |
STPAPIClient.shared().createToken(with: payment) { (token: STPToken?, error: Error?) in | |
guard let token = token, error == nil else { | |
// Present error to user... | |
return | |
} | |
submitTokenToBackend(token, completion: { (error: Error?) in | |
if let error = error { | |
// Present error to user... | |
// Notify payment authorization view controller | |
completion(.failure) | |
} | |
else { | |
// Save payment success | |
paymentSucceeded = true | |
// Notify payment authorization view controller | |
completion(.success) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment