dom / latest / paymentrequest.html /

PaymentRequest

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The Payment Request API's PaymentRequest interface is the primary access point into the API, and lets web content and apps accept payments from the end user on behalf of the operator of the site or the publisher of the app.

EventTarget PaymentRequest

Constructor

PaymentRequest() Secure context

Creates a new PaymentRequest object.

Properties

PaymentRequest.id Read only Secure context

An unique identifier for a particular PaymentRequest, which can be set via details.id. When none is set, it defaults to a UUID.

PaymentRequest.shippingAddress Read only Secure context Deprecated

If requested via payment options, returns the shipping address chosen by the user for the purposes of calculating shipping. This property is only populated if the constructor is called with the requestShipping flag set to true. Additionally, in some browsers, the parts of the address will be redacted for privacy until the user indicates they are ready to complete the transaction (i.e., they hit "Pay").

PaymentRequest.shippingOption Read only Secure context Deprecated

Returns the identifier of the selected shipping option. This property is only populated if the constructor is called with the requestShipping flag set to true.

PaymentRequest.shippingType Read only Secure context Deprecated

Returns the type of shipping used to fulfill the transaction. This will be one of shipping, delivery, pickup, or null if a value was not provided in the constructor.

Methods

PaymentRequest.canMakePayment() Secure context

Indicates whether the PaymentRequest object can make a payment before calling show().

PaymentRequest.show() Secure context

Causes the user agent to begin the user interaction for the payment request.

PaymentRequest.abort() Secure context

Causes the user agent to end the payment request and to remove any user interface that might be shown.

Events

merchantvalidation Secure context

With some payment handlers (e.g., Apple Pay), this event handler is called to handle the merchantvalidation event, which is dispatched when the user agent requires that the merchant validate that the merchant or vendor requesting payment is legitimate.

paymentmethodchange Secure context

With some payment handlers (e.g., Apple Pay), dispatched whenever the user changes payment instrument, like switching from a credit card to a debit card.

shippingaddresschange Secure context Deprecated

Dispatched whenever the user changes their shipping address.

shippingoptionchange Secure context Deprecated

Dispatched whenever the user changes a shipping option.

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
PaymentRequest
60
15
55
No
47
11.1
No
53
No
44
11.3
6.0
PaymentRequest
60
15
55
No
47
11.1
No
53
No
44
11.3
6.0
abort
60
15
55
No
47
11.1
No
53
No
44
11.3
6.0
canMakePayment
60
16
55
No
47
11.1
No
53
No
44
11.3
6.0
id
60
16
55
No
47
11.1
No
60
No
44
11.3
8.0
merchantvalidation_event
No
No
55
No
No
11.1
No
No
No
No
11.3
No
paymentmethodchange_event
76
79
55
No
47
12.1
No
76
No
44
12.2
12.0
shippingAddress
61
15
55
No
47
No
No
53
No
44
No
6.0
shippingaddresschange_event
61
15
55
No
47
11.1
No
53
No
44
11.3
6.0
shippingOption
60
15
55
No
47
11.1
No
53
No
44
11.3
6.0
shippingoptionchange_event
61
15
55
No
47
11.1
No
53
No
44
11.3
6.0
shippingType
60
15
55
No
47
11.1
No
55
No
44
11.3
6.0
show
60
15
55
No
47
11.1
No
53
No
44
11.3
6.0

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