> For the complete documentation index, see [llms.txt](https://docs.txn.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txn.io/invoices/payments-to-closed-invoices.md).

# Payments to closed invoices

End users sometimes send another payment to an invoice address after the invoice is closed, for example by paying twice by mistake. An invoice is closed once it is `completed`, `cancelled` or `rejected`. The invoice does not take the new payment: its status and amounts do not change, and no invoice webhook is sent. This page explains what Txn does with the funds instead, and how you find and reconcile them.

An `expired` invoice is not closed. Txn keeps watching its address, and a payment after expiry is applied to the invoice as a late payment; see [Invoice status flow](https://docs.txn.io/invoices/invoice-status-flow.md).

## How Txn handles the payment

Txn can handle payments to closed invoices in one of two ways, configured for your account by Txn support:

* **Credit to your crypto account.** Txn credits the full amount received, in the cryptocurrency the end user sent, to your crypto account in that currency: the account that holds the invoice address, normally your master account (for example, your USDT account). There is no conversion to the invoice's `targetCurrency` and no invoice fee. The credit is a `CoinTransaction` that carries the invoice's `reference`, so you can match it to the original order.
* **Do not credit (default).** Txn records the payment but does not credit it to any account. Contact Txn support to resolve it.

To switch your account to crediting, contact Txn support.

```mermaid
sequenceDiagram
    participant EU as End user
    participant T as Txn
    participant M as Your system
    EU->>T: Pays the invoice
    T->>M: Invoice webhook (completed)
    EU->>T: Sends another payment to the same address
    T->>T: Credits your crypto account, reference = invoice reference
    T-->>M: Closed-invoice notification (if a URL is set up)
    M->>T: GET /transactions to confirm the credit
```

## Notification

Payments to closed invoices do not trigger an invoice webhook or a [crypto deposit webhook](https://docs.txn.io/transactions/crypto-deposit-webhooks.md). When your account credits them, Txn can instead send a notification to a URL you choose. Txn support sets the URL up for your account; it is separate from the webhook endpoints configured in the dashboard.

Txn sends the notification once, as soon as it detects the payment and before the payment completes. It is an HTTP `POST` with a JSON body (`Content-Type: application/json`). It does not use the JSON:API format and is not signed, so do not credit your end user on the notification alone: confirm the payment through the API first, as described in [Finding the payment in the API](#finding-the-payment-in-the-api).

**Example notification**

```json
{
  "description": "The user sent a duplicate payment to a closed invoice. The funds have been allocated to your merchant account.",
  "company_name": "Acme",
  "transaction_id": "79e935f8-5071-4e51-b82e-7cfbf3fb1857",
  "transaction_type": "Transaction::CoinDeposit",
  "status": "confirmed",
  "tx_hash": "b7d0ba1853125d6ed9e6a9b5c7e719f9dfb8dfec7a0b2f3a18a72b63e2e4464c",
  "reference": "docs-closed-invoice-1793961624",
  "amount": "10 USDT",
  "network_name": "Tron (TRC20)",
  "address": "TLVEo6wq4qEhNWuC2GXEcZ4PGgRwncqjsG",
  "environment": "sandbox"
}
```

**Payload Description**

| Name               | Type   | Description                                                                                                                                                                            |
| ------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description`      | string | What happened. Use it to tell this notification apart from the others sent to the same URL; see [Other notifications sent to the same URL](#other-notifications-sent-to-the-same-url). |
| `company_name`     | string | Your company name.                                                                                                                                                                     |
| `transaction_id`   | string | ID of the payment. The same ID appears as `data[].id` in [Listing transactions](https://docs.txn.io/transactions/listing-transactions.md) and in the invoice's `coinDeposits`.         |
| `transaction_type` | string | Always `Transaction::CoinDeposit`.                                                                                                                                                     |
| `status`           | string | Internal Txn state of the payment when it was detected, usually `unconfirmed` or `confirmed`. It is not the final status: check `simplifiedState` through the API.                     |
| `tx_hash`          | string | Transaction hash on the network.                                                                                                                                                       |
| `reference`        | string | The `reference` of the closed invoice.                                                                                                                                                 |
| `amount`           | string | Amount received with its currency code, formatted for display (for example, `10 USDT`). Take the numeric amount from the API.                                                          |
| `network_name`     | string | Network name, for example `Tron (TRC20)`.                                                                                                                                              |
| `address`          | string | The invoice address the payment was sent to.                                                                                                                                           |
| `environment`      | string | Txn environment that sent the notification, for example `sandbox`.                                                                                                                     |

### Other notifications sent to the same URL

Txn also uses this URL to tell you about crypto deposits held for compliance review. These notifications have the same fields. Branch on `description`:

| `description`                                                                                                    | Meaning                                                                                  |
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `The user sent a duplicate payment to a closed invoice. The funds have been allocated to your merchant account.` | A payment to a closed invoice was credited to your crypto account. Covered on this page. |
| `The user's payment risk exposure is too high. The payment has been placed on hold for further review.`          | A deposit was placed on hold for compliance review.                                      |
| `The payment review has been completed, and the payment has been released and processed as normal.`              | A held deposit was released and processed.                                               |
| `The payment review has been completed, and the payment has been rejected.`                                      | A held deposit was rejected and not credited.                                            |
| `The user's payment risk exposure is too high. The payment has been refunded to the source address.`             | A held deposit was refunded to the address it came from.                                 |

In the compliance notifications, `address` is the sender's address (for a refund, the address the refund was sent to) rather than the invoice address.

## Finding the payment in the API

Whether or not you receive notifications, the credited payment is available through the API.

### Listing transactions

The payment is a `CoinTransaction` in [Listing transactions](https://docs.txn.io/transactions/listing-transactions.md) and in [Listing account transactions](https://docs.txn.io/accounts/listing-account-transactions.md) for your crypto account. Its `reference` is the invoice `reference`, and `amount` is the full amount received. To pick up new and newly completed entries, sort by `updated_at`:

```bash
curl -G "https://api.sandbox.txn.io/api/public/v1/transactions" \
     -H 'Content-Type: application/vnd.api+json' \
     -H 'Authorization: Bearer <api_key>' \
     --data-urlencode 'order=updated_at' \
     --data-urlencode 'per_page=100'
```

The entry for the payment in the example notification:

```json
{
  "id": "79e935f8-5071-4e51-b82e-7cfbf3fb1857",
  "type": "transactions",
  "attributes": {
    "createdAt": "2026-11-06T10:43:14.884Z",
    "simplifiedState": "completed",
    "transactionType": "CoinTransaction",
    "amount": "10.000000",
    "currency": "USDT",
    "balance": "305901.826361",
    "reference": "docs-closed-invoice-1793961624",
    "accountId": "e289de2b-37bd-4eff-b832-f754c31a2d95"
  },
  "relationships": {
    "account": {
      "data": {
        "type": "accounts",
        "id": "e289de2b-37bd-4eff-b832-f754c31a2d95"
      }
    },
    "transactionDetails": {
      "meta": {
        "included": false
      }
    },
    "author": {
      "data": null
    }
  }
}
```

`simplifiedState` is `pending` until the payment is credited and `completed` once it is. A `CoinTransaction` with a non-null `reference` is a payment to one of your invoice addresses; a deposit to an [account address](https://docs.txn.io/accounts/creating-account-address.md) has no `reference`.

### Reading the invoice

[Reading invoice](https://docs.txn.io/invoices/reading-invoice.md) returns every payment received at the invoice address in `data.relationships.coinDeposits`, including payments that arrived after the invoice closed. The invoice's own `status`, `statusContext` and amounts do not change. Each entry in `included[]` has its own `simplifiedState`: `processed` for the payment applied to the invoice, and `completed` for a later payment credited to your crypto account.

The two `coinDeposits` of the example invoice, which was paid in full and then paid again:

```json
[
  {
    "id": "8095da11-fa2b-485d-be22-77e34bd40e4a",
    "type": "coinDeposits",
    "attributes": {
      "txHash": "9bbebe78ca07f0398cddad66485ec3d64d7e16d96e12a4742d18bab4fe327205",
      "currencyCode": "USDT",
      "createdAt": "2026-11-06T10:41:45.727Z",
      "state": "processed",
      "amount": "10.000000",
      "riskScore": null,
      "reference": "docs-closed-invoice-1793961624",
      "accountId": "e289de2b-37bd-4eff-b832-f754c31a2d95",
      "simplifiedState": "processed",
      "sourceAddresses": [
        "TPE3bwwmwMBHyddFpruHeFWMVUibxs3rq8"
      ],
      "clusterCategory": "Exchange",
      "clusterName": "Test ENV"
    }
  },
  {
    "id": "79e935f8-5071-4e51-b82e-7cfbf3fb1857",
    "type": "coinDeposits",
    "attributes": {
      "txHash": "b7d0ba1853125d6ed9e6a9b5c7e719f9dfb8dfec7a0b2f3a18a72b63e2e4464c",
      "currencyCode": "USDT",
      "createdAt": "2026-11-06T10:43:14.873Z",
      "state": "completed",
      "amount": "10.000000",
      "riskScore": null,
      "reference": "docs-closed-invoice-1793961624",
      "accountId": "e289de2b-37bd-4eff-b832-f754c31a2d95",
      "simplifiedState": "completed",
      "sourceAddresses": [
        "TPE3bwwmwMBHyddFpruHeFWMVUibxs3rq8"
      ],
      "clusterCategory": "Exchange",
      "clusterName": "Test ENV"
    }
  }
]
```

`relationships` (`network`, `address`, `author`, all with `meta.included` `false`) are omitted above for brevity.

Payments to invoice addresses are not returned by [Listing crypto deposits](https://docs.txn.io/transactions/listing-crypto-deposits.md) or [Reading crypto deposit](https://docs.txn.io/transactions/reading-crypto-deposit.md), which cover account addresses only.

## Integration checklist

1. Match the payment to your order or end user with `reference`.
2. Confirm it through the API: the `CoinTransaction` with that `reference` and the notification's `transaction_id` is `completed`.
3. Process each `transaction_id` once. A closed invoice's address can receive several payments, each with its own ID.
4. Decide how to treat the funds under your own policy, for example by crediting the end user's balance in the currency received or by refunding them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.txn.io/invoices/payments-to-closed-invoices.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
