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 |
浏览器兼容性
加载中…