2

I want to make an example project that open an Apple Pay sheet when user clicks on the 'Pay with Apple Pay' button on my app.

I test my app on an iPhone 6 with iOs version 8.1 (which contains Apple Pay) and Xcode 6.1 GM. Both of them have not been officially released yet.

I followed the tutorial on this page. And this is my code for handling the on-click event of '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's go!
// if (![PKPaymentAuthorizationViewController canMakePayments]) return;
PKPaymentAuthorizationViewController *authVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
authVC.delegate = self;
[self presentViewController:authVC animated:YES completion:nil];

Clicking on the 'Pay with Apple Pay' button, I got this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target

When checking the PKPaymentAuthorizationViewController canMakePayments], it returns false.

I'm not sure about the reason of my error is of the iPhone's setting or my code.

Does someone have the experience with Apple Pay? Please help me. Thank you so much.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
haotang
  • 5,520
  • 35
  • 46
  • Don't you think it is odd that you are commenting out `canMakePayments`? If it returns `NO` then why would you expect it to work? – borrrden Oct 09 '14 at 02:48
  • @borrrden I commented it for checking if the Apple Pay sheet display an error message or it will return error on code. Due to the lack of documentations. I just try to investigate all situations as possible :( – haotang Oct 09 '14 at 02:55
  • Yes encountered the same problem...... – iAnurag Nov 18 '14 at 10:15

1 Answers1

3

I test my app on an iPhone 6 with iOs version 8.1 (which contains Apple Pay)

No, the most recent beta (iOS 8.1 Beta 2) does not contain Apple Pay. There's obviously some stuff in there under the hood as they're working on it, but it's not intended to work for developers yet.

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

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • Thanks for your information. May be we should wait for an official release :) – haotang Oct 09 '14 at 03:05
  • I updated to iOS 8.1.1. In my case 'canMakePayments' is returning YES. But while presenting pkpaymentauthorizationviewcontroller, it is becoming nil...what to do???? – iAnurag Nov 18 '14 at 12:51
  • Any update? I am also facing same issue but with Braintree + Apple Pay :( – Femina Jan 22 '15 at 11:55
  • @Meenu Apple Pay has been released. This question was about the iOS 8.1 betas before it was released. Please ask a separate question about your issue, since it's a little different. – Aaron Brager Jan 22 '15 at 12:42
  • Question: http://stackoverflow.com/questions/28090069/braintree-apple-pay-testing-on-real-device – Femina Jan 22 '15 at 13:37