PaymentRequest: abort() 方法
PaymentRequest 介面的 PaymentRequest.abort() 方法會讓使用者代理結束支付請求,並移除可能顯示的任何使用者介面。
語法
js
abort()
引數
無。
返回值
無(undefined)。
示例
以下示例設定了一個超時,用於清除可能已被放棄或忽略的支付請求。
js
const request = new PaymentRequest(supportedInstruments, details, options);
const paymentTimeout = setTimeout(
() => {
clearTimeout(paymentTimeout);
request
.abort()
.then(() => {
print("Payment timed out after 20 minutes.");
})
.catch(() => {
print(
"Unable to abort, because the user is currently in the process " +
"of paying.",
);
});
},
20 * 60 * 1000,
); /* 20 minutes */
規範
| 規範 |
|---|
| Payment Request API # dom-paymentrequest-abort |
瀏覽器相容性
載入中…