Web/API/Payment Request API

From Get docs

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


The Payment Request API provides a consistent user experience for both merchants and users. It is not a new way for paying for things; rather, it's a way for users to select their preferred way of paying for things, and make that information available to a merchant.

Payment Request concepts and usage

Many problems related to online shopping-cart abandonment can be traced to checkout forms, which can be difficult and time consuming to fill out and often require multiple steps to complete. The Payment Request API is meant to reduce the number of steps needed to complete a payment online, potentially doing away with checkout forms. It aims to make the checkout process easier, by remembering a user's details, which are then passed along to a merchant hopefully without requiring a HTML form.

Advantages of using the Payment Request API with "basic-card" (card-based payments):

  • Fast purchase experience: Users enter their details once into the browser and are then ready to pay for goods and services on the web. They no longer have to fill out the same details repeatedly across different sites.
  • Consistent experience on every site (that supports the API): As the payment sheet is controlled by the browser, it can tailor the experience to the user. This can include localizing the UI into the user's preferred language.
  • Accessibility: As the browser controls the input elements of the payment sheet, it can assure consistent keyboard and screen reader accessibility on every website without developers needing to do anything. A browser could also adjust the font size or color contrast of the payment sheet, making it more comfortable for the user to make a payment.
  • Credentials management: Users can manage their credit cards and shipping addresses directly in the browser. A browser can also sync these "credentials" across devices, making it easy for users to jump from desktop to mobile and back again when buying things.
  • Consistent error handling: The browser can check the validity of card numbers, and can tell the user if a card has expired (or is about to expire). The browser can automatically suggest which card to use based on past usage patterns or restrictions from the merchant (e.g, "we only accept Visa or Mastercard"), or allow the user to say which is their default/favorite card.

To request a payment, a web page creates a PaymentRequest object in response to a user action that initiates a payment, such as clicking a "Purchase" button. The PaymentRequest allows the web page to exchange information with the user agent while the user provides input to complete the transaction.

You can find a complete guide in Using the Payment Request API.

Note: The API is available inside cross-origin <iframe> elements only if they have had the allowpaymentrequest attribute set on them.


Interfaces

PaymentAddress
An object that contains address information; used for billing and shipping addresses, for example.
PaymentRequest
An object that provides the API for creating and managing the user agent's payment interface.
PaymentRequestEvent
An event delivered to a payment handler when a PaymentRequest is made.
PaymentRequestUpdateEvent
Enables the web page to update the details of the payment request in response to a user action.
PaymentMethodChangeEvent
Represents the user changing payment instrument (e.g., switching from a credit card to debit card).
PaymentResponse
An object returned after the user selects a payment method and approves a payment request.
MerchantValidationEvent
Represents the browser requiring the merchant (website) to validate themselves as allowed to use a particular payment handler (e.g., registered as allowed to use Apple Pay).

Dictionaries

AddressErrors
A dictionary containing strings providing descriptive explanations of any errors in any PaymentAddress entries which have errors.
PayerErrors
A dictionary containing strings providing descriptive explanations of any errors in related to PaymentResponse's email, phone, and name attributes.
PaymentDetailsUpdate
An object describing changes that need to be made to the payment details in the event that the server needs to update information following the instantiation of the payment interface but before the user begins to interact with it.

Related dictionaries for the Basic Card specification

BasicCardChangeDetails
An object providing redacted address information that is provided as the methodDetails on the paymentmethodchange event sent to the PaymentRequest when the user changes payment information.
BasicCardErrors
An object providing any error messages associated with the fields in the BasicCardResponse object that are not valid. This is used as the value of the paymentMethod property on the PaymentValidationErrors object sent to the PaymentRequest when an error occurs.
BasicCardRequest
Defines an object structure for containing payment request details such as card type.
BasicCardResponse
Defines an object structure for payment response details such as the number/expiry date of the card used to make the payment, and the billing address.

Specifications

Specification Status Comment
Payment Request API Candidate Recommendation Initial definition.
Basic Card Payment Working Draft Defines BasicCardRequest and BasicCardResponse, among other things needed for handling credit card payment
Payment Method Identifiers Candidate Recommendation Defines payment method identifiers and how they are validated, and, where applicable, minted and formally registered with the W3C.

Browser compatibility

PaymentRequest interface

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PaymentRequest Chrome

Full support 60

Edge

Full support 15

Firefox No support No

Notes'

No support No

Notes'

Notes' Available only in nightly builds. Requires dom.payments.request.enabled to be set to true and the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.

IE

No support No

Opera

Full support 47

Safari

Full support 11.1

WebView Android

No support No

Chrome Android

Full support 53

Firefox Android No support No

Notes'

No support No

Notes'

Notes' Available only in nightly builds. Requires dom.payments.request.enabled to be set to true and the comma-delineated list in dom.payments.request.supportedRegions to contain one or more of the supported 2-character ISO locales, currently US and CA.

Opera Android

Full support 44

Safari iOS

Full support 11.3

Samsung Internet Android

Full support 6.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.'
See implementation notes.


See also