PaymentRequest: merchantvalidation event

merchantvalidation events are delivered by the Payment Request API to a PaymentRequest object when a payment handler requires that the merchant requesting the purchase validate itself as permitted to use the payment handler.

See Merchant validation in Payment processing concepts for details on how the merchant validation process works.

Bubbles No
Cancelable No
Interface MerchantValidationEvent
Event handler property onmerchantvalidation

Examples

In this example, an event handler is established for the merchantvalidation event. It uses the fetch() to send a request to its own server with an argument of the payment method's validation URL, obtained from the event's validationURL property. The merchant server should access the validation URL in accordance with the payment method documention. Typically, a client should not access the validation URL.

request.addEventListener("merchantvalidation", event => {
  event.complete(async () => {
    const merchantServerUrl = window.location.origin +
        '/validate?url=' + encodeURIComponent(event.validationURL);
    // get validation data, and complete validation;
    return await fetch(merchantServerUrl).then(response => response.text());
  }, false);
};

const response = await request.show();

How merchant server handles the validation depends on the server implementation and payment method documentation. The content delivered by the validation server is forwarded to the merchant server and is then returned from the fetch() call's fulfillment handler to the complete() method on the event. This response lets the payment handler know if the merchant is validated.

You can also use the onmerchantvalidation event handler property to set up the handler for this event:

request.onmerchantvalidation = event => {
  event.complete(async () => {
    const merchantServerUrl = window.location.origin +
        '/validate?url=' + encodeURIComponent(event.validationURL);
    // get validation data, and complete validation;
    return await fetch(merchantServerUrl).then(response => response.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 'merchantvalidation' in that specification.
Candidate Recommendation  

Browser compatibility

Update compatibility data on GitHub
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.

See also

Document Tags and Contributors

Contributors to this page: Sheppy, rsolomakhin, mdnwebdocs-bot
Last updated by: Sheppy,