# Create an invoice

Let's [create an invoice](https://reference.cryptopay.me/#tag/Invoices/operation/invoices.create) and then pay for it:

{% code overflow="wrap" %}

```bash
curl -X POST \
https://business-sandbox.cryptopay.me/api/invoices \
-H 'Authorization: HMAC ***' \
-H 'Content-Type: application/json' \
-H 'Date: Tue, 19 Mar 2019 10:11:40 GMT' \
-d '{"price_amount":"100", "price_currency":"EUR", "pay_currency":"BTC", "network":"bitcoin", "custom_id":"209584732"}'
```

{% endcode %}

Let us go through the parameters we used in our request above:&#x20;

* `price_amount` - the payment amount&#x20;
* `price_currency` - the currency of payment, i.e. the currency into which the cryptocurrency received at the address of the invoice will be converted and in which the merchant will be credited to the balance, in our case it is `EUR`
* `pay_currency` - the cryptocurrency in which the payment is to be made, in our case it is `BTC`
* `network` - the blockchain in which the address is going to be created. The list of available networks can be found [here](https://developers.cryptopay.me/guides/currencies/currencies).
* `custom_id` - we recommend you to specify a certain reference by which you associate your customer with the payment, e.g. `209584732`

You will receive the invoice address, the amount of cryptocurrency to be sent to the invoice address and a link to the invoice's hosted page, which can be built into your website and other details:

{% code overflow="wrap" %}

```json
{
  "id": "cc75b958-5780-4b34-a33a-cf63b349fbab",
  "custom_id": "209584732",
  "status": "new",
  "status_context": null,
  "address": "3Gtvf2EVxN8XJ4DHriRt9q9LkdVCpQZEeSd",
  "network": "bitcoin",
  "uri": "bitcoin:3Gtvf2EVxN8XJ4DHriRt9q9LkdVCpQZEeSd?amount=0.010268",
  "price_amount": "100.0",
  "price_currency": "EUR",
  "pay_amount": "0.010268",
  "pay_currency": "BTC",
  "fee": "1.0",
  "fee_currency": "EUR",
  "paid_amount": "0.0",
  "exchange": {
    "pair": "BTCEUR",
    "rate": "4905.9838",
    "fee": "0.0",
    "fee_currency": "EUR"
  },
  "transactions": [],
  "name": "invoice name",
  "description": "invoice description",
  "metadata": {
    "foo": "bar"
  },
  "success_redirect_url": null,
  "hosted_page_url": "https://hosted-business.cryptopay.me/invoices/cc75b958-5780-4b34-a33a-cf63b349fbab",
  "created_at": "2019-05-02T13:56:56+00:00",
  "expires_at": "2019-05-02T14:06:56+00:00"
}
```

{% endcode %}

## **Tips for Making Invoice Payments**

To pay for the invoice, it’s required to send a cryptocurrency transaction to the invoice cryptocurrency address - in this tutorial it is `3Gtvf2EVxN8XJ4DHriRt9q9LkdVCpQZEeSd`. To do so, log in to your sandbox account and press the "Send" button, which is located on your cryptocurrency wallet balance:&#x20;

<figure><img src="https://610376622-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LcumCsZ6ZxEPn6jqlMH%2Fuploads%2F5p99j9wUOPgRYiDD3JvV%2FScreenshot%202026-01-29%20at%204.20.44%E2%80%AFPM.png?alt=media&#x26;token=b884a83b-8d35-411a-b9db-3d5d01321d29" alt=""><figcaption></figcaption></figure>

In the pop-up window, enter the address (`address` from the received response) and the transaction amount (`pay_amount` from the received response), and complete the process. You can also automate this process with [this endpoint](https://reference.cryptopay.me/#tag/Coin-withdrawals/operation/coin-withdrawals.create) so that you do not have to create payments manually.

Once the payment is made, we will send the [callbacks](https://developers.cryptopay.me/guides/api-basics/callbacks) to the Callback URL.&#x20;

{% hint style="info" %}
We recommend that you check invoice statuses via `GET /api/invoices/:id`using [this endpoint](https://reference.cryptopay.me/#tag/Invoices/operation/invoices.retrieve) as the delivery of the callbacks is not guaranteed.
{% endhint %}

Below is an example of a callback for the final status `completed` of the payment:

{% code overflow="wrap" %}

```json
{
  "type": "Invoice",
  "event": "status_changed",
  "data": {
    "id": "cc75b958-5780-4b34-a33a-cf63b349fbab",
    "status": "completed",
    "status_context": null,
    "address": "2NG8f2EVxN8XJ4DHriRt9q9LkdVCpQZ2UGB",
    "network": "bitcoin",  
    "price_amount": "100.0",
    "price_currency": "EUR",
    "pay_amount": "0.02038328",
    "pay_currency": "BTC",
    "paid_amount": "0.02038328",
    "exchange": {
      "pair": "BTCEUR",
      "rate": "4905.9838"
    },
    "transactions": [
      {
        "txid": "502e6de0c3b1d129974c55e6cd127fd548e4501ff8e8d9330ea9a30a83dbd16e",
        "risk": {
          "score": 3.1,
          "level": "low",
          "resource_name": "Bitstamp",
          "resource_category": "Exchange"
        }
      }
    ],
    "name": "invoice name",
    "description": "invoice description",
    "metadata": {
      "foo": "bar"
    },
    "success_redirect_url": null,
    "hosted_page_url": "https://hosted-business.cryptopay.me/invoices/cc75b958-5780-4b34-a33a-cf63b349fbab",
    "custom_id": "209584732",
    "created_at": "2019-05-02T13:56:56+00:00",
    "expires_at": "2019-05-02T14:06:56+00:00"
  }
}
```

{% endcode %}

It is important to note that cash from the payment is only credited to the merchant balance when the payment status is updated to `completed`. The `price_amount` field for a payment with the status `completed` indicates the full amount of this processed payment.
