我正在尝试运行https://www.youtube.com/watch?v=yelPlCVZLEE上所示的付款请求 API 示例。我已经按照他们描述的过程进行了操作,并且我还运行了以下代码:
function go() {
console.log('Pay');
var request = new PaymentRequest([{
supportedMethods:['urn:payment:visa','urn:payment:mc','urn:payment:amex']
}],
{
total: {
label: "Total due",
amount: { currencyCode: "USD", value: "60.00" }, // US$60.00
}
}
);
request.show()
.then(function(response) {
// process transaction response here
return response.complete(true);
})
.then(function() {
alert("Buy!");
})
.catch(function(e) {
alert(e.name);
});
}
我收到以下错误:未捕获的 ReferenceError:PaymentRequest 未定义。
如果我从以下位置运行测试:http: //github.adrianba.net/paymentrequest-demo/tests/payment-tests.html 它说它已定义。我做错了什么?