# Fiat Invoices

{% hint style="warning" %}
Every request listed on this page requires [authorization](https://docs.0xpay.app/public-api/endpoints/broken-reference) to be successfully completed.&#x20;
{% endhint %}

## Create fiat invoice (Server-Side)

<mark style="color:green;">`POST`</mark> `https://public.api.0xpay.app/merchants/invoices/fiat`

Creates a webpage with your invoice details on 0xpay.app domain, usable for a one-time payment. Currently, the only supported fiat `tickers` are `UAH and KZT.`\
**Payment limits:** \
**KZT** Min — 12000 KZT, Max — 300000 KZT.

**Status Updates:** After creation, every invoice update will produce an [invoice notification](https://docs.0xpay.app/notifications#fiat-invoice).

#### Request Body

| Name                                   | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount                                 | object  | <p><code>value: string</code> – invoice amount you want to receive from user<br><code>ticker: string</code> – currently, only <code>UAH</code> is available<br><em>If not specified — user will fill this fields on his demand</em></p>                                                                                                                                                                                                                                                                                                                                                                     |
| meta                                   | string  | *your metadata* that will be passed along to you later with a notification                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| name<mark style="color:red;">\*</mark> | string  | descriptional field, name of your invoice. For example: "Order payment"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| toPendingImmediate                     | boolean | jump immediately to pending status, it can be useful if you want to skip fist "user prompt" status.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| email                                  | string  | user email                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| target                                 | object  | <p><code>ticker: string</code> - the currency to which we will try to exchange the received funds if <code>target.ticker == amount.ticker</code> no exchange will happen</p><p><code>address: string</code> - the address, to which we will withdraw invoice funds in the currency specified in <code>target.ticker</code> </p><p><code>blockchain: string</code> - network in which withdrawal will be made, this field is required if <code>target.address</code> is provided, available values you can find <a href="../../../general/networks-and-assets#blockchains">here</a> ("API value" column)</p> |
| redirectUrl                            | string  | URL to redirect user after payment                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

{% tabs %}
{% tab title="200: OK Invoice URL generated succesfully" %}
{% code overflow="wrap" %}

```javascript
{
    "id": "123e4567-e89b-12d3-a456-426614174000" //internal ID has been assigned to the invoice
     "url": "https://my.0xpay.app/invoices/crypto/123e4567-e89b-12d3-a456-426614174000" // feel free to redirect user to this URL for payment

}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Create fiat invoice via Web Form (Client-Side)

<mark style="color:green;">`POST`</mark> `https://public.api.0xpay.app/merchants/invoices/fiat/form`

Creates a fiat invoice using parameters from your HTML form and redirects users to 0xpay URL for payment. on 0xpay.app domain for one-time payment. Currently, the only supported fiat `tickers` are `UAH and KZT.`\
**Payment limits:** \
**UAH** Min — 25 UAH, Max — 29999 UAH.\
**KZT** Min — 12000 KZT, Max — 300000 KZT.

Instead of authorizing a request, just **pass your merchantID along with other parameters.**

**Status Updates:** After creation, every invoice update will produce an [invoice notification](https://docs.0xpay.app/notifications#fiat-invoice).

#### Request Body

| Name                                         | Type   | Description                                                                                                                                                                                                                |
| -------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value                                        | string | <p>a fixed amount of invoice<br><em>This field is optional, if not specified user will fill this fields on his demand</em></p>                                                                                             |
| meta                                         | string | *your metadata* that will be passed along to you later with a notification                                                                                                                                                 |
| name<mark style="color:red;">\*</mark>       | string | descriptional field, name of your invoice. For example: "Order payment"                                                                                                                                                    |
| merchantID<mark style="color:red;">\*</mark> | string | internal id of your 0xpay merchant account                                                                                                                                                                                 |
| targetTicker                                 | string | the currency to which we will try to exchange the received funds if `targetTicker == ticker` no exchange will happen                                                                                                       |
| ticker                                       | string | <p>only UAH available currently</p><p><em>This field is optional, if not specified user will fill this fields on his demand</em></p>                                                                                       |
| targetAddress                                | string | the address, to which we will withdraw invoice funds in the currency specified in `targetTicker`                                                                                                                           |
| targetBlockchain                             | string | network in which withdrawal will be made, this field is required if `targetAddress` is provided, available values you can find [here](https://docs.0xpay.app/general/networks-and-assets#blockchains) ("API value" column) |
| redirectUrl                                  | string | URL to redirect user after payment                                                                                                                                                                                         |

{% tabs %}
{% tab title="200: OK Redirects to payment webpage URL" %}
Redirects to payment webpage URL
{% endtab %}
{% endtabs %}

## Find fiat invoice details by ID

<mark style="color:blue;">`GET`</mark> `https://public.api.0xpay.app/merchants/invoices/fiat/:id`

This method is used to get invoice's data by it's id.&#x20;

#### Path Parameters

| Name                                 | Type   | Description                             |
| ------------------------------------ | ------ | --------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | internal identificator of 0xpay invoice |

{% tabs %}
{% tab title="200: OK Examples of fiat invoices:" %}
List of invoice statuses: \
\- CREATED\
\- PENDING\
\- PAID\
\- DONE\
\- FAILED

{% tabs %}
{% tab title="Pending Invoice" %}
{% code overflow="wrap" %}

```
{
    "id": "eb929d63-5f05-4d9f-9d3e-854384009ef1",
    "name": "Order payment",
    "company": {
        "name": "CompanyName",
        "url": "example.com"
    },
    "status": "PENDING", 
    "amount": {
        "value": "1000",
        "ticker": "UAH",

    },
    "meta": "i-want-to-know-about-that"
}
```

{% endcode %}
{% endtab %}

{% tab title="Done Invoice" %}

```
{
    "id": "eb929d63-5f05-4d9f-9d3e-854384009ef1",
    "name": "Order payment",
    "company": {
        "name": "CompanyName",
        "url": "example.com"
    },
    "status": "DONE", 
    "amount": {
        "value": "1000",
        "ticker": "UAH",

    },
    paidAmount: {
        "value": "1010",
        "ticker": "UAH",
    },
    fee: {
        "value": "10",
        "ticker": "UAH",   
    }
    "meta": "i-want-to-know-about-that",
    "cardNumber": "444111***********5131"
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}
