---
updatedAt: 2026-08-28T06:44:55.000Z
agentTools:
  projectIndex: https://developer.peachpayments.com/llms.txt
---

# Embed checkout in your website

# Tutorial

<Callout icon="📘" theme="info">
- The Embedded Checkout sample projects for [Node](https://gitlab.com/p2886/checkout-samples/-/tree/main/node/Embedded%20Checkout) and [Python](https://gitlab.com/p2886/checkout-samples/-/tree/main/python/Embedded%20Checkout) enable you to experiment with Embedded Checkout and produce a working prototype with minimal changes.
- To support Apple Pay on Embedded Checkout, follow [these instructions](https://developer.peachpayments.com/docs/checkout-embedded#apple-pay).
- The authentication service URL and other service URLs are available in the [API endpoints](https://developer.peachpayments.com/docs/checkout-embedded#api-endpoints) section.
</Callout>

Follow these instructions to embed checkout in your website:

1. [Generate an access token](https://developer.peachpayments.com/docs/checkout-embedded-authentication) by executing a POST `{peach-auth-service}/api/oauth/token` request with your client ID, client secret, and merchant ID.

   ```curl
   curl --location --request POST '{peach-auth-service}/api/oauth/token' 
   --header 'content-type: application/json' 
   --data-raw 
   '{
       "clientId": "{clientId}",
       "clientSecret": "{clientSecret}",
       "merchantId": "{merchantId}"
   }'
   ```

2. [Create a checkout instance](https://developer.peachpayments.com/reference/post_v2-checkout) by executing a POST `{checkout-endpoint}/v2/checkout` request with the JWT retrieved from the above call.

   <Callout icon="📘" theme="info">
     Embedded Checkout:

     - Requires a [unique nonce](https://developer.peachpayments.com/docs/checkout-embedded-authentication#uniqueness-of-request) for each request made to the `/v2/checkout` endpoint.
     - Requires that you [allowlist URL domains that execute the API POST request](https://developer.peachpayments.com/docs/checkout-embedded-authentication#allowlist-domains) to Checkout for added security.
     - Can [tokenise cards and digital wallets](https://developer.peachpayments.com/docs/checkout-tokenisation).
   </Callout>

3. Create the payment form by including the script tag on your HTML page.

   <Callout icon="🚧" theme="warn">
     - If your website uses a Content Security Policy (CSP), you must add the required directives from the [Embedded Checkout CSP directives list](https://developer.peachpayments.com/docs/checkout-embedded-sdk-reference#required-csp-directives) to your policy.
     - You must set a height for the element with the `checkout-root` ID:

       - Minimum: 640 pixels
       - Fill the container: `100%`
       - Only element on the page: `100vh` to fill the screen height
   </Callout>

   ```html
   <html>
   <head>
   </head>
   <body>
   <div id="payment-form"></div>
   <script src="https://sandbox-checkout.peachpayments.com/js/checkout.js"></script>
   </body>
   ```

4. Ensure that the checkout script from step 3 is fully loaded and then instantiate Embedded Checkout using your entity ID and the checkout ID.

   <Callout icon="❗" theme="error">
     If the script is **not** fully loaded, your customers might receive `Checkout not found` errors and be unable to pay.
   </Callout>

   ```javascript
   <script>
     const checkout = Checkout.initiate({
       key: <entity id>,
       checkoutId: <Checkout Id>,
    });

     checkout.render("#payment-form");
   </script>
   ```

5. Get the status of the checkout from [Embedded Checkout events](https://developer.peachpayments.com/docs/checkout-embedded-sdk-reference#events).

   ```javascript
   const checkout = Checkout.initiate({
     key: <entity id>,
     checkoutId: <Checkout Id>,
     events: {
       onCompleted: (event) => console.log(event),
       onCancelled: (event) => console.log(event),
       onExpired: (event) => console.log(event),
     },
   });
   ```

6. [Theme Embedded Checkout](https://developer.peachpayments.com/docs/checkout-embedded-sdk-reference#theming).

   ```javascript
   const checkout = Checkout.initiate({
     key: "<entity id>",
     checkoutId: "<Checkout Id>",
     options: {
       theme: {
         brand: {
           primary: "#ff0000",
         },
         cards: {
           background: "#00ff00",
           backgroundHover: "#F3F3F4",
         }
       },
     },
   });
   ```

7. [Customise the availability and order of payment methods](https://developer.peachpayments.com/docs/checkout-embedded-sdk-reference#customise-payment-method-availability-and-order).

   ```javascript
   const checkout = Checkout.initiate({
     key: "<entity id>",
     checkoutId: "<Checkout Id>",
     options: {
       ordering: {
         PAYFLEX: 1,
         CARD: 2,
       },
     },
   });
   ```

# Consolidated example snippet

The following snippet provides an example of the complete HTML page:

```html
<html>
  <head> </head>
  <body>
    <div id="payment-form"></div>
    <script src="https://sandbox-checkout.peachpayments.com/js/checkout.js"></script>

    <script>
      const checkout = Checkout.initiate({
        key: "{entityId}",
        checkoutId: "{checkoutId}",
        options: {
          theme: {
            brand: {
              primary: "#ff0000",
            },
            cards: {
              background: "#00ff00",
              backgroundHover: "#F3F3F4",
            },
          },
        },
      });

      checkout.render("#payment-form");
    </script>
  </body>
</html>
```

<Callout icon="🚧" theme="warn">
Running the local HTML page in your browser only renders the Checkout instance; you can view the payment methods but cannot attempt a payment. To attempt a payment, you must host the HTML page.
One way to do this locally is by using Python's [`http.server`](https://docs.python.org/3/library/http.server.html) functionality, for example, by executing `python -m http.server 8000` from the HTML file's directory, and then opening `http://localhost:8000/file.html` in your browser.
</Callout>

# Embedded Express

Embedded Express is a wallet-only variant of Embedded Checkout that displays Apple Pay, Google Pay, and Samsung Pay only. Use Embedded Express to offer a quick, one-click payment experience by surfacing free-standing wallet buttons earlier, saving clicks, without the full Checkout user interface.

<Callout icon="🚧" theme="warn">
- To accept wallet payments through Embedded Express, ensure that your Peach Payments account includes [support for Apple Pay, Google Pay, and Samsung Pay](https://developer.peachpayments.com/docs/manage-payment-methods#activate-a-payment-method), or whichever wallets you want to offer.
- Embedded Express does not support [Apple Pay](https://developer.peachpayments.com/docs/pp-payment-methods#apple-pay) or [Samsung Pay](https://developer.peachpayments.com/docs/pp-payment-methods#samsung-pay) on all devices or browsers.
</Callout>

Customers who want to pay with a different payment method can still navigate to the full Embedded Checkout from the same checkout instance.

## When to use Embedded Express

Use Embedded Express when you want to:

* Surface free-standing wallet buttons earlier in the customer journey, saving clicks and reducing the steps to purchase.
* Increase conversion by offering one-click payment for customers who have already set up a wallet on their device.
* Continue to offer non-wallet payment methods through the full [Embedded Checkout](https://developer.peachpayments.com/docs/checkout-embedded) experience as a fallback.

Use [Embedded Checkout](https://developer.peachpayments.com/docs/checkout-embedded) when you want to show the complete set of configured payment methods in a single embedded experience.

## Enable Embedded Express

Embedded Express uses the same authentication, checkout creation, and rendering flow as Embedded Checkout. To enable Embedded Express, call `Checkout.express` instead of `Checkout.initiate` when instantiating the Checkout object.

See the [SDK reference](https://developer.peachpayments.com/docs/checkout-embedded-sdk-reference#overview) for details on which options Embedded Express supports. Embedded Express does not support any [customisations](https://developer.peachpayments.com/docs/checkout-embedded#customisations), aside from the event handlers.

Instantiate the Checkout object with `Checkout.express`:

```javascript
const checkout = Checkout.express({
  key: "<entity id>",
  checkoutId: "<Checkout Id>",
  requiresShipping: true, // optional; see Collect a shipping address
});

checkout.render("#payment-form");
```

## Collect a shipping address

Embedded Express can capture the customer's shipping address and contact details from Apple Pay and forward them to you. This is useful when you need a delivery address but do not want to add a separate address form to your checkout.

To enable this, set `requiresShipping` to `true` when you instantiate Embedded Express, as shown in [Enable Embedded Express](https://developer.peachpayments.com/docs/checkout-embedded-tutorial#enable-embedded-express).

When `requiresShipping` is `true`:

* Apple Pay requests the customer's postal address, name, email, and phone number.
* After the customer authorises the payment, Peach Payments forwards the captured shipping details to you in the [Checkout webhook](https://developer.peachpayments.com/docs/checkout-webhooks#checkout-successful). To use the shipping details, update your webhook handling to read the `shipping` fields.

When `requiresShipping` is `false` or you omit it, Apple Pay does not request address or contact details, and the payment behaviour does not change.