## 12. Automatic Refund for Abnormal Payments

Infini can automatically refund underpayments, overpayments, and late payments that meet the configured rules. When enabled, eligible crypto payments are refunded on-chain after address confirmation, and merchants receive transaction-level webhook notifications for the final result.

Automatic refund is **off by default**. Normal paid-order aggregation and settlement stay unchanged when the feature is disabled.

### 12.1 When Automatic Refund Applies

| Scenario | Behavior |
|  --- | --- |
| **Underpayment** | After the order expires, remaining paid amount that cannot complete the order may be refunded. |
| **Overpayment** | Amount paid above the order value may be refunded (subject to gas and quote-buffer rules). |
| **Late payment** | A payment received after the order is already final may be refunded if it still falls inside the confirmation window. |


Automatic refund does **not** change:

- Normal paid-order payment aggregation
- Normal merchant settlement timing or amount for successfully completed orders
- Existing wrong-currency / abnormal-repay handling outside this flow


### 12.2 Merchant Configuration

Configure automatic refund in the merchant console under **Exceptions**:

| Setting | Description |
|  --- | --- |
| **Settle paid orders only** | Master switch. `unchecked` (default): legacy behavior, no automatic refunds. `checked`: eligible underpay / overpay / late payments enter the automatic refund flow. |
| **Refund address confirmation period** | Days the payer has to submit a refund address after order expiration. Range **30–90**, default **30**. |
| **Underpayment reminders** | Whether Infini sends underpayment reminder emails to the payer. |


Configuration changes apply to unfinished orders immediately. An already-created refund’s confirmation deadline keeps the value written at creation time.

### 12.3 Refund Address Confirmation

Infini emails the payer a one-time claim link to submit a refund address on the same network/currency.

- Confirmation deadline starts from the original order `expires_at`.
- Email retries do **not** extend the deadline.


If the payer does not submit a valid address before the deadline, the refund becomes **unclaimed** and the amount is settled to the merchant instead of being refunded on-chain.

### 12.4 Amount, Gas, and Settlement Notes

- Refunds are calculated in the original paid token.
- A network-level fixed gas fee (denominated in USD/USDC and converted with the payment’s arrival rate snapshot) is deducted from the refund principal. The payer receives `received_amount = refund_amount - gas_fee`.
- If the aggregated refund value is not greater than the network gas threshold, Infini does **not** create an automatic refund record and does **not** send `auto_refund.*` webhooks; the amount is settled to the merchant.
- Amounts occupied by an in-progress or completed automatic refund are excluded from normal merchant settlement for that payment principal.
- Unclaimed refunds flip to merchant settlement after the confirmation deadline.


### 12.5 Merchant Integration Checklist

1. Enable automatic refund in **Payment Exceptions**.
2. Set `refund_confirmation_period_days` (30–90).
3. Subscribe webhook endpoints to:
  - `auto_refund.completed`
  - `auto_refund.unclaimed`
4. Handle both events idempotently with `X-Webhook-Event-Id` / payload `event_id`.
5. Use order / payment detail views in the merchant console for operational follow-up; webhook payloads remain the integration source of truth for automation.


See [Webhook](/docs/en/7-webhook) for event payload fields and examples.