我試圖運行支付請求API的示例,如https://www.youtube.com/watch?v=yelPlCVZLEE上所示。 我跟隨的過程,因爲他們描述和我也運行下面的代碼:PaymentRequest 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 這是說它的定義。 我做錯了什麼?
非常感謝您的回覆。我做了它,它的工作,但現在,按照https://www.w3.org/TR/payment-request/上的步驟,並通過執行以下調用API: –
謝謝!我以爲我必須啓用'#web-payments'標誌 - 但不是!乾杯:) –