While trying to integrate Apple Pay into my test app, I couldn't get the payment sheet to show up, even though I followed all instructions in Apple's Getting Started with Apple Pay document.
When making the payment request:
PKPaymentAuthorizationViewController *auth = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
I get two weird errors, with no results on web searches:
Error on PKInAppPaymentService connection: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)" (connection to service named com.apple.passd.in-app-payment) UserInfo=0x174273780 {NSDebugDescription=connection to service named com.apple.passd.in-app-payment}
Connection to remote alert view service failed
After following the four steps in Apple's getting started doc, the solution is hidden step number 5:
Enable Apple Pay in your project settings, on the Capabilities tab. This is arguably part of step 4 in Apple's doc, but the step that really tripped me up was checking on the merchant id as shown in the screenshot below:
Edit: Also see answer from @ChristopherJones if you still have trouble.
(Make sure the merchantId you use with a payment request is exactly the same as the one in your Apple Pay capabilities section. Remove the alphanumeric stuff in the beginning if you included it.)
After that, just build and run again.
Also can happen if you subclass from PKPaymentRequest
and feed your subclass to PKPaymentAuthorizationViewController
I had this same issue and the problem was you have to make sure your PKPaymentRequest's merchantIdentifier matches exactly without the random number. Also, you need to make sure that the same identifier is check marked in the Capabilities tab.
PKPaymentRequest *request = [PKPaymentRequest new];
request.merchantIdentifier = @"merchant.com.example";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With