Web Payments overview

Web Payments are a set of open web platform specifications for integrating digital wallets and other payment methods into checkout on the web. Developed in the W3C Web Payments Working Group, these specifications include the Payment Request API, Payment Handler API, Payment Method Manifest, and Secure Payment Confirmation.

Direct integration with payment providers makes checkout faster and more consistent for users than filling in checkout forms. Users can authorize payments in a few taps using payment credentials and address information already stored with their payment provider.

Illustration of a user tapping a Buy button on a phone to pay with stored payment cards and addresses.

Most checkouts combine the following approaches:

  • Payment apps: A Pay with button calls the Payment Request API to launch a specific payment app, which returns a payment credential.
  • Payment authentication: Card issuers and networks use Secure Payment Confirmation to authenticate payments with WebAuthn.
  • Payment and address forms: Users enter card and address details, helped by browser autofill. See Payment and address form best practices.

Key terms

  • Merchant: The website that sells goods or services and calls the Payment Request API.
  • Payment service provider (PSP): A company that processes payments for merchants, often providing the payment buttons and SDKs that merchants embed.
  • Payment app: A web-based or Android app that handles the payment, such as a digital wallet.
  • Payment method identifier: A URL, such as https://google.com/pay, that identifies a payment method and lets the browser find the payment apps that support it.

How a payment works

A payment with the Payment Request API follows these steps:

  1. The merchant creates a PaymentRequest with a payment method identifier and the transaction details.
  2. The merchant calls canMakePayment() to check whether a payment app is available for that payment method, and shows the payment button only if one is.
  3. When the user clicks the button, the merchant calls show(). The browser launches the payment app.
  4. The user authorizes the payment in the payment app, and show() resolves with a PaymentResponse containing the payment credential.
  5. The merchant validates the credential on its server and calls complete().

The following example shows this flow for a single payment method:

if (window.PaymentRequest) {
  const createRequest = () => new PaymentRequest(
    [{supportedMethods: 'https://bobbucks.dev/pay', data: {/* Method-specific data. */}}],
    {total: {label: 'Total', amount: {currency: 'USD', value: '10.00'}}}
  );

  if (await createRequest().canMakePayment()) {
    payButton.hidden = false;
  }

  payButton.addEventListener('click', async () => {
    let response;
    try {
      // A PaymentRequest can only be shown once, so create a new one per click.
      response = await createRequest().show();
    } catch (error) {
      // Handle show() errors such as AbortError (user canceled) or
      // NotSupportedError (payment method unavailable).
      return;
    }

    let isValid = false;
    try {
      isValid = await validateOnServer(response.methodName, response.details);
    } catch (error) {
      // Handle server validation or network errors.
    }
    await response.complete(isValid ? 'success' : 'fail');
  });
}

If the merchant requests shipping or contact details, the payment app or the browser collects them.

Best practices

  • Use one payment method per button. Render a dedicated button for each payment app you support, and create the PaymentRequest with only that payment method. Chrome can then skip its own Payment Request UI and launch the payment app directly.
  • Know what canMakePayment() checks. It confirms a payment app is available for the method—not that the user has a saved account or card. To check for an enrolled instrument (from the canmakepayment event), Chrome provides hasEnrolledInstrument(), which enforces a query quota and rejects with NotAllowedError if exceeded.
  • Call show() directly from the click handler. show() consumes transient user activation, while canMakePayment() doesn't. Avoid calling other activation-consuming APIs (such as window.open()) or awaiting unrelated async work before show(), or show() can reject with a SecurityError.
  • Pass a promise to show() if the total isn't known yet. The browser shows a loading indicator until the promise resolves with the final details.
  • Provide total in the payment details. For most payment methods, the PaymentRequest constructor requires total (throwing a TypeError if omitted), even if the payment app calculates its own pricing.
  • Validate on your server. Treat response.details as untrusted until your server or PSP verifies it.
  • Allow payment in cross-origin iframes. If a cross-origin iframe creates a PaymentRequest—including for Secure Payment Confirmation—add allow="payment" to the <iframe> element to enable the payment Permissions Policy. Without it, the PaymentRequest constructor throws a SecurityError.

Browser support

Web Payments APIs have limited browser availability, so always feature detect and provide a fallback such as checkout forms or your PSP's web checkout flow.

Payment Request API

Payment Handler API

Secure Payment Confirmation

Where to start