Payments
Payments represent charge attempts associated with invoices. Each payment tracks the status, method, gateway used, and provider response.
Payment Statusesβ
pending β processing β succeeded β refunded
β β
failed partially_refunded
β
canceled
| Status | Description |
|---|---|
| pending | Awaiting processing |
| processing | Sent to gateway, awaiting response |
| succeeded | Confirmed as paid |
| failed | Declined by gateway or error |
| canceled | Manually canceled |
| partial | Partial payment received |
| refunded | Fully refunded |
| partially_refunded | Partially refunded |
Payment Flowβ
1. Automatic Charge (charge_automatically)β
Invoice finalized
β Applies credits automatically
β If credits cover everything: invoice = paid
β If not:
β Gets default payment method
β Processes payment via gateway
β Card: immediate response
β Boleto/PIX: awaits gateway webhook
β Success: invoice = paid
β Failure: schedules retry (dunning)
2. Manual Paymentβ
The operator or customer initiates payment via the dashboard or portal.
Processing a Paymentβ
When processing, the system:
- Validates that the invoice is
open - Determines the payment method (provided, saved, or default)
- Gets the organization's gateway for the payment type
- Creates a payment record with an idempotency key
- Sends the charge to the gateway
- Updates the payment with the response
Idempotencyβ
Each payment has a unique idempotency key. Duplicate requests return the existing result without reprocessing.
Special Scenariosβ
Partial Paymentβ
- The received amount is less than the total
- The invoice remains
openwith the balance updated - The customer can pay the remaining amount with another payment
Overpaymentβ
When the paid amount exceeds the invoice balance:
- The invoice amount is applied normally
- The surplus becomes a credit automatically on the customer's account
- The credit is of type
adjustmentwith description "Overpayment credit on invoice {number}" - The credit will be automatically applied to future invoices
Already Paid Invoiceβ
If the invoice was already paid when the payment is processed, the full amount becomes a credit on the customer's account.
Operationsβ
Cancel Paymentβ
Only pending payments can be canceled. For boleto/PIX, the cancellation is sent to the gateway.
Refundβ
succeeded or partially_refunded payments can be refunded:
- Full refund: Status changes to
refunded - Partial refund: Status changes to
partially_refunded - The request is sent to the gateway when available
Retryβ
failed payments can be retried. A new payment is created with the same amount, invoice, and method.
Screenshotsβ
Payment listβ
The /dashboard/payments screen aggregates all payments received, with filters by status, method, gateway, customer and period. Each row shows the related invoice, amount, gateway fee, net amount and response message.

Payment detailβ
The /dashboard/payments/[id] page shows the complete record: gateway, transaction at the provider, settled invoice, method (with the card's last 4 digits or the boleto's bank), attempt history, refunds and webhooks received.
