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
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onmerchantvalidation | Chrome ? | Edge ? | Firefox
Full support
64
| IE No support No | Opera No support No | Safari ? | WebView Android No support No | Chrome Android ? | Firefox Android
Full support
64
| Opera Android No support No | Safari 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.
