# Checkouts

Once you’ve created a checkout, then you can either share the hosted link or embed the checkout directly on your website. It will also determine the amount required in customer selected cryptocurrency.

Once paid, the payment is captured, the cryptocurrency will then be converted and credited into the balance of the merchant account and can be withdrawn anytime.

#### The Checkout Object

| Name                | Type   | Description                                                                                           |
| ------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| id                  | Number | Unique identifier for the object                                                                      |
| uuid                | UUID   | A UUID (Universal Unique Identifier) is a 128-bit value used to uniquely identify an object or entity |
| currency            | String | The Checkout default  currency: alphabetic currency code                                              |
| trackingId          | String | Client-provided identifier of the payment in the external system                                      |
| walletId            | Number | Wallet id to accept payment in                                                                        |
| logoUrl             | String | Client-provided logo url for the checkout page                                                        |
| expectedQuoteAmount | String | Expected quote currency amount to be paid                                                             |
| includedCurrencyIds | Array  | Array of currencies available for the current  checkout page                                          |
| ExcludedCurrencyIds | Array  | Array of currencies to exclude from the checkout page                                                 |
| createdAt           | Date   | Time at which the object was created                                                                  |
| checkoutUrl         | String | A checkout URL to use it as iframe or separated page to deposit crypto                                |

## Create a Checkout

<mark style="color:green;">`POST`</mark> `/api/v2/checkouts/create`&#x20;

Creates new checkout page&#x20;

#### Headers

| Name                                     | Type             | Description |
| ---------------------------------------- | ---------------- | ----------- |
| Accept<mark style="color:red;">\*</mark> | application/json |             |

#### Request Body

| Name                                         | Type   | Description                                                      |
| -------------------------------------------- | ------ | ---------------------------------------------------------------- |
| currency<mark style="color:red;">\*</mark>   | String | Default Checkout currency                                        |
| trackingId<mark style="color:red;">\*</mark> | String | Client-provided identifier of the payment in the external system |
| expectedQuoteAmount                          | String | Expected amount denominated in USD                               |
| webhookUrl<mark style="color:red;">\*</mark> | String | Notification URL                                                 |
| includedCurrencies                           | Array  | Array of currencies to include                                   |
| excludedCurrencies                           | Array  | Array of currencies to exclude                                   |

{% tabs %}
{% tab title="200: OK Example of successful response" %}

