> ## 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.

# Authorize PayPal Checkout

> Confirms the PayPal payment after buyer approval and stores the PayPal credentials for Complete Order

## Overview

After the buyer approves the payment on PayPal, this endpoint confirms the authorization with Firmly. It stores the PayPal credentials (`paypal_token`, `payer_id`) in the checkout session so [Complete Order](https://firmly.mintlify.site/api-reference/payment/express-checkout/complete-order-paypal.md) can place the order, and returns the current cart.

Whether the buyer's PayPal-selected shipping and billing address is pulled onto the cart at this step depends on the merchant integration: some integrations retrieve it from PayPal and apply it here, others only record the credentials and leave the cart's address unchanged. Read `shipping_info` and `billing_info` from the response as the address currently on the cart; do not assume they reflect the address the buyer chose on PayPal.

> [!NOTE]
>
> This step can be skipped: [Complete Order](https://firmly.mintlify.site/api-reference/payment/express-checkout/complete-order-paypal.md) will authorize automatically before placing the order, as long as `paypal_token` and `payer_id` are provided. Call authorize explicitly when you want to show the cart to the buyer before the final step.

## 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` *required*

PayPal authorization details

**Attributes**

**paypal\_token** `string` *required*

The PayPal Express Checkout token returned by [Start](https://firmly.mintlify.site/api-reference/payment/express-checkout/start-paypal.md). Also accepted as `paypalToken`.

**payer\_id** `string` *required*

The PayPal payer id returned to the client after the buyer approves the payment. Also accepted as `payerId`.

## Response

Returns the cart with the PayPal credentials recorded on `payment_method`.

**cart\_id** `string`

Unique identifier for the cart

**line\_items** `array`

Array of items in the cart

**payment\_method** `object`

Confirmed PayPal payment method

**Payment Method**

**payment\_type** `string`

The gateway identifier for PayPal

**attributes** `object`

PayPal authorization details

**Attributes**

**paypal\_token** `string`

The PayPal Express Checkout token

**payer\_id** `string`

The confirmed PayPal payer id

**shipping\_info** `object`

Delivery address currently on the cart. Reflects the PayPal-selected address only for merchant integrations that apply it at this step.

**billing\_info** `object`

Billing address currently on the cart, when present. Reflects the PayPal billing address only for merchant integrations that apply it at this step.

**total** `object`

Grand total including all costs

## Code Example

```javascript JavaScript theme={null}
// After the buyer approves on PayPal (payerId + paypal token returned to the client)
const response = await fetch(
  'https://api.firmly.work/api/v1/domains/merchant.example.com/express/paypal/authorize',
  {
    method: 'POST',
    headers: {
      'x-firmly-authorization': authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      attributes: {
        paypal_token: 'EC-25M07043P9951254S',
        payer_id: 'QYR5Z8XZ5JX6N'
      }
    })
  }
);

const cart = await response.json();
// Credentials are stored; cart.shipping_info is the address currently on the cart
// (PayPal's address only if this merchant integration applies it here). Proceed to complete order
```

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

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

cart = response.json()
```

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

## 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",
      "payer_id": "QYR5Z8XZ5JX6N"
    }
  },
  "shipping_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "phone": "2065551212",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "billing_info": {
    "first_name": "John",
    "last_name": "Smith",
    "email": "john@example.com",
    "address1": "123 Main St",
    "city": "Seattle",
    "state_or_province": "WA",
    "country": "US",
    "postal_code": "98101"
  },
  "total": { "currency": "USD", "value": 30, "number": 3000, "symbol": "$" }
}
```

## Error Responses

| Code | Description |
| - | - |
| `ErrorCartNotFound` | No active cart for this domain |
| `ErrorBadRequest` | Missing `paypal_token` or `payer_id` |
| `ErrorGatewayNotFound` | PayPal is not enabled for this merchant |
| `ErrorPaymentMethodNotAvailable` | PayPal is not available for this cart |
| `ErrorPrecondition` | Precondition failed (e.g., cart state invalid) |
| `ErrorSubmitExpressCheckout` | Authorization failed at PayPal or the merchant |
| `ErrorRateLimited` | Too many requests |

## Related Endpoints

* [Start PayPal Checkout](https://firmly.mintlify.site/api-reference/payment/express-checkout/start-paypal.md) - Create the PayPal order first
* [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.