PaymentRequestEvent: PaymentRequestEvent() constructor
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 PaymentRequestEvent constructor creates a new PaymentRequestEvent object instance.
Syntax
new PaymentRequestEvent(type)
new PaymentRequestEvent(type, options)
Parameters
type-
A string with the name of the event. It is case-sensitive and browsers set it to
paymentrequest. optionsOptional-
An object that, in addition of the properties defined in
ExtendableEvent(), can have the following properties:methodData-
An array of
PaymentMethodDataobjects (seemethodData> Value) containing payment method identifiers for the payment methods that the website accepts and any associated payment method-specific data. modifiers-
An array of objects containing changes to payment details.
paymentRequestId-
The ID of the
PaymentRequestobject. paymentRequestOrigin-
The origin where the
PaymentRequestobject was initialized. topOrigin-
The top-level origin where the
PaymentRequestobject was initialized. total-
The total amount being requested for payment.
Return value
A new PaymentRequestEvent object.
Examples
A developer would not use this constructor manually. A new PaymentRequestEvent object is constructed when a handler is invoked as a result of the paymentrequest event firing.
self.addEventListener("paymentrequest", (e) => {
// ...
});
Specifications
| Specification |
|---|
| Payment Handler API # dom-paymentrequestevent-constructor |
Browser compatibility
| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
PaymentRequestEvent() constructor | |||||||||||