CanMakePaymentEvent: respondWith() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is only available in Service Workers.
Phương thức respondWith() của giao diện CanMakePaymentEvent cho phép service worker phản hồi một cách thích hợp để báo hiệu liệu nó đã sẵn sàng xử lý thanh toán hay chưa.
Syntax
js
respondWith(response)
Parameters
Return value
Không có (undefined).
Examples
js
self.addEventListener("canmakepayment", (e) => {
e.respondWith(
new Promise((resolve, reject) => {
someAppSpecificLogic()
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
});
}),
);
});
Specifications
| Specification |
|---|
| Web-based Payment Handler API> # dom-canmakepaymentevent-respondwith> |