安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
只读
methodName
特性为
PaymentMethodChangeEvent
interface is a string which uniquely identifies the payment handler currently selected by the user.
The payment handler may be a payment technology, such as Apple Pay or Android Pay, and each payment handler may support multiple payment methods; changes to the payment method within the payment handler are described by the
PaymentMethodChangeEvent
.
var methodName = paymentMethodChangeEvent.methodName;
A
DOMString
which uniquely identifies the currently-selected payment handler. This may be a string chosen from the list of standardized payment method identifiers, or a URL used by the payment processing service. See
Payment method identifiers
in
支付请求 API
了解更多信息。
The default value is the empty string,
""
.
此范例使用
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();
| 规范 | 状态 | 注释 |
|---|---|---|
|
支付请求 API
The definition of 'PaymentMethodChangeEvent.methodName' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
methodName
|
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