```javascript
{
    "data": {
        "id": 3444,
        "uuid": "6939c3d6-514a-4b12-88b1-f4dda0947538",
        "currency": "BTC",
        "trackingId": "ACM-253-798",
        "walletId": 2127,
        "logoUrl": "https://yourdomain.com/logo.png",
        "expectedBaseAmount": null,
        "expectedQuoteAmount": "200",
        "includedCurrencyIds": "null",
        "excludedCurrencyIds": "null",
        "createdAt": "2023-04-05T15:34:24.000000Z",
        "checkoutUrl": "https://pay.unixpay.com/checkout/6939c3d6-514a-4b12-88b1-f4dda0947538"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Example of the response with errors" %}

```javascript
{
    "Error": {
        "message": "Unknown walletId"
    }
}
```

{% endtab %}
{% endtabs %}

## Update Checkout

<mark style="color:orange;">`PUT`</mark> `/api/v2/checkouts/update/{uuid}`&#x20;

Updates existing checkout

#### Headers

| Name                                     | Type             | Description |
| ---------------------------------------- | ---------------- | ----------- |
| Accept<mark style="color:red;">\*</mark> | applicaiton/json |             |

#### Request Body

| Name                                       | Type   | Description                        |
| ------------------------------------------ | ------ | ---------------------------------- |
| currency<mark style="color:red;">\*</mark> | String | Default Checkout currency          |
| walletId<mark style="color:red;">\*</mark> | Number | Wallet id to receive funds in      |
| expectedQuoteAmount                        | String | Expected amount denominated in USD |
| webhookUrl                                 | String | Notification URL                   |

{% tabs %}
{% tab title="200: OK Example of successful response" %}

```javascript
{
    "data": {
        "id": 3444,
        "uuid": "6939c3d6-514a-4b12-88b1-f4dda0947538",
        "currency": "ETH",
        "trackingId": "ACM-253-798",
        "walletId": 2127,
        "logoUrl": "https://yourdomain.com/logo.png",
        "expectedBaseAmount": null,
        "expectedQuoteAmount": "200",
        "includedCurrencyIds": "null",
        "excludedCurrencyIds": "null",
        "createdAt": "2023-04-05T15:34:24.000000Z",
        "checkoutUrl": "https://pay.unixpay.com/checkout/6939c3d6-514a-4b12-88b1-f4dda0947538"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Example of the response with errors" %}

```
{
    "error": {
        "message": "Unknown walletId"
    }
}
```

{% endtab %}
{% endtabs %}

## Lists all Checkouts

<mark style="color:blue;">`GET`</mark> `/api/v2/checkouts`&#x20;

Returns a list of previously created Checkouts. The Checkouts are returned in sorted order, with the most recent checkout appearing first.

You can optionally provide parameters to filter out the results by time created.

#### Query Parameters

| Name | Type   | Description                                                                                       |
| ---- | ------ | ------------------------------------------------------------------------------------------------- |
| from | Date   | Filter by created time. We use basic **ISO 8601** format for mixed date-time: YYYY-MM-DDThh:mm:ss |
| to   | Date   | Filter by created time. We use basic **ISO 8601** format for mixed date-time: YYYY-MM-DDThh:mm:ss |
| page | Number | Current page                                                                                      |

{% tabs %}
{% tab title="200: OK Example of successful response" %}

```javascript
{
    "data": [
        {
	        "id": 3444,
	        "uuid": "6939c3d6-514a-4b12-88b1-f4dda0947538",
	        "currency": "ETH",
	        "trackingId": "ACM-253-798",
	        "walletId": 2127,
	        "logoUrl": "https://yourdomain.com/logo.png",
	        "expectedBaseAmount": null,
	        "expectedQuoteAmount": "200",
	        "includedCurrencyIds": "null",
	        "excludedCurrencyIds": "null",
	        "createdAt": "2023-04-05T15:34:24.000000Z",
	        "checkoutUrl": "https://pay.unixpay.com/checkout/6939c3d6-514a-4b12-88b1-f4dda0947538"
        },
        ...
        {
	        "id": 3448,
	        "uuid": "886ff545-52b8-4beb-96e4-34955415512b",
	        "currency": "XRP",
	        "trackingId": "ACM-253-749",
	        "walletId": 2127,
	        "logoUrl": "https://yourdomain.com/logo.png",
	        "expectedBaseAmount": null,
	        "expectedQuoteAmount": "200",
	        "includedCurrencyIds": "null",
	        "excludedCurrencyIds": "null",
	        "createdAt": "2023-04-05T19:34:24.000000Z",
	        "checkoutUrl": "https://pay.unixpay.com/checkout/886ff545-52b8-4beb-96e4-34955415512b"
        }
    ],
    "links": {
        "first": "/api/v2/checkouts?page=1",
        "last": "/api/v2/checkouts?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "links": [
            {
                "url": null,
                "label": "&laquo; Previous",
                "active": false
            },
            {
                "url": "/api/v2/checkouts?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": null,
                "label": "Next &raquo;",
                "active": false
            }
        ],
        "path": "/api/v2/checkouts",
        "per_page": 20,
        "to": 11,
        "total": 11
    }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Example of the response with errors" %}

```javascript
{
    "message": "The given data was invalid.",
    "errors": {
        "from": [
            "The from is not a valid date."
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Get Checkout by Uuid

<mark style="color:blue;">`GET`</mark> `/api/v2/checkouts/{uuid}`&#x20;

Retrieves the details of a Checkout that has previously been created. Supply the universally unique identifier that was returned from your previous request, and the API will return the corresponding checkout information.

#### Path Parameters

| Name                                   | Type   | Description                                                                              |
| -------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| uuid<mark style="color:red;">\*</mark> | String | Universally unique identifier, which is a 128 bit value and used to identify the records |

{% tabs %}
{% tab title="200: OK Example of successful response" %}

```javascript
{
    "data": {
        "id": 3444,
        "uuid": "6939c3d6-514a-4b12-88b1-f4dda0947538",
        "currency": "ETH",
        "trackingId": "ACM-253-798",
        "walletId": 2127,
        "logoUrl": "https://yourdomain.com/logo.png",
        "expectedBaseAmount": null,
        "expectedQuoteAmount": "200",
        "includedCurrencyIds": "null",
        "excludedCurrencyIds": "null",
        "createdAt": "2023-04-05T15:34:24.000000Z",
        "checkoutUrl": "https://pay.unixpay.com/checkout/6939c3d6-514a-4b12-88b1-f4dda0947538"
    }
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Example of the response with errors" %}

```javascript
{
    "message": "The given data was invalid.",
    "errors": {
        "uuid": [
            "The uuid must be a valid UUID."
        ]
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://btpaydocs.blackthornfs.com/reference/api-reference/checkouts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
