Failed to open Apple Pay sheet on iPhone 6

I want to create an example project that opens an Apple Pay sheet when a user clicks the "Pay using Apple Pay" button in their application.

I am testing my application on iPhone 6 with iOS version 8.1 (which contains Apple Pay) and Xcode 6.1 GM. Both of them have not yet been officially released.

I followed the tutorial on this page . And this is my code for handling the on-click event of the Pay with Apple Pay button:

PKPaymentRequest *request = [PKPaymentRequest new]; // Must be configured in Apple Developer Member Center // Doesn't seem like the functionality is there yet request.merchantIdentifier = @"my.valid.merchant.identifier"; request.countryCode = @"US"; request.currencyCode = @"USD"; // Let go! // if (![PKPaymentAuthorizationViewController canMakePayments]) return; PKPaymentAuthorizationViewController *authVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request]; authVC.delegate = self; [self presentViewController:authVC animated:YES completion:nil]; 

By clicking on the "Pay using Apple Pay" button, I received this error:

Application termination due to an uncaught exception "NSInvalidArgumentException", reason: "Application tried to present nil modal view controller to target

When checking PKPaymentAuthorizationViewController canMakePayments] it returns false.

I am not sure why my error is related to iPhone setup or my code.

Does anyone have experience with Apple Pay? Please help me. Thank you very much.

+2
source share
1 answer

I am testing my application on iPhone 6 with iOS version 8.1 (which contains Apple Pay)

No, the latest beta (iOS 8.1 Beta 2) does not contain Apple Pay. There is obviously something under the hood when they work on it, but it is not intended for developers yet.

This is why [PKPaymentAuthorizationViewController canMakePayments] returns NO and authVC is nil . Apple Pay is also not available in the settings and is not mentioned in the release notes .

+3
source

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


All Articles