CanMakePaymentEvent
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Note: This feature is only available inService Workers.
TheCanMakePaymentEvent interface of thePayment Handler API is the event object for thecanmakepayment event, fired on a payment app's service worker to check whether it is ready to handle a payment. Specifically, it is fired when the merchant website calls thePaymentRequest() constructor.
In this article
Constructor
CanMakePaymentEvent()ExperimentalCreates a new
CanMakePaymentEventobject instance.
Instance methods
respondWith()ExperimentalEnables the service worker to respond appropriately to signal whether it is ready to handle payments.
Examples
js
self.addEventListener("canmakepayment", (e) => { e.respondWith( new Promise((resolve, reject) => { someAppSpecificLogic() .then((result) => { resolve(result); }) .catch((error) => { reject(error); }); }), );});Specifications
| Specification |
|---|
| Payment Handler API> # the-canmakepaymentevent> |