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 respondWith() method of the CanMakePaymentEvent interface enables the service worker to respond appropriately to signal whether it is ready to handle payments.
respondWith(response)responseA Promise that resolves with a boolean value to signal that it is ready to handle a payment request: (true), or not (false).
None (undefined).
self.addEventListener("canmakepayment", (e) => {
e.respondWith(
new Promise((resolve, reject) => {
someAppSpecificLogic()
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
});
}),
);
});