> ## Documentation Index
> Fetch the complete documentation index at: https://firmly.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Start PayPal Checkout

> Creates a PayPal Express Checkout order and returns the PayPal token and approval URL

## Overview

Initiates a PayPal checkout by creating a PayPal Express Checkout order on the merchant. Returns the cart enriched with a `payment_method` object containing the PayPal EC `paypal_token` and the PayPal approval `url`. The buyer approves the payment on PayPal (via the PayPal SDK button or by opening the approval URL); the approval returns a `payer_id` and `paypal_token` that you pass to [Authorize](https://firmly.mintlify.site/api-reference/payment/express-checkout/authorize-paypal.md).

> [!NOTE]
>
> PayPal is enabled per merchant. Check the cart's `payment_method_options` array for `{ "type": "PayPal", "wallet": "paypal", "config": { ... } }` before offering PayPal; `config` carries the PayPal SDK settings (`clientId`, `merchantId`, `sandbox`, `intent`, `integration_version`, `mode`).

## Authentication

**x-firmly-authorization** `string` *required*

Device authentication token from Browser Session

## Path Parameters

**domain** `string` *required*

The merchant domain (e.g., "merchant.example.com")

## Request Body

**attributes** `object`

Optional gateway-specific attributes. Omit or send an empty object for PayPal.

## Response

Returns the cart enriched with the PayPal payment method.

**cart\_id** `string`

Unique identifier for the cart

**line\_items** `array`

Array of items in the cart

**payment\_method** `object`

PayPal payment method details

**Payment Method**

**payment\_type** `string`

The gateway identifier for PayPal

**attributes** `object`

PayPal checkout credentials

**Attributes**

**paypal\_token** `string`

The PayPal Express Checkout token. Used as the PayPal SDK `createOrder` id.

**url** `string`

The PayPal approval URL. Server-redirect merchants open this in a popup for the buyer to approve; SDK-button merchants render the button and ignore this field.

**sandbox** `boolean`

Whether the PayPal sandbox environment is in use

**total** `object`

Grand total including all costs

**sub\_total** `object`

Subtotal before shipping and tax

## Code Example

```javascript JavaScript theme={null}
const response = await fetch(
  'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start',
  {
    method: 'POST',
    headers: {
      'x-firmly-authorization': authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ attributes: {} })
  }
);

const cart = await response.json();
const paypalToken = cart.payment_method.attributes.paypal_token;
// Pass paypalToken to the PayPal SDK createOrder(), or open attributes.url to approve
```

```python Python theme={null}
import requests

response = requests.post(
    'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start',
    headers={
        'x-firmly-authorization': auth_token,
        'Content-Type': 'application/json'
    },
    json={'attributes': {}}
)

cart = response.json()
paypal_token = cart['payment_method']['attributes']['paypal_token']
```

```bash cURL theme={null}
curl -X POST https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/start \
  -H "x-firmly-authorization: YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"attributes": {}}'
```

## Response Example

```json theme={null}
{
  "cart_id": "9cf76530-1344-420f-9ca6-c7a96fb6db45",
  "line_items": [
    {
      "line_item_id": "3e66bef5-43f5-4a80-8957-91c5c8233163",
      "sku": "MT12",
      "quantity": 1,
      "description": "Cassius Sparring Tank",
      "price": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" },
      "line_price": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
    }
  ],
  "payment_method": {
    "payment_type": "paypal",
    "attributes": {
      "paypal_token": "EC-25M07043P9951254S",
      "url": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-25M07043P9951254S",
      "sandbox": true
    }
  },
  "sub_total": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" },
  "total": { "currency": "USD", "value": 18, "number": 1800, "symbol": "$" }
}
```

## Error Responses

| Code | Description |
| - | - |
| `ErrorCartNotFound` | No active cart for this domain |
| `ErrorGatewayNotFound` | PayPal is not enabled for this merchant |
| `ErrorOperationNotSupported` | Merchant adapter does not support PayPal express checkout |
| `ErrorStartExpressCheckout` | PayPal failed to create the Express Checkout order |
| `ErrorStoreUnavailable` | Merchant temporarily unavailable |
| `ErrorRateLimited` | Too many requests |

## Related Endpoints

* [Authorize PayPal Checkout](https://firmly.mintlify.site/api-reference/payment/express-checkout/authorize-paypal.md) - Confirm after buyer approval
* [Complete PayPal Order](https://firmly.mintlify.site/api-reference/payment/express-checkout/complete-order-paypal.md) - Finalize the order


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.