<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "ApplePayontheWeb",
  "identifier" : "/documentation/ApplePayontheWeb/ApplePaySession/onvalidatemerchant",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Apple Pay on the Web"
    ],
    "preciseIdentifier" : "instp/ApplePaySession/onvalidatemerchant"
  },
  "title" : "onvalidatemerchant"
}
-->

# onvalidatemerchant

An event handler the system calls when it displays the payment sheet.

```
attribute EventHandler onvalidatemerchant;
```

## Discussion

Use this attribute to request and return a merchant session. You must set this attribute to the following function:

```javascript
session.onvalidatemerchant = function(event) {}
```

where `event` is an [`ApplePayValidateMerchantEvent`](/documentation/ApplePayontheWeb/ApplePayValidateMerchantEvent) object.

The process to complete the merchant validation is as follows:

1. Your [`onvalidatemerchant`](/documentation/ApplePayontheWeb/ApplePaySession/onvalidatemerchant) function calls your server, and passes it the static hostname `apple-pay-gateway.apple.com` as the validation URL. In the China region, use `cn-apple-pay-gateway.apple.com`.
2. Your server uses the validation URL to request a session from the Apple Pay server, as described in <doc://com.apple.documentation/documentation/ApplePayontheWeb/requesting-an-apple-pay-payment-session>.
3. In response, your server receives an opaque merchant session object, `MerchantSession`.
4. You pass the merchant session object to the completion method, [`completeMerchantValidation`](/documentation/ApplePayontheWeb/ApplePaySession/completeMerchantValidation).

The system enables the payment sheet.

> Note:
> Previous merchant validation instructions stated that your ``doc://com.apple.applepayontheweb/documentation/ApplePayontheWeb/ApplePaySession/onvalidatemerchant`` function must call your server and pass it the URL from the event’s ``doc://com.apple.applepayontheweb/documentation/ApplePayontheWeb/ApplePayValidateMerchantEvent/validationURL`` attribute. Apple Pay continues to support this flow for existing implementations.

## See Also

[Providing Merchant Validation](/documentation/ApplePayontheWeb/providing-merchant-validation)

Validate your merchant identity and receive a session object for each payment request.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)