I'm adding Apple Pay to my shopping cart web app for the first time. Everything is working perfectly on iPad and iPhone and for at least one MacBook user on my team - we've completed payments, start to finish.
But for one user on a 2023 16-inch MacBook Pro (Ventura 13.0), pressing the Apple Pay button does not cause the pop-up to appear. I've added lots of logging statements in the button handler and in the various callback functions it registers. I'm creating a session, but that session's onvalidatemerchant callback is never called.
I asked this user to test ApplePaySession.canMakePayments(), and it returns true.
A simplified version of the click handler:
function startApplePay(args) {
const paymentRequest = createApplePaymentRequest(args);
const session = new ApplePaySession(3, paymentRequest);
console.log("Created apple pay session", session); // OK
session.onvalidatemerchant = event => {
console.log("onValidateMerchant callback invoked"); // FAILS
// applePayInstance.performValidation(...)
}
session.onpaymentauthorized = event => {...}
session.onshippingcontactselected = event => {...}
session.oncancel = event => {...}
session.begin();
console.log("Started apple pay session", session); // OK
}
There are a lot of logging statements present, that I've omitted here for simplicity, in this function and in each of the callback functions it defines.
On my colleague's MacBook, I see the console logging statements that show successful session creation and that session.begin() was called. But onvalidatemerchant is never called; instead it calls oncancel immediately. Printing the ApplePayCancelEvent to the console, it shows that onvalidatemerchant is a function. It also shows a sessionError with { code: "unknown", info: {} }.
Any way to gain more insight into why onCancel() was called?
We're testing this in production with a production certificate. Everything is working fine on mobile devices (iPad & multiple iPhone users have tested), and we can complete payment start to finish. Another MacBook owner has also made payments successfully - it's just this one MacOS 13 user experiencing problems.
This is similar to an issue from 7 years ago, but I haven't found an answer in that thread: https://developer.apple.com/forums/thread/51657