CanMakePaymentEvent
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.
Giao diện CanMakePaymentEvent của Web-based Payment Handler API là đối tượng sự kiện cho sự kiện canmakepayment, được kích hoạt trên service worker của một ứng dụng thanh toán để kiểm tra xem ứng dụng đó đã sẵn sàng xử lý một khoản thanh toán hay chưa. Cụ thể, sự kiện này được kích hoạt khi website của bên bán gọi hàm tạo PaymentRequest().
Constructor
CanMakePaymentEvent()Experimental-
Tạo một phiên bản đối tượng
CanMakePaymentEventmới.
Instance methods
respondWith()Experimental-
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.
Examples
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> # the-canmakepaymentevent> |