问题
Is there a way to know when CANCEL is pressed in the Apple Pay view? I tried to look for a delegate, but didn't find one.
回答1:
If you have the PKPaymentAuthorizationViewControllerDelegate methods setup, you can catch the cancel in this method:
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
I set a boolean (applePaymentDidSucceed) to FALSE before I call Apple Pay, then set it to true if the "PKPaymentAuthorizationStatus" in this method is true:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment...
if ( ! applePaymentDidSucceed), the user cancelled.
回答2:
Yes there is!
You can use session.oncancel
event
More info here: - https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession - https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778029-oncancel
回答3:
You will get an error. There are several error codes defined, one is for the user cancelling the payment, another for a user having paid purchases disabled in their settings, and all kinds of other errors (for example, you can't make purchases without internet access).
So no particular case for cancellation, just an error.
来源:https://stackoverflow.com/questions/37169121/is-there-a-way-to-know-when-cancel-is-pressed-in-the-apple-pay-view