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

> ## Agent Instructions
> The CoinStack API base URL is https://coinstack.net/api/v1. Authenticate with an API key sent as 'Authorization: Bearer sk_...' from a server, never from a browser. Every response is a JSON object with 'success' and 'response'. Amounts are strings; token amounts on quotes and payments are in the token's smallest unit. Fulfil an order when its checkout status is 'completed', not when the customer returns to success_url. Verify the CoinStack-Signature header on every webhook using the raw request body. The OpenAPI file is at https://docs.coinstack.net/openapi.json.

# Underpayments and late payments

> What happens when a customer pays too little, too much or too late.

Customers send payments from their own wallets, so the amount and timing are not always exact. This page covers each case and what your integration should do.

## Underpayments

### Small shortfalls

A payment that falls slightly short still completes the checkout. How short is set under **Settings**, then **Underpayment**, in the dashboard:

* **Percent of the total.** The default is 0.5%.
* **Fixed amount in USD.** Off by default.

If both are set, the smaller allowance applies. A checkout completed this way has the status `completed`, and `underpaid` is `true` if it was short by one cent or more.

### Partial payments

A payment that falls short by more than the allowance moves the checkout to `partial` and sends a `checkout.partial` event. The checkout stays open, and the customer can send the rest to the same address. When the total reaches the full amount, the checkout becomes `completed`.

If the checkout reaches `expires_at` while it is still `partial`, it becomes `expired` with `underpaid` set to `true`. The USDC from the partial payment has already reached your wallet.

### Resolving an underpaid checkout

When a checkout is `partial` or `expired` and has received a payment, you have two options:

* **Accept what was paid.** [Resolve the checkout](https://docs.coinstack.net/api-reference/checkouts/resolve-a-checkout.md), or select **Mark as resolved** on the checkout in the dashboard. Its status becomes `resolved` and a `checkout.resolved` event is sent.
* **Return the payment.** Send the customer a refund from your own wallet. CoinStack does not send refunds.

```bash theme={null}
curl -X POST https://coinstack.net/api/v1/checkouts/8f3b2c1e-5d47-4a9b-b6e0-2c7f1a9d4e53/resolve \
  -H "Authorization: Bearer $COINSTACK_API_KEY"
```

`resolved` is final. Treat it as paid in your own system.

## Overpayments

If the customer pays more than 2% over the full amount, the checkout is `completed` with `overpaid` set to `true`. All of it is settled to your wallet. Compare `received` with what you expected and refund the difference from your own wallet if you choose to.

## Late payments

A payment that arrives after `expires_at` is still recorded against the checkout.

* If it brings the total to the full amount, the checkout changes from `expired` to `completed`, `late` is set to `true`, and a `checkout.completed` event is sent.
* If it does not, the checkout stays `expired` with `underpaid` set to `true`. You can resolve it or refund the customer.

Decide in advance how your system handles a `checkout.completed` event for an order you already cancelled.

### Payments after the price lock

When a customer chooses a token, the amount is fixed at the price at that moment. That price is held for a limited time:

| Token | Price held for |
| - | - |
| Stablecoins | No limit while the token holds its peg |
| BTC | 60 minutes |
| All others | 20 minutes |

A payment sent after that time, in a token that is not a stablecoin, is counted at the market price when it arrived. If the price has fallen, the payment may no longer cover the full amount and the checkout becomes `partial`.

## Returned payments

Sometimes a payment cannot be processed. It is returned to the sender, and the payment's `status` becomes `refunded` with the reason in `fail_reason`. A `payment.refunded` event is sent.

A returned payment does not count towards the checkout.

## Summary

| What you see | What it means | What to do |
| - | - | - |
| `completed` | Paid in full, or short by less than your allowance. | Fulfil the order. |
| `completed`, `overpaid` | Paid more than 2% over. | Fulfil the order. Refund the extra if you choose to. |
| `completed`, `late` | Paid in full after the checkout expired. | Fulfil the order, or refund it if the order is no longer available. |
| `partial` | Part of the amount has arrived and the checkout is still open. | Wait for the rest. |
| `expired`, `underpaid` | Part of the amount arrived and the checkout closed. | Resolve it or refund the customer. |
| `expired` | Nothing was paid. | Nothing. Create a new checkout if the customer wants to try again. |
| `resolved` | You accepted an underpayment. | Fulfil the order. |


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