Skip to content

Instantly share code, notes, and snippets.

@philipshen
Last active September 5, 2019 19:34
Show Gist options
  • Save philipshen/16fbab939902039da95c3d0c935bacf3 to your computer and use it in GitHub Desktop.
Save philipshen/16fbab939902039da95c3d0c935bacf3 to your computer and use it in GitHub Desktop.
if fetchedPaymentToken == nil {
let request = self.paymentRepository.createPKRequest(order: order)
if self.paymentRepository.canSubmit(paymentRequest: request) {
group.enter()
let paymentController = PaymentAuthorizationController()
paymentController.present(paymentRequest: request) { [weak self] controller, payment, authCompletion in
self?.paymentRepository.createStripeToken(payment: payment, completion: { token, error in
defer { group.leave() }
guard let token = token, error == nil else {
return
}
fetchedPaymentToken = token
})
}
} else {
return completion(.init(code: .failureNoPaymentMethod, userActivity: nil))
}
}
group.wait()
@philipshen
Copy link
Author

Notes:

Line 1: the fetchedPaymentToken being nil indicates that the user is going to use ApplePay, and therefore this block of code is executed.

Line 7: Because of the issue I'm having with PKPaymentAuthorizationController, this completion handler is never called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment