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

# Customer Overpayments and Deposits

> Record payments that exceed an invoice, or arrive before it, and apply the credit to a later invoice.

Customers sometimes pay more than an invoice total, or pay a deposit before an invoice exists. Layer tracks this extra amount as a **customer credit** in a liability account. When the customer uses the credit, you record a separate payment that moves the credit onto the new invoice.

This approach has two benefits:

* The original payment never changes after you record it.
* The credit balance is visible on the balance sheet until the customer uses it.

> [!NOTE]
>
> All amounts are integer cents. All examples use [Record a payment](https://docs.layerfi.com/api-reference/v1/record-a-payment.md): `POST /v1/businesses/{businessId}/invoices/payments`.

## Record an overpayment

Allocate the invoice amount to the invoice, and allocate the extra amount to a liability account. In this example, a customer pays $125.00 on a $100.00 invoice.

```bash theme={null}
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/payments \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "external_id": "pmt-1001",
    "customer_external_id": "cust-42",
    "paid_at": "2026-10-15T17:00:00Z",
    "method": "ACH",
    "amount": 12500,
    "invoice_payments": [
      { "invoice_external_id": "inv-500", "amount": 10000 },
      {
        "account": { "type": "StableName", "stable_name": "UNEARNED_REVENUE" },
        "amount": 2500,
        "memo": "Customer credit from overpayment"
      }
    ]
  }'
```

Invoice `inv-500` is fully paid, and \$25.00 sits in **Unearned Revenue** as a customer credit.

> [!WARNING]
>
> Always allocate the extra amount to a named liability account. Do not allocate it to Accounts Receivable. If you leave it unallocated, Layer records it as **Uncategorized Revenue**, and a later redemption cannot offset it.

## Record a deposit before an invoice exists

A deposit, such as a payment on an accepted quote, uses the same pattern. Allocate the full amount to the liability account.

```bash theme={null}
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/payments \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "external_id": "dep-2001",
    "customer_external_id": "cust-42",
    "paid_at": "2026-11-02T17:00:00Z",
    "method": "ACH",
    "amount": 50000,
    "invoice_payments": [
      {
        "account": { "type": "StableName", "stable_name": "UNEARNED_REVENUE" },
        "amount": 50000,
        "memo": "Deposit for quote Q-88"
      }
    ]
  }'
```

## Apply the credit to a later invoice

When the customer uses the credit, record a new payment with method `CREDIT_BALANCE`. Set `paid_at` to the date that the credit is applied. Set `redemption_account` to the same account that holds the credit.

In this example, the customer applies the $25.00 credit to a $60.00 invoice.

```bash theme={null}
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/payments \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "external_id": "pmt-1001-credit-inv-612",
    "customer_external_id": "cust-42",
    "paid_at": "2026-12-03T17:00:00Z",
    "method": "CREDIT_BALANCE",
    "amount": 2500,
    "redemption_account": { "type": "StableName", "stable_name": "UNEARNED_REVENUE" },
    "invoice_payments": [
      { "invoice_external_id": "inv-612", "amount": 2500 }
    ],
    "memo": "Applied credit from pmt-1001"
  }'
```

This payment moves $25.00 out of Unearned Revenue and onto invoice `inv-612`. The customer pays the remaining $35.00 with a normal payment. To use only part of a credit, set `amount` to the part that is used. The rest stays in the liability account.

`CREDIT_BALANCE` payments have these rules:

* Do not send a `processor`, `fee`, or `additional_fees`.
* Send `redemption_account` only with method `CREDIT_BALANCE`. If you omit it, Layer uses **Unearned Revenue**.
* The sum of `invoice_payments` must not be more than `amount`.

## Accounting effect

| Basis | Original payment | Credit applied |
| - | - | - |
| **Cash** | Layer recognizes the full payment as revenue on `paid_at`. | The invoice is marked paid. Layer does not count the revenue again. |
| **Accrual** | The extra amount is a liability. | Revenue for the new invoice is recognized when the `CREDIT_BALANCE` payment is recorded. |

## Track different types of credit

You can track deposits, overpayments, and gift balances separately. Create child accounts under Unearned Revenue, or other liability accounts, with [Create ledger account](https://docs.layerfi.com/api-reference/v1/create-ledger-account.md). Use the same account in the original allocation and in `redemption_account`. Separate accounts are optional. They are not an accounting requirement.

## Related documentation

> [card] [Import sales and AR data](https://docs.layerfi.com/guides/importing-sales-ar-data.md)
>
> Review how invoices, payments, refunds, and payouts flow into Layer.

> [card] [Record a payment](https://docs.layerfi.com/api-reference/v1/record-a-payment.md)
>
> Review the request parameters for invoice payments.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.