安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

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.

句法

paymentRequest.onmerchantvalidation = eventHandlerFunction;
					

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.

范例

An example merchant validation handler for the PaymentRequest 对象 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();
					

更多信息,见 Merchant Validation in Payment processing concepts .

规范

规范 状态 注释
支付请求 API
The definition of 'onmerchantvalidation' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
onmerchantvalidation Chrome ? Edge ? Firefox 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari ? WebView Android 不支持 No Chrome Android ? Firefox Android 64 注意事项 Disabled
64 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android ?

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

元数据

  • 最后修改: