---
title: Upgrade your Checkout integration
description: Upgrade your PayPal integration with the JavaScript SDK for dynamic
  payment buttons, pop-up flows, and better control over button styles.
badges:
  - type: neutral
    text: STANDARD
  - type: neutral
    text: JavaScript SDK v5
---

# Upgrade your Checkout integration (/platforms/checkout/standard/upgrade-integration)



If you have previous checkout integrations, such as Express Checkout or `checkout.js`, PayPal recommends upgrading your integration with the [JavaScript SDK](/sdk/js/configuration/).

The JavaScript SDK has the following benefits:

* Dynamically renders payment buttons instead of using static images.
* Launches payment flow in a pop-up window instead of redirecting to a new page.
* Supports greater control over payment button styles.

> **Warning:** If you want to continue offering Pay Later at checkout, integrate Billing With Purchase, instead. It has the same features as Billing Agreement, but works with the payment options you already have.

## Know before you code [#know-before-you-code]

> **Info:**
>
> ### Get sandbox account information [#get-sandbox-account-information]
>
> Complete the steps in Get started to get the following sandbox account information from the Developer Dashboard:
>
> * Your client ID. Use your client ID when adding payment options to your website.
> * Your personal and business sandbox accounts. Use sandbox accounts to test checkout options.
>
> [Dashboard](/dashboard/)

> **Info:**
>
> ### Explore PayPal APIs with Postman [#explore-paypal-apis-with-postman]
>
> You can use Postman to explore and test PayPal APIs. Learn more in our [Postman guide](/api/rest/postman).

## Payer experience [#payer-experience]

After the payer authorizes the transaction, the payment buttons call your JavaScript callback rather than redirecting the payer to a return URL.

The payer takes the following actions:

1. Selects a payment button.
2. Logs into PayPal.
3. Approves the transaction on PayPal.
4. Returns to your site where you show the payer a confirmation page.

<img src="https://www.paypalobjects.com/devdoc/understanding-new-paypal-checkout-flow.svg" alt="Payer experience" />

## 1. Add payment buttons [#1-add-payment-buttons]

Add the JavaScript SDK and payment buttons to your page.

```html lineNumbers
<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Ensures optimal rendering on mobile devices. -->
</head>

<body>
    <script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID">
        // Replace YOUR_CLIENT_ID with your sandbox client ID
    </script>
    <div id="paypal-button-container"></div>
</body>

</html>
```

### Modify the code [#modify-the-code]

1. Copy the sample code and paste it into the code of your checkout page.
2. Replace `YOUR_CLIENT_ID` with your client ID.

## 2. Update script [#2-update-script]

Update the script tag to pass the [parameters you want for your integration](/sdk/js/configuration/), including:

* The currency of the transaction.
* The intent of the transaction.
* Whether the transaction has a **Pay Now** or a **Continue** button.
* Whether the transaction saves payment methods to the vault.

### Example script: [#example-script]

```html lineNumbers
<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&currency=EUR&intent=order&commit=false&vault=true">
</script>
```

## 3. Set up transaction [#3-set-up-transaction]

When your payer selects the PayPal button, the script calls a `createOrder()` function that you define. In this function, return a promise for a token, payment ID, or order ID from the Orders v2 API.

**Note:** The `createOrder()` function in the JavaScript SDK integration replaces the `payment()` function in the `checkout.js` script.

Migrate the `actions.payment.create()` call to a server-side integration pattern with the create order endpoint.

API endpoint: [Create order](/api/orders/v2/orders-create)

#### HTML createOrder example

```html lineNumbers
<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
    <!-- Replace "TEST" with your own sandbox Business account app client ID -->
    <script src="https://www.paypal.com/sdk/js?client-id=TEST&currency=USD"></script>
    <!-- Set up a container element for the button -->
    <div id="paypal-button-container"></div>
    <script>
        paypal.Buttons({
            // Order is created on the server and the order id is returned
            createOrder() {
                return fetch("/my-server/create-paypal-order", {
                        method: "POST",
                        headers: {
                            "Content-Type": "application/json",
                        },
                        // Use the "body" param to optionally pass additional order information
                        // such as product SKUs and quantities
                        body: JSON.stringify({
                            cart: [{
                                sku: "YOUR_PRODUCT_STOCK_KEEPING_UNIT",
                                quantity: "YOUR_PRODUCT_QUANTITY",
                            }, ],
                        }),
                    })
                    .then((response) => response.json())
                    .then((order) => order.id);
            }
        }).render('#paypal-button-container');
    </script>
</body>

</html>
```

#### node.js createOrder example

```javascript lineNumbers
// For a working example, see:
// https://github.com/paypal-examples/docs-examples/tree/main/standard-integration
const {
    CLIENT_ID,
    APP_SECRET
} = process.env;
const baseURL = {
    sandbox: "https://api-m.sandbox.paypal.com",
    production: "https://api-m.paypal.com"
};

// Allow JSON body
app.use(express.json());

// Create a new order
app.post("/create-paypal-order", async(req, res) => {
    const order = await createOrder();
    res.json(order);
});

//////////////////////
// PayPal API helpers
//////////////////////

// Use the orders API to create an order
async function createOrder() {
    const accessToken = await generateAccessToken();
    const url = `${baseURL.sandbox}/v2/checkout/orders`;
    const response = await fetch(url, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            Authorization: `Bearer ${accessToken}`,
        },
        body: JSON.stringify({
            intent: "CAPTURE",
            purchase_units: [{
                amount: {
                    currency_code: "USD",
                    value: "100.00",
                },
            }, ],
        }),
    });
    const data = await response.json();
    return data;
}

// Generate an access token using client ID and app secret
async function generateAccessToken() {
    const auth = Buffer.from(CLIENT_ID + ":" + APP_SECRET).toString("base64")
    const response = await fetch(`${baseURL.sandbox}/v1/oauth2/token`, {
        method: "POST",
        body: "grant_type=client_credentials",
        headers: {
            Authorization: `Basic ${auth}`,
        },
    });
    const data = await response.json();
    return data.access_token;
}
```

## 4. Finalize payment [#4-finalize-payment]

After your payer logs in to PayPal and approves the transaction, the script calls the `onApprove()` function to finalize the transaction.

**Note:** For server-side REST integrations, the `onAuthorize()` function from the `checkout.js` script is replaced by the `onApprove()` function in the JavaScript SDK integration.

Migrate the `actions.payment.execute()` to a server-side integration with the Orders Capture endpoint. For more information, see [Set up standard payments](/checkout).

API endpoint: [Orders capture](/api/orders/v2/orders-capture)

#### HTML captureOrder example

```html lineNumbers
<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
    <!-- Replace "TEST" with your own sandbox Business account app client ID -->
    <script src="https://www.paypal.com/sdk/js?client-id=TEST&currency=USD"></script>
    <!-- Set up a container element for the button -->
    <div id="paypal-button-container"></div>
    <script>
        paypal.Buttons({
            // Finalize the transaction on the server after payer approval
            onApprove(data) {
                return fetch("/my-server/capture-paypal-order", {
                        method: "POST",
                        body: JSON.stringify({
                            orderID: data.orderID
                        })
                    })
                    .then((response) => response.json())
                    .then((orderData) => {
                        // Successful capture! For dev/demo purposes:
                        console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
                        const transaction = orderData.purchase_units[0].payments.captures[0];
                        alert(`Transaction ${transaction.status}: ${transaction.id}\n\nSee console for all available details`);
                        // When ready to go live, remove the alert and show a success message within this page. For example:
                        // const element = document.getElementById('paypal-button-container');
                        // element.innerHTML = '<h3>Thank you for your payment!</h3>';
                        // Or go to another URL:  window.location.href = 'thank_you.html';
                    });
            }
        }).render('#paypal-button-container');
    </script>
</body>

</html>
```

#### node.js captureOrder example

```javascript lineNumbers
// For a working example, see:
// https://github.com/paypal-examples/docs-examples/tree/main/standard-integration
const {
    CLIENT_ID,
    APP_SECRET
} = process.env;
const baseURL = {
    sandbox: "https://api-m.sandbox.paypal.com",
    production: "https://api-m.paypal.com"
};

// Allow JSON body
app.use(express.json());

// Capture payment & store order information or fulfill order
app.post("/capture-paypal-order", async(req, res) => {
    const {
        orderID
    } = req.params;
    const captureData = await capturePayment(orderID);
    // TODO: store payment information such as the transaction ID
    res.json(captureData);
});

//////////////////////
// PayPal API helpers
//////////////////////

// Use the orders API to capture payment for an order
async function capturePayment(orderId) {
    const accessToken = await generateAccessToken();
    const url = `${baseURL.sandbox}/v2/checkout/orders/${orderId}/capture`;
    const response = await fetch(url, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            Authorization: `Bearer ${accessToken}`,
        },
    });
    const data = await response.json();
    return data;
}

// Generate an access token using client ID and app secret
async function generateAccessToken() {
    const auth = Buffer.from(CLIENT_ID + ":" + APP_SECRET).toString("base64")
    const response = await fetch(`${baseURL.sandbox}/v1/oauth2/token`, {
        method: "POST",
        body: "grant_type=client_credentials",
        headers: {
            Authorization: `Basic ${auth}`,
        },
    });
    const data = await response.json();
    return data.access_token;
}
```

