# Charge

## Create Charge

## Create a new charge

<mark style="color:green;">`POST`</mark> `https://api.criptan.com/business/charge`

To request a cryptocurrency payment, you create a charge. A charge will expire after a waiting period (payment window) if no payment has been detected. Charges are identified by a unique code.

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | String | API key     |

#### Request Body

| Name                                                              | Type             | Description                                                                                                            |
| ----------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
| currency<mark style="color:red;">\*</mark>                        | string           | Fiat currency identifier (e.g: 'EUR')                                                                                  |
| amount<mark style="color:red;">\*</mark>                          | integer          | Amount charged in fiat currency                                                                                        |
| dscription<mark style="color:red;">\*</mark>                      | string           | Description of the payment                                                                                             |
| continueUrl                                                       | string           | URL that the user will be redirected to if the payment is successful                                                   |
| cancelUrl                                                         | string           | URL that the user will be redirected to if the payment fail                                                            |
| products<mark style="color:red;">\*</mark>                        | array of objects | An array of JSON object that contains information about what you are charging the user                                 |
| metadata                                                          | string           | A strinfified JSON object that contains any metadata you want to include about your order                              |
| ttl                                                               | integer          | The number of minutes your user has to pay the charge. Minimum: 5 minutes, Maximum: 60 minutes                         |
| client                                                            | object           | Additional client data. This is **required** if the merchant needs to pass a KYC of the customer.                      |
| client.fullName<mark style="color:red;">\*</mark>                 | string           | Full name of the client, separated by spaces                                                                           |
| client.dateOfBirth<mark style="color:red;">\*</mark>              | string           | ISO8601 string representing the date of birth                                                                          |
| client.address<mark style="color:red;">\*</mark>                  | string           | Full address of the client                                                                                             |
| client.needsAdditionalClearance<mark style="color:red;">\*</mark> | boolean          | If the client needs additional verification (operating on >10k€)                                                       |
| client.document.id<mark style="color:red;">\*</mark>              | string           | The ID of the client                                                                                                   |
| client.document.type<mark style="color:red;">\*</mark>            | string           | The type of the ID of the customer, either `id` (a national document) or `P` (a passport)                              |
| metadata.concept<mark style="color:red;">\*</mark>                | string           | This is only **required** in case of a client who is a PFP who needs to send bank transactions with a specific concept |

{% tabs %}
{% tab title="200: OK Return BusinessCharge and checkoutUrl" %}

