Skip to content

Instantly share code, notes, and snippets.

@agentcoops
Created September 24, 2015 22:19
Show Gist options
  • Save agentcoops/f2dcb68d016c8beb92c2 to your computer and use it in GitHub Desktop.
Save agentcoops/f2dcb68d016c8beb92c2 to your computer and use it in GitHub Desktop.
IOS 7 Swift
func paymentAuthorizationViewController(
controller: PKPaymentAuthorizationViewController,
didAuthorizePayment payment: PKPayment,
completion: ((PKPaymentAuthorizationStatus) -> Void)) {
self.handlePaymentAuthorizationWithPayment(payment, completion:completion);
}
func handlePaymentAuthorizationWithPayment(payment: PKPayment, completion: ((PKPaymentAuthorizationStatus) -> Void)!) {
STPAPIClient.sharedClient().createTokenWithPayment(
payment,
completion: { (token: STPToken?, error: NSError?) in
if ((error) != nil) {
completion(PKPaymentAuthorizationStatus.Failure)
}
self.createBackendChargeWithToken(token!, completion: completion)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment