Issue Integrating Apple Pay JS – `merchantSession` Blocke

Hello Apple Devs,

We’re currently trying to integrate Apple Pay on the web using Apple Pay JS. We've followed the official documentation closely, but we're running into a blocker during the merchantSession validation phase.

We successfully retrieved a merchantSession, which looks like this:

json { "displayName": "Our Name", "domainName": "https://pay.ourdomain.co", "epochTimestamp": , "expiresAt": ****************, "merchantIdentifier": "", "merchantSessionIdentifier": ", "nonce": "", "operationalAnalyticsIdentifier": our name "t:", "pspId": "", "retries": 0, "signature": "*****************..." }

Issue: Shortly after initiating the session, we receive a cancel event with the following info:

ApplePayCancelEvent {
type: "cancel",
sessionError: {
code: "unknown",
info: {}
}
}

We're unsure what causes the cancellation. There are no clear error messages or hints in the logs to identify what went wrong.

What We’ve Checked:

  • The merchantSession is returned successfully from our backend.
  • The domainName matches our frontend domain (https://pay.durdomain.co).
  • The session hasn’t expired when tested.
  • We're using Apple Pay JS APIs as described in the documentation.

Help Needed:

  • What can trigger an ApplePayCancelEvent with an "unknown" error code?

Any insight or guidance would be deeply appreciated. Thanks in advance!

Hi! Sorry to hear that you're having difficulties integrating Apple Pay, let's see what we can do to help.

The merchant session object is meant to be opaque, so as long as you're getting the object successfully from the backend, that stage looks to be working fine.

It's not mentioned in what you've described, but have you ensured you're returning the object back to the device using the completeMerchantValidation method? If you don't do this within a reasonable timeframe, the payment sheet on the device will time out and dismiss, causing a cancel event. More information on the overall process can be found on this page.

If you are returning the object back using completeMerchantValidation, then it's possible that some of the logging on the device may indicate what's going on, such as an incorrect configuration for the merchant identifier. You can use the Console app on macOS to inspect the logs on the affected device.

Some information that would help to clarify things would be:

  • Is the issue occurring on iOS, iPadOS, macOS or visionOS?
  • Is this occurring in Safari, or when using a third party web browser?

If this doesn't help, then we would need a sysdiagnose to investigate further, and we can follow up directly.

I would recommend the following:

  • Install the appropriate "Apple Pay" logging profile on the device which displays the payment sheet. This is available from https://developer.apple.com/bug-reporting/profiles-and-logs
  • Restart the device after installing the profile, and reproduce the issue a few times.
  • File Feedback through Feedback Assistant, with as much information as possible. This will provide a sysdiagnose that we can look at. Please do not attempt to upload the sysdiagnose to this thread, but you can post the feedback number you’re provided with after submission. Information about Feedback Assistant and bug reporting can be found at https://developer.apple.com/bug-reporting.
Issue Integrating Apple Pay JS – `merchantSession` Blocke
 
 
Q