```javascript
{
  id: string;
  checkoutUrl: string;
  continueUrl: string;
  createdAt: string;
  expiresAt: string;
  paymentStatus: 'PENDING';
  products: [
    {
      title: string;
      price: number;
      quantity: number;
      image: string | undefined;
      description: string | undefined;
    }
  ];
  pricing: {
    fiat: {
      amount: string;
      currency: string;
    };
    BTC: {
      amount: string;
      currency: string;
      address: string;
    };
    ETH: {
      amount: string;
      currency: string;
      address: string;
    };
    LTC: {
      amount: string;
      currency: string;
      address: string;
    };
  };
  description: string;
  processStatus: "UNPROCESSED";
  metadata: Record<string, unknown> | undefined;
  acceptanceRate: string | undefined;
  cryptoHoldingPercentage: string | undefined;
  client: BusinessChargeClient | undefined;
  checkoutUrl: string;
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Client KYC data is missing, but your account specify it as needed" %}

```javascript
{
  message: 'Client KYC data is missing, but your account specify it as needed',
  code: 'missing_client_data'
}
```

{% endtab %}

{% tab title="500: Internal Server Error Generic internal error" %}

```javascript
{
  message: 'Internal error',
  code: 'internal_error'
}
```

{% endtab %}

{% tab title="503: Service Unavailable Not found charge price data from Exchange" %}

```javascript
{
    message: "Service unavaliable. Not found charge price data from Exchange",
    code: "service_unavaliable_price_data_exchange",
    retryable: true
}
```

{% endtab %}

{% tab title="404: Not Found The account trying to initiate the payment hasn't been found" %}

```javascript
{
    message: "Business account not found",
    code: "not_found_business_account"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Fail to create charge" %}

```javascript
{
    message: "Internal error. Fail to create Charge",
    code: "internal_error_create_charge"
}
```

{% endtab %}

{% tab title="400: Bad Request Charge exceeds maximum charge amount" %}

```javascript
{
    message: "Charge exceeds maximum charge amount",
    code: "exceed_restricted_charge_amount
}
```

{% endtab %}
{% endtabs %}

## List of charges

## Get all charges from a business account

<mark style="color:blue;">`GET`</mark> `https://api.criptan.com/business/charge`

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | string | Api key     |

{% tabs %}
{% tab title="200: OK Get list of charges" %}

```javascript
{
  [
  id: string;
  createdAt: string;
  expiresAt: string;
  paymentStatus: 'PENDING' | 'PAID' | 'CONFIRMED' | 'EXPIRED' | 'UNDERPAID' | 'DELAYED' | 'REFUNDED' | 'REFUND_PENDING';
  products: [
    {
      title: string;
      price: number;
      quantity: number;
      image: string | undefined;
      description: string | undefined;
    }
  ];
  pricing: {
    fiat: {
      amount: string;
      currency: string;
    };
    BTC: {
      amount: string;
      currency: string;
      address: string;
    };
    ETH: {
      amount: string;
      currency: string;
      address: string;
    };
    LTC: {
      amount: string;
      currency: string;
      address: string;
    };
  };
  description: string;
  processStatus: "ERROR" | "INITIATED" | "PROCESSED" | "UNPROCESSED";
  metadata: Record<string, unknown> | undefined;
  acceptanceRate: string | undefined;
  cryptoHoldingPercentage: string | undefined;
  client: BusinessChargeClient | undefined;
  confirmedAt: string | undefined;
  paidAt: string | undefined;
  processedAt: string | undefined;
  refundAddresses: BusinessRefundAddress | undefined;
  refundPaidAt: string | undefined;
  refundRequestedAt: string | undefined;
  transaction: BusinessTransaction | undefined;
  continueUrl: string;
  cancelUrl: string;
  checkoutUrl: string;
  ]
}
```

{% endtab %}

{% tab title="404: Not Found Not found list" %}

```javascript
{
    message: "Charges not found",
    code: "not_found_charges"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Get list of charges fail" %}

```javascript
{
    message: "Internal error. Get list of charges",
    code: "internal_error_get_list_of_charges"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Unknown error" %}

```javascript
{
    message: "Internal error",
    code: "internal_error"
}
```

{% endtab %}
{% endtabs %}

## Get Charge

## Get charge details

<mark style="color:blue;">`GET`</mark> `https://api.criptan.com/business/charge/:id`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | string | charge id   |

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | String | Api key     |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  id: string;
  createdAt: string;
  expiresAt: string;
  paymentStatus: 'PENDING' | 'PAID' | 'CONFIRMED' | 'EXPIRED' | 'UNDERPAID' | 'DELAYED' | 'REFUNDED' | 'REFUND_PENDING';
  products: [
    {
      title: string;
      price: number;
      quantity: number;
      image: string | undefined;
      description: string | undefined;
    }
  ];
  pricing: {
    fiat: {
      amount: string;
      currency: string;
    };
    BTC: {
      amount: string;
      currency: string;
      address: string;
    };
    ETH: {
      amount: string;
      currency: string;
      address: string;
    };
    LTC: {
      amount: string;
      currency: string;
      address: string;
    };
  };
  description: string;
  acceptanceRate: string;
  processStatus: "ERROR" | "INITIATED" | "PROCESSED" | "UNPROCESSED";
  metadata: Record<string, unknown> | undefined;
  acceptanceRate: string | undefined;
  cryptoHoldingPercentage: string | undefined;
  client: BusinessChargeClient | undefined;
  confirmedAt: string | undefined;
  paidAt: string | undefined;
  processedAt: string | undefined;
  refundAddresses: BusinessRefundAddress | undefined;
  refundPaidAt: string | undefined;
  refundRequestedAt: string | undefined;
  transaction: BusinessTransaction | undefined; 
  continueUrl: string;
  cancelUrl: string;
  checkoutUrl: string;
}
```

{% endtab %}

{% tab title="404: Not Found The payment you have requested hasn't been found" %}

```javascript
{
   message: "Charge not found",
   code: "not_found_charge"
}
```

{% 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://developers.criptan.com/business-criptan-pay/api-reference/charge.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.
