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

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

冒泡 No
可取消 No
接口 MerchantValidationEvent
事件处理程序特性 onmerchantvalidation

范例

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.

还可以使用 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();
					

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

规范

规范 状态 注释
支付请求 API
The definition of 'merchantvalidation' 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 ?

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

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

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

另请参阅

元数据

  • 最后修改: