CanMakePaymentEvent: CanMakePaymentEvent() constructor
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is only available in Service Workers.
The CanMakePaymentEvent() constructor creates a new CanMakePaymentEvent object instance.
Syntax
js
new CanMakePaymentEvent(type)
Parameters
type-
A string representing the type of event. In the case of
CanMakePaymentEventthis is alwayscanmakepayment.
Examples
A developer would not use this constructor manually. A new CanMakePaymentEvent object is constructed when a handler is invoked as a result of the canmakepayment event firing.
js
self.addEventListener("canmakepayment", (e) => {
e.respondWith(
new Promise((resolve, reject) => {
someAppSpecificLogic()
.then((result) => {
resolve(result);
})
.catch((error) => {
reject(error);
});
}),
);
});
Specifications
| Specification |
|---|
| Web-based Payment Handler API # dom-canmakepaymentevent-constructor |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CanMakePaymentEvent() constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.