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

# Invoice callbacks

Invoice callbacks are sent whenever the status of an invoice changes.

<Tabs>
  <Tab title="Successful payment">
    Sent when the invoice has been successfully paid and can be treated as completed on your side.

    ```json highlight={42} theme={null}
    {
      "id": 588,
      "foreign_id": "8FW1KI7LesB9yxWcK1K",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 386897,
        "currency": "BTC",
        "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.02000000",
        "remaining_amount": "0.01000000"
      },
      "currency_received": {
        "currency": "BTC",
        "amount": "0.02000000"
      },
      "transactions": [
        {
          "id": 750294,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk",
          "tag": null,
          "amount": "0.01000000",
          "txid": "528dcda13270f8590853405600bf5634d53aa66d2ce5d3a873006a670f9da788",
          "confirmations": "0"
        }
      ],
      "fees": [
        {
          "type": "fee_crypto_deposit",
          "currency": "BTC",
          "amount": "0.0008"
        }
      ],
      "error": "",
      "status": "confirmed",
      "fixed_at": 1592307241,
      "expires_at": 1592308141
    }
    ```
  </Tab>

  <Tab title="Transaction is in the mempool">
    Sent when a payment transaction has been detected in the mempool but has not yet been finalized. The invoice should be treated as pending until a confirmed callback is received.

    ```json highlight={43} theme={null}
    {
      "id": 22,
      "foreign_id": "229-hdsa",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 1845,
        "currency": "BTC",
        "convert_to": "EUR",
        "address": "2N8pvnVKEFjVCP4TteJVCPTbg9Aqibfws8C",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.00309556",
        "remaining_amount": "0.00000000"
      },
      "currency_received": {
        "currency": "EUR",
        "amount": "214.00000000"
      },
      "transactions": [
        {
          "id": 1504,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2N8pvnVKEFjVCP4TteJVCPTbg9Aqibfws8C",
          "tag": null,
          "amount": "0.00309556",
          "txid": "3e68744626ba23d591dc1b548b8b9b126ab0f49e6da020958f66ee64c38ec7ed",
          "confirmations": "0"
        }
      ],
      "fees": [],
      "error": "",
      "status": "processing",
      "fixed_at": 1592308917,
      "expires_at": 1592395375
    }
    ```
  </Tab>

  <Tab title="Invoice payment by installments">
    Sent when the invoice is paid using multiple transactions. Once the full amount is received, the invoice is marked as confirmed.

    ```json highlight={53} theme={null}
    {
      "id": 588,
      "foreign_id": "8FW1KI7LesB9yxWcK1K",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 386897,
        "currency": "BTC",
        "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.02000000",
        "remaining_amount": "0.00000000"
      },
      "currency_received": {
        "currency": "BTC",
        "amount": "0.02000000"
      },
      "transactions": [
        {
          "id": 750294,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk",
          "tag": null,
          "amount": "0.01000000",
          "txid": "6647cf5cae701507b7076b32ca12f19d8e9fe037407c02e09b04abdaede99fd0",
          "confirmations": "1"
        },
        {
          "id": 750384,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk",
          "tag": null,
          "amount": "0.01000000",
          "txid": "528dcda13270f8590853405600bf5634d53aa66d2ce5d3a873006a670f9da788",
          "confirmations": "1"
        }
      ],
      "fees": [
        {
          "type": "fee_crypto_deposit",
          "currency": "BTC",
          "amount": "0.0008"
        }
      ],
      "error": "",
      "status": "confirmed",
      "fixed_at": 1592307241,
      "expires_at": 1592394104
    }
    ```
  </Tab>

  <Tab title="Timer expired">
    Sent when the invoice expires before any payment is received. In this case, the invoice is marked as failed.

    ```json highlight={23-24} theme={null}
    {
      "id": 23,
      "foreign_id": "77xa2pd",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 1846,
        "currency": "BTC",
        "address": "2MyL2ftBdNsmpsx1EKggPzNVuoiZCWdVaLX",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.02000000",
        "remaining_amount": "0.02000000"
      },
      "currency_received": {
        "currency": "BTC",
        "amount": "0.02000000"
      },
      "transactions": [],
      "fees": [],
      "error": "Timer expired. User not paid.",
      "status": "failed",
      "fixed_at": 1592309817,
      "expires_at": 1592310717
    }
    ```
  </Tab>

  <Tab title="Processing status for more than 24 hours">
    Sent when a payment was detected but remained in processing for too long without being finalized, so the invoice was marked as failed.

    ```json highlight={41-42} theme={null}
    {
      "id": 21,
      "foreign_id": "88smaan2",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 1844,
        "currency": "BTC",
        "address": "2NCfH4keMq2SZj3H73VeQYtb8yBgTuUrACf",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.01000000",
        "remaining_amount": "0.00990000"
      },
      "currency_received": {
        "currency": "BTC",
        "amount": "0.01000000"
      },
      "transactions": [
        {
          "id": 1505,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2NCfH4keMq2SZj3H73VeQYtb8yBgTuUrACf",
          "tag": null,
          "amount": "0.00010000",
          "txid": "6dd68265eb2b3a1be0dd4a40975345155d0fbbe244c84efcc7f6b910629a38f9",
          "confirmations": "0"
        }
      ],
      "fees": [
        {
          "type": "fee_crypto_deposit",
          "currency": "BTC",
          "amount": "0.0008"
        }
      ],
      "error": "Timer expired. Transactions were in status processing too long.",
      "status": "failed",
      "fixed_at": 1592308709,
      "expires_at": 1592309609
    }
    ```
  </Tab>

  <Tab title="Payment is less than invoice amount">
    Sent when the customer pays less than the required invoice amount before the invoice expires. In this case, the invoice is marked as failed.

    ```json highlight={41-42} theme={null}
    {
      "id": 21,
      "foreign_id": "88smaan2",
      "end_user_reference": "12345",
      "type": "invoice",
      "crypto_address": {
        "id": 1844,
        "currency": "BTC",
        "address": "2NCfH4keMq2SZj3H73VeQYtb8yBgTuUrACf",
        "tag": null
      },
      "currency_sent": {
        "currency": "BTC",
        "amount": "0.01000000",
        "remaining_amount": "0.00990000"
      },
      "currency_received": {
        "currency": "BTC",
        "amount": "0.01000000"
      },
      "transactions": [
        {
          "id": 1505,
          "currency": "BTC",
          "transaction_type": "blockchain",
          "type": "deposit",
          "address": "2NCfH4keMq2SZj3H73VeQYtb8yBgTuUrACf",
          "tag": null,
          "amount": "0.00010000",
          "txid": "6dd68265eb2b3a1be0dd4a40975345155d0fbbe244c84efcc7f6b910629a38f9",
          "confirmations": "2"
        }
      ],
      "fees": [
        {
          "type": "fee_crypto_deposit",
          "currency": "BTC",
          "amount": "0.0008"
        }
      ],
      "error": "Timer expired. User paid less than requested.",
      "status": "failed",
      "fixed_at": 1592308709,
      "expires_at": 1592309609
    }
    ```
  </Tab>
</Tabs>
