e01.org

CanMakePaymentEvent: respondWith() method

Web-Based Payment Handler APIservice

Web-Based Payment Handler APIservice

The **`respondWith()`** method of the CanMakePaymentEvent interface enables the service worker to respond appropriately to signal whether it is ready to handle payments.

## Syntax

```js-nolint
respondWith(response)
```

### Parameters

- `response`
- : A Promise that resolves with a boolean value to signal that it is ready to handle a payment request: (`true`), or not (`false`).

### Return value

None (`undefined`).

## 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)

source: MDN Web Docs mirror · page

Cite this

"CanMakePaymentEvent: respondWith() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CanMakePaymentEvent/respondWith

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy