PaymentRequest.onmerchantvalidation

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The PaymentRequest event handler onmerchantvalidation is invoked when the merchantvalidation is fired, indicating that the payment handler (e.g., Apple Pay) requires the merchant to validate themselves. This is usually the first event to be fired, and the user won't be able to proceed with a payment until the merchant validate themselves.

This event is not be fired by all payment handlers. In particular, it's used by Apple Pay.

Syntax

paymentRequest.onmerchantvalidation = eventHandlerFunction;

Value

An event handler function which is to be called whenever the merchantvalidation event is fired at the PaymentRequest, indicating that the payment handler requires the merchant to validate themselves as allowed to use this payment handler.

Examples

An example merchant validation handler for the PaymentRequest object request looks like this:

request.onmerchantvalidation = ev => {
  ev.complete(async () => {
    const merchantServerUrl = window.location.origin +
        '/validation?url=' + encodeURIComponent(ev.validationURL);
    // get validation data, and complete validation;
    return await fetch(merchantServerUrl).then(r => r.text());
  })
};

const response = await request.show();

For more information, see Merchant Validation in Payment processing concepts.

Specifications

Specification Status Comment
Payment Request API
The definition of 'onmerchantvalidation' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onmerchantvalidationChrome ? Edge ? Firefox Full support 64
Notes Disabled
Full support 64
Notes Disabled
Notes Available only in nightly builds.
Disabled From version 64: this feature is behind the dom.payments.request.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera No support NoSafari ? WebView Android No support NoChrome Android ? Firefox Android Full support 64
Notes Disabled
Full support 64
Notes Disabled
Notes Available only in nightly builds.
Disabled From version 64: this feature is behind the dom.payments.request.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android No support NoSafari iOS ? Samsung Internet Android ?

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.