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.
The CanMakePaymentEvent() constructor creates a new CanMakePaymentEvent object instance.
new CanMakePaymentEvent(type)typeA string representing the type of event. In the case of CanMakePaymentEvent this is always canmakepayment.
A developer would not use this constructor manually. A new CanMakePaymentEvent object is constructed when a handler is invoked as a result of the canmakepayment event firing.
self.addEventListener("canmakepayment", (e) => {
e.respondWith(
new Promise((resolve, reject) => {
someAppSpecificLogic()
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
});
}),
);
});