Web-Based Payment Handler APIservice
The CanMakePaymentEvent() constructor creates a new CanMakePaymentEvent object instance.
Syntax
new CanMakePaymentEvent(type)
Parameters
type- : A string representing the type of event. In the case of
CanMakePaymentEventthis is alwayscanmakepayment.
- : A string representing the type of event. In the case of
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 ServiceWorkerGlobalScope.canmakepayment_event event firing.
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 Handler API
- Web-based payment apps overview
- Setting up a payment method
- Life of a payment transaction
- Using the Payment Request API
- Payment processing concepts
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
