W3cubDocs

/Web APIs

CanMakePaymentEvent

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The CanMakePaymentEvent interface of the Payment Handler API 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 new PaymentRequest().

Event ExtendableEvent CanMakePaymentEvent

Constructor

CanMakePaymentEvent() Experimental

Creates a new CanMakePaymentEvent object instance.

Instance methods

respondWith() Experimental

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

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
CanMakePaymentEvent 70 79 No No 57 No No 70 No 49 No 10.0
CanMakePaymentEvent 70 79 No No 57 No No 70 No 49 No 10.0
methodData 70–111 79–111 No No 57–97 No No 70–111 No 49 No 10.0–22.0
modifiers 70–111 79–111 No No 57–97 No No 70–111 No 49 No 10.0–22.0
paymentRequestOrigin 70–111 79–111 No No 57–97 No No 70–111 No 49 No 10.0–22.0
respondWith 70 79 No No 57 No No 70 No 49 No 10.0
topOrigin 70–111 79–111 No No 57–97 No No 70–111 No 49 No 10.0–22.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CanMakePaymentEvent