Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to detect when the Cancel button it touched on an Apple Pay PKPaymentAuthorizationViewController?

Tags:

ios

applepay

Apple Pay calls the following delegate whenever a PKPaymentAuthorizationViewController is dismissed for any reason. Is there any way to detect if just the Cancel button was touched?

- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

enter image description here

like image 527
Ethan Allen Avatar asked Mar 09 '16 21:03

Ethan Allen


1 Answers

From the documentation for paymentAuthorizationViewControllerDidFinish:

When the user authorizes a payment request, this method is called after the status from the paymentAuthorizationViewController:didAuthorizePayment:completion: method’s completion block has been shown to the user. When the user cancels without authorizing the payment request, only paymentAuthorizationViewControllerDidFinish: is called.

So if

paymentAuthorizationViewController:didAuthorizePayment:completion:

Is not called first, then the user tapped the cancel button (or the controller somehow got cancelled otherwise).

like image 73
Aurast Avatar answered Sep 20 '22 00:09

Aurast