Failed to cancel PKPaymentAuthorizationViewController

I am working on implementing Apple Pay for my application. Although I have everything that is mostly found out, I cannot reject the PKPaymentAuthorizationViewController, which is being authenticated. Here is my code ..

-(void) viewDidAppear:(BOOL)animated {
    // request is initialized here.
    paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];

    //paymentPane is not nil. 
    paymentPane.delegate = self;

    [self presentViewController:paymentPane animated:TRUE completion:nil];
}

The above function is called and successfully represents the Apple Pay View Controller for payment authentication. I executed the following methods from the delegate as follows:

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

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion {
     NSLog(@"%@", [payment.token description]);
     completion(PKPaymentAuthorizationStatusSuccess);
}

didAuthorizePayment, , paymentAuthorizationViewControllerDidFinish Apple View. , , ViewController . , "" Apple Pay View.

.

@interface ApplePayManager : UIViewController<PKPaymentAuthorizationViewControllerDelegate, UIAlertViewDelegate>

, ? ?

, iOS. / , !

: http://www.raywenderlich.com/87300/apple-pay-tutorial https://dzone.com/articles/integrating-your-ios-app-apple

+4
1

. . , ViewController, ApplePay View, rootVC. , rootVC.

  UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];

  [rootViewController presentViewController:paymentPane animated:TRUE completion:nil];
+1

Source: https://habr.com/ru/post/1617335/


All Articles