【发布时间】:2019-08-01 00:29:54
【问题描述】:
我正在关注 tutorial 关于新的 PaymentRequest API,但我收到错误消息:
未捕获的 TypeError:无法构造“PaymentRequest”:迭代器 getter 是不可调用的。 在 startPayment ((index):45)
function startPayment(){
if (!window.PaymentRequest) {
// PaymentRequest API is not available. Forwarding to
// legacy form based experience.
location.href = '/checkout';
return;
}
const methods = {
supportedMethods: "basic-card",
data: {
supportedNetworks: [
'visa', 'mastercard', 'amex', 'discover',
'diners', 'jcb', 'unionpay'
]
},
}
const details = {
total: {
label: 'Tyle musisz zabulić',
amount: { currency: 'PLN', value : '22.15' }
},
displayItems: [{
label: 'Narkotyki',
amount: { currency: 'PLN', value: '22.15' }
}],
}
const options = {
requestShipping: true,
requestPayerEmail: true,
requestPayerPhone: true,
requestPayerName: true,
shippingType: 'delivery'
};
const request = new PaymentRequest(methods, details, options) // this line fails
request.show().then(response => {
// [process payment]
// send to a PSP etc.
response.complete('success');
});
}
这是什么意思,我该如何解决? MacOS Chrome 版本:72.0.3626.121 64bit
【问题讨论】:
标签: google-chrome progressive-web-apps payment-request-api