## 5. Fix deprecations [#5-fix-deprecations]

For `checkout.js` integrations, upgrade the deprecated integration to the current integration. Check your browser's JavaScript console for errors to debug issues.

| Deprecated integration                                                                                                                            | Upgrade to integration                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Add a script that points to `paypalobjects.com/api/checkout.js`.<br />                                                                            | Add a script that points to `paypalobjects.com/sdk/js`.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                                 |
| Add a client-side call to `paypal.Button.render({}, '#el');`.<br />                                                                               | Add a client-side call to `paypal.Buttons({}).render('#el');`.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                          |
| Add the `payment()` callback.<br />                                                                                                               | Add the `createOrder()` callback.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                                                       |
| Add the `actions.payment.create()` call.<br />                                                                                                    | Add a server-side call to `/v2/checkout/orders`.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                                        |
| Add the `onAuthorize()` callback.<br />                                                                                                           | Add the `onApprove()` callback.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                                                         |
| Add the `actions.payment.execute()` call.<br />                                                                                                   | Add a server-side call to `/v2/checkout/orders/:id/capture`.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                            |
| Set `style.size` to `small`, `medium`, `large`, and `responsive`.<br />                                                                           | Set the container element to your preferred size.<br />                  See [Customize the payment buttons](/sdk/js/reference/#style).<br />                                                                                                                                                                                                                   |
| Pass the `client` option in the `paypal.Button.render()` call.<br />                                                                              | Pass `client-id=xyz` to the `/sdk/js` script tag.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                                       |
| Pass the `commit: true` or `commit: false` option in the `paypal.Button.render()` call.<br />                                                     | Pass `commit=true` or `commit=false` to the `/sdk/js` script tag.<br />                  See [Commit](/sdk/js/configuration/).<br />                                                                                                                                                                                                                            |
| Pass the `env` option in the `paypal.Button.render()` call.<br />                                                                                 | Pass `client-id=xyz` to the `/sdk/js` script tag and auto-detect the environment.<br />                  See [Client ID](/sdk/js/configuration/).<br />                                                                                                                                                                                                         |
| Pass the `locale` option in the `paypal.Button.render()` call.<br />                                                                              | Pass `locale=xx_XX` to the `/sdk/js` script tag.<br />                  See [Locale](/sdk/js/configuration/).<br />                                                                                                                                                                                                                                             |
| Pass the `style.fundingicons` option in the `paypal.Button.render()` call.<br />                                                                  | The card buttons display automatically in the default integration.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                                      |
| Pass the `funding.allowed` option in the `paypal.Button.render()` call.<br />                                                                     | PayPal automatically decides on the optimal buttons to show to your buyers.<br />                  See [Set up standard payments](/checkout).<br />                                                                                                                                                                                                             |
| Pass the `funding.disallowed` option in the `paypal.Button.render()` call.<br />                                                                  | Pass `disable-funding` or `disable-card` to the `/sdk/js` script tag.<br />                  See [Disable Funding](/sdk/js/configuration/#link-disablefunding) and [Disable card](/sdk/js/configuration/#link-disablecard).<br />                                                                                                                               |
| Use `paypal.request`, `paypal.request.get`, `paypal.request.post`.<br />                                                                          | Use the built-in browser `fetch` function, with a polyfill or your AJAX library of choice.<br />                  See [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).<br />                                                                                                                                                    |
| Use `paypal.Promise`.<br />                                                                                                                       | Use the built-in browser `Promise`, with a polyfill or your promise library of choice.<br />                  See [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises).<br />                                                                                                                                                |
| When you set up transaction, pass return and cancel URLs.<br />                  Call `actions.redirect()` in `onAuthorize` and `onCancel`.<br /> | When you set up transaction, do not pass return and cancel URLs.<br />                  Call ` window.location.href = 'done_page.html'` in `onApprove`.<br />                  Call ` window.location.href = 'cancel_page.html'` in `onCancel`.<br />                  See [Redirect](https://developer.mozilla.org/en-US/docs/Web/API/Request/redirect).<br /> |

## Go live [#go-live]

> **Info:** Go live
>
> Move from PayPal's production environment to go live.
