CanMakePaymentEvent
Web-Based Payment Handler APIservice
Web-Based Payment Handler APIservice
The **`CanMakePaymentEvent`** interface of the is the event object for the canmakepayment 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 the PaymentRequest() constructor.
## Constructor
- CanMakePaymentEvent()
- : Creates a new `CanMakePaymentEvent` object instance.
## Instance methods
- respondWith()
- : Enables 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
## Browser compatibility
## See also
-
- [Web-based payment apps overview](https://web.dev/articles/web-based-payment-apps-overview)
- [Setting up a payment method](https://web.dev/articles/setting-up-a-payment-method)
- [Life of a payment transaction](https://web.dev/articles/life-of-a-payment-transaction)
- [Using the Payment Request API](/docs/Web/API/Payment_Request_API/Using_the_Payment_Request_API)
- [Payment processing concepts](/docs/Web/API/Payment_Request_API/Concepts)
Cite this
"CanMakePaymentEvent". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CanMakePaymentEvent JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy