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

只读 methodDetails 特性为 PaymentMethodChangeEvent interface is an object containing any data the payment handler may provide to describe the change the user has made to their payment method. The value is null if no details are available.

句法

details = paymentMethodChangeEvent.methodName;
					

An object containing any data needed to describe the changes made to the payment method. The contents vary depending on the actual payment method chosen, so you will need to refer to the methodName property first, then inerpret the methodDetails after that.

默认值为 null , indicating that no additional details are available.

范例

此范例使用 paymentmethodchange event to watch for changes to the payment method selected for Apple Pay, in order to compute a discount if the user chooses to use a Visa card as their payment method.

request.onpaymentmethodchange = function(ev) {
  const { type: cardType } = ev.methodDetails;
  const newStuff = {};
  if (ev.methodName === "https://apple.com/apple-pay") {
    switch (cardType) {
      case "visa":
        // do Apple Pay specific handling for Visa card...
        // methodDetails contains the card information
        const result = calculateDiscount(ev.methodDetails);
        Object.assign(newStuff, result);
        break;
    }
  }
  // finally...
  ev.updateWith(newStuff);
};
const response = await request.show();
					

注意, methodDetails property is being used by the calculateDiscount() function to compute any payment discount, then updateWith() is called to update the event with the computed update.

规范

规范 状态 注释
支付请求 API
The definition of 'PaymentMethodChangeEvent.methodDetails' 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
methodDetails Chrome 不支持 No Edge 不支持 No Firefox 63 注意事项 Disabled
63 注意事项 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 不支持 No Firefox Android 63 注意事项 Disabled
63 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS ? Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

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

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

元数据

  • 最后修改: