Handling Edge Cases
Design your flows so money, status, and user experience stay consistent—even when payments aren’t perfect. Below are the core scenarios, recommended rules, and implementation notes.
1) Underpaid (received < requested)
What happens: Customer sends less than amount.
Recommended rules (pick one):
- A. Top-up flow (recommended): Mark
pending_underpaid; display/paylink to send the difference. Auto-confirm when total ≥ requested. - B. Partial credit: Mark
partial_paid; create a balance/credit for the shortfall and let customer continue with a scaled service (e.g., lower deposit).
2) Overpaid (received > requested)
What happens: Customer sends more than amount.
Recommended rules (order of preference):
- A. Auto-credit difference (recommended): Confirm invoice, credit
{received - amount}to customer account.
3) No payment / Timeout / Expired
What happens: Session created, no valid on-chain payment within window.
Recommended rules:
- Mark
expired.
4) Late payment after expiry
What happens: Funds arrive after you marked the session expired.
Recommended rules:
- Auto-reconcile: Detect late arrival → create a new transaction record linked to the expired invoice; notify merchant via callback as
late_confirmed.
5) Multiple payments to the same invoice
What happens: Customer sends multiple transfers for one invoice.
Recommended rules:
- Aggregate totals within the active window.
- If total ≥ requested → confirm; if > requested → follow Overpaid rules.
- After confirm, additional funds become extra deposit/credit.
Updated about 2 months ago
