安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
shippingOption
只读特性在
PaymentRequest
interface returns the ID attribute of the shipping option selected by the user. This option is only present when the
requestShipping
option is set to
true
在
PaymentOptions
object passed to the
PaymentRequest
构造函数。
var shippingOption = PaymentRequest.shippingOption;
In the example below, the
PaymentRequest.onshippingaoptionchange
event is called. It calls
updateDetails()
to toggle the shipping method between "standard" and "express".
// Initialization of PaymentRequest arguments are excerpted for brevity.
var payment = new PaymentRequest(supportedInstruments, details, options);
request.addEventListener('shippingoptionchange', function(evt) {
evt.updateWith(new Promise(function(resolve, reject) {
updateDetails(details, request.shippingOption, resolve, reject);
}));
});
payment.show().then(function(paymentResponse) {
// Processing of paymentResponse exerpted for the same of brevity.
}).catch(function(err) {
console.error("Uh oh, something bad happened", err.message);
});
function updateDetails(details, shippingOption, resolve, reject) {
var selectedShippingOption;
var otherShippingOption;
if (shippingOption === 'standard') {
selectedShippingOption = details.shippingOptions[0];
otherShippingOption = details.shippingOptions[1];
details.total.amount.value = '55.00';
} else if (shippingOption === 'express') {
selectedShippingOption = details.shippingOptions[1];
otherShippingOption = details.shippingOptions[0];
details.total.amount.value = '67.00';
} else {
reject('Unknown shipping option \'' + shippingOption + '\'');
return;
}
selectedShippingOption.selected = true;
otherShippingOption.selected = false;
details.displayItems.splice(2, 1, selectedShippingOption);
resolve(details);
}
| 规范 | 状态 | 注释 |
|---|---|---|
| 支付请求 API | 候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
shippingOption
|
Chrome 61 | Edge 15 |
Firefox
56
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari Yes | WebView Android 不支持 No | Chrome Android 56 |
Firefox Android
56
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS Yes | Samsung Internet Android 6.0 |
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
PaymentResponse