> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.buqipi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkouts

> Tokenize a card, charge it and create the reservation only after payment.

A checkout is a payment intent, not a reservation.

## 1. Create the checkout

`POST /checkouts` prices the stay and returns:

```json theme={null}
{
  "data": {
    "id": "BKPRYB3N9BG9R",
    "status": "requires_tokenization",
    "amount": 143.1,
    "currency": "EUR",
    "requires_payment": true,
    "return_url": "https://partner.example.com/booking/return",
    "expires_at": "2026-11-17T17:10:19+01:00",
    "tokenizer": {
      "provider": "paynopain",
      "script_url": "https://pci-proxy-api.paynopain.com/sandbox/client.js",
      "token": "...",
      "external_id": "BKPRYB3N9BG9R"
    }
  }
}
```

The partner backend should pass only `script_url`, `token` and `external_id` to its browser.

## 2. Tokenize the card

Load `script_url` and initialize PaynoPain ProxyFields with the tokenizer token. Submit the card fields from the browser. Card data never reaches Buqipi or the partner backend.

## 3. Charge

```http theme={null}
POST /checkouts/{id}/charge
Idempotency-Key: optional-retry-key
```

The server revalidates price and availability, retrieves the tokenized card by `external_id`, and launches the payment.

Possible states:

* `succeeded` / `completed`: payment accepted and reservation created.
* `requires_action`: open `action.url` for 3DS.
* `processing`: the provider is still confirming; poll or call `complete`.
* `failed`: no reservation was created.

## 4. Return from 3DS

Buqipi appends `checkout_id` and `status=ok|ko` to the partner `return_url`. The partner calls:

```http theme={null}
POST /checkouts/{id}/complete
Idempotency-Key: optional-retry-key
```

The reservation is created only when payment is confirmed.

## Idempotency

* `external_ref` is unique per API client and cannot belong to another booking.
* Reusing `Idempotency-Key` with a different body returns `buqipi.connect.idempotency_conflict`.
* A completed checkout returns its booking on retry.


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