安全上下文
此特征只可用于
安全上下文
(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. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
methodDetails
|
Chrome 不支持 No | Edge 不支持 No |
Firefox
63
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari ? | WebView Android 不支持 No | Chrome Android 不支持 No |
Firefox Android
63
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS ? | Samsung Internet Android 不支持 No |
完整支持
不支持
兼容性未知
见实现注意事项。
用户必须明确启用此特征。
PaymentMethodChangeEvent
methodDetails
methodName