Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. CanMakePaymentEvent

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.

Event ExtendableEvent CanMakePaymentEvent

Constructor

CanMakePaymentEvent()Experimental

Creates a newCanMakePaymentEvent 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

Specification
Payment Handler API
# the-canmakepaymentevent

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp