---
updatedAt: 2026-11-25T22:22:33.000Z
agentTools:
  projectIndex: https://api-docs.open-co.com/llms.txt
---

# Collection Flow

This document describes the complete collection lifecycle for the BNPL White-Label system — from listing active loans and invoices to payment processing, renegotiation, and webhook notifications.

## Overview

After loan disbursement (application status `FUNDED`), the collection system manages:

* **Loan & invoice tracking** — list loans, payment plans, and monthly invoices
* **Payment generation** — PIX QR Codes and Boletos for invoice or installment payment
* **Batch payments** — pay multiple invoices at once with automatic discount
* **Balance & settlement** — outstanding balance and early settlement calculation
* **Renegotiation** — settlement of overdue installments with a discount, offered by Open Co (see the [Renegotiation Flow](renegotiation_flow.md) guide)
* **Webhooks** — receive notifications when installment or invoice statuses change

***

## Invoice vs Payment Plan

> This is one of the most common questions from integration partners. Understanding the difference is essential.

A **Payment Plan** and an **Invoice** serve different purposes:

|                  | Payment Plan                            | Invoice (Fatura)                                     |
| ---------------- | --------------------------------------- | ---------------------------------------------------- |
| **Scope**        | One loan only                           | All loans of a customer                              |
| **Created when** | Loan is disbursed (FUNDED)              | Monthly, automatically                               |
| **Contains**     | All installments of that specific loan  | Installments from *all* loans due in the same month  |
| **Used for**     | Tracking repayment of a single purchase | Generating a single monthly payment for the customer |
| **Analogy**      | Individual purchase receipt             | Credit card monthly statement                        |

**Visual example:**

```
Customer bought 2 items on BNPL:

  Loan A: Sneakers (4x R$100)
    └── Payment Plan A
          ├── Installment A1 (Feb) ✅ PAID
          ├── Installment A2 (Mar) ◄──────────┐
          ├── Installment A3 (Apr)             │ grouped into
          └── Installment A4 (May)             │
                                               │
  Loan B: Headphones (3x R$150)               │
    └── Payment Plan B                        │
          ├── Installment B1 (Mar) ◄──────────┤
          ├── Installment B2 (Apr)             │
          └── Installment B3 (May)             │
                                               ▼
                                    ┌─────────────────────┐
                                    │  March Invoice       │
                                    │  R$ 100 + R$ 150     │
                                    │  = R$ 250 total      │
                                    │  Due: March 15       │
                                    │  (single PIX/Boleto) │
                                    └─────────────────────┘
```

The customer pays **one invoice per month** (R$ 250) instead of paying each loan separately.

***

## Collection Endpoints

### Loans

| Endpoint                    | Method | Description                                           |
| --------------------------- | ------ | ----------------------------------------------------- |
| `/person/{person_id}/loans` | GET    | List loans with nested payment plans and installments |

### Invoices

| Endpoint                                | Method | Description                                                   |
| --------------------------------------- | ------ | ------------------------------------------------------------- |
| `/invoices`                             | GET    | List invoices (filterable by status, period)                  |
| `/invoices/{invoice_id}`                | GET    | Get invoice details with breakdown by loan                    |
| `/invoices/{invoice_id}/payment-method` | POST   | Generate PIX or Boleto for an invoice                         |
| `/invoices/batch-payment`               | POST   | Pay invoices in batch (discount may apply per partner config) |

### Payment Plans & Installments

| Endpoint         | Method | Description                          |
| ---------------- | ------ | ------------------------------------ |
| `/payment-plans` | GET    | List payment plans for a customer    |
| `/installments`  | GET    | List installments for a payment plan |

### Charges & Balance

| Endpoint                                | Method | Description                                               |
| --------------------------------------- | ------ | --------------------------------------------------------- |
| `/charging`                             | POST   | Create charge (PIX or Boleto) for specific installments   |
| `/application/{id}/outstanding-balance` | GET    | Get outstanding balance with early settlement calculation |

### Renegotiation

| Endpoint                                   | Method | Description                                                           |
| ------------------------------------------ | ------ | --------------------------------------------------------------------- |
| `/renegotiation`                           | GET    | List a customer's renegotiations (filter by status, paginated)        |
| `/renegotiation/{renegotiation_id}`        | GET    | Get the offer or agreement, including the PIX while `PENDING_PAYMENT` |
| `/renegotiation/{renegotiation_id}/accept` | POST   | Accept an offer (offer-first flow) and get the PIX                    |

Offers are created by Open Co; the partner shows them and lets the customer pay. See the [Renegotiation Flow](renegotiation_flow.md) guide for the two issuance flows, statuses, webhooks and rules.

### Webhooks

All webhook endpoints are in the **Webhook** section of the API Reference.

| Endpoint                       | Method | Description                                           |
| ------------------------------ | ------ | ----------------------------------------------------- |
| `/webhooks/payment`            | POST   | Payment confirmation from payment provider            |
| `/webhooks/installment-status` | POST   | Installment status change notification (from QI Tech) |
| `/webhooks/invoice-status`     | POST   | Invoice status change notification                    |
| `/webhooks/application-status` | POST   | Application status change notification                |
| `/webhooks/refund-status`      | POST   | Refund status change notification                     |

***

## Collection Modes

The system supports two collection modes:

### Invoice Mode (Recommended)

Loans are grouped into **monthly invoices (faturas)**, similar to a credit card statement. The customer receives a single invoice per month containing all installments due in that period.

```
Customer has 3 active loans:
  Loan A: 4x R$ 100  (installments due on the 15th)
  Loan B: 3x R$ 150  (installments due on the 15th)
  Loan C: 6x R$ 50   (installments due on the 15th)

March Invoice:
  ├── Loan A — Installment 2/4: R$ 100.00
  ├── Loan B — Installment 1/3: R$ 150.00
  └── Loan C — Installment 3/6: R$ 50.00
  ────────────────────────────────────────
  Total: R$ 300.00  |  Due: March 15
```

**Flow:**

1. `GET /invoices?person_id={id}&status=OPEN` — list open invoices
2. `GET /invoices/{invoice_id}` — show invoice detail with per-loan breakdown
3. `POST /invoices/{invoice_id}/payment-method` with `{"payment_method": "PIX"}` — generate PIX QR Code
4. Customer pays → webhook notifies → invoice status updates

### Standalone Mode

Each loan is serviced individually. Installments are charged separately per loan using the `/charging` endpoint.

**Flow:**

1. `GET /payment-plans?person_id={id}` — list active payment plans
2. `GET /installments?payment_plan_id={id}` — list installments
3. `POST /charging` — generate PIX or Boleto for specific installments
4. Customer pays → `POST /webhooks/payment` → installment status updates

***

## Main Flow: Invoice Payment

```
┌──────────────────┐
│    Customer       │
│    opens app      │
└────────┬─────────┘
         │
         │ 1. List active loans
         ▼
┌──────────────────────────────┐
│ GET /person/{id}/loans       │
│ Returns loans + payment      │
│ plans + installments         │
└────────┬─────────────────────┘
         │
         │ 2. List open invoices
         ▼
┌──────────────────────────────┐
│ GET /invoices                │
│ ?person_id={id}&status=OPEN  │
│ Returns monthly invoices     │
└────────┬─────────────────────┘
         │
         │ 3. Customer selects invoice
         ▼
┌──────────────────────────────┐
│ GET /invoices/{id}           │
│ Detail with per-loan         │
│ breakdown of items           │
└────────┬─────────────────────┘
         │
         │ 4. Generate payment
         ▼
┌──────────────────────────────┐
│ POST /invoices/{id}/          │
│      payment-method           │
│ {"payment_method": "PIX"}     │
│                               │
│ Returns:                      │
│  • pix_qr_code               │
│  • pix_qr_code_base64        │
│  • pix_copy_paste             │
│  • expires_at                 │
└────────┬─────────────────────┘
         │
         │ 5. Customer pays via PIX
         ▼
┌──────────────────────────────┐
│ Payment Provider confirms    │
│                              │
│ POST /webhooks/payment       │
│ POST /webhooks/              │
│      installment-status      │
│ POST /webhooks/              │
│      invoice-status          │
└────────┬─────────────────────┘
         │
         ▼
┌──────────────────────────────┐
│  Invoice status → PAID       │
│  Installments → PAID         │
│  Payment plan updated        │
└──────────────────────────────┘
```

***

## Batch Payment Flow

Customers can pay **multiple invoices at once**. A discount may apply depending on partner configuration.

```
┌──────────────────────────────┐
│ GET /invoices                │
│ ?person_id={id}              │
│ Returns: 3 open invoices     │
│  • March:  R$ 300.00         │
│  • April:  R$ 300.00         │
│  • May:    R$ 250.00         │
└────────┬─────────────────────┘
         │
         │ Customer selects all 3
         ▼
┌──────────────────────────────┐
│ POST /invoices/batch-payment │
│                              │
│ Request:                     │
│  invoice_ids: [mar, apr, may]│
│  payment_method: PIX         │
│                              │
│ Response:                    │
│  original_amount:  R$ 850.00 │
│  total_amount:     R$ 850.00 │
│  discount_amount:  R$   0.00 │
│  final_amount:     R$ 850.00 │
│  pix_qr_code: "..."         │
└──────────────────────────────┘
```

> `original_amount` is the face value of all selected invoices at batch creation time. `total_amount` reflects current remaining balances (including any fines or interest). `discount_amount` depends on partner configuration and may be 0. `final_amount = total_amount − discount_amount`.

***

## Overdue Payment Flow

When installments become overdue, the system applies two phases: a **grace period** (`OVERDUE_GRACE`) where the normal BNPL limit is maintained and no fines apply, followed by a **penalty period** (`OVERDUE_PENALTY`) where the BNPL limit is zeroed and fines (multa, max 2%) and daily late interest (juros mora, max 1%/month) are applied.

```
┌──────────────────────────────┐
│ Installment past due date    │
│                              │
│ Webhook received:            │
│ POST /webhooks/              │
│      installment-status      │
│ new_status: OVERDUE_GRACE    │
│ (normal limit, no fine)      │
└────────┬─────────────────────┘
         │
         │ Grace period expires
         ▼
┌──────────────────────────────┐
│ POST /webhooks/              │
│      installment-status      │
│ new_status: OVERDUE_PENALTY  │
│                              │
│ Invoice also updates:        │
│ POST /webhooks/invoice-status│
│ new_status: OVERDUE_PENALTY  │
│                              │
│ fine_amount: 2% of overdue   │
│ interest: 0.033%/day         │
└────────┬─────────────────────┘
         │
         │ Check outstanding balance
         ▼
┌──────────────────────────────┐
│ GET /application/{id}/       │
│     outstanding-balance      │
│                              │
│ Returns:                     │
│  outstanding_balance: 285.48 │
│  remaining_principal: 278.48 │
│  fine_amount:           2.00 │
│  late_interest:         5.00 │
│  early_settlement:    270.00 │
│  pending_installments:     2 │
└────────┬─────────────────────┘
         │
         │ Option A: Pay overdue invoice directly
         │ Option B: Settle with a renegotiation offer (issued by Open Co)
         ▼
┌──────────────────────────────┐
│ Webhook received:            │
│ renegotiation.status_change  │
│ status: OFFERED              │
│ (or PENDING_PAYMENT, with    │
│  the PIX already generated)  │
└────────┬─────────────────────┘
         │
         ▼
┌──────────────────────────────┐
│ GET /renegotiation/{id}      │
│                              │
│ Returns:                     │
│  invoices and installments   │
│  final_amount                │
│  expires_at (5 days)         │
└────────┬─────────────────────┘
         │
         │ Offer without a PIX: customer accepts
         ▼
┌──────────────────────────────┐
│ POST /renegotiation/{id}/    │
│      accept                  │
│                              │
│ Returns:                     │
│  status: PENDING_PAYMENT     │
│  pix (for payment)           │
└────────┬─────────────────────┘
         │
         │ Customer pays the PIX
         ▼
┌──────────────────────────────┐
│ Webhooks:                    │
│ payment.status_change (PAID) │
│ invoice.status_change        │
│ renegotiation.status_change  │
│  status: PAID                │
│                              │
│ Overdue invoices are settled │
└──────────────────────────────┘
```

Renegotiation offers are issued by Open Co, in one of two ways: an offer without a PIX (`OFFERED`, valid for 5 days, with the PIX generated when the customer accepts) or a renegotiation created already with the PIX (`PENDING_PAYMENT`, with no accept step). While a renegotiation is `OFFERED` or `PENDING_PAYMENT`, do not offer the regular invoice payment. See the [Renegotiation Flow](renegotiation_flow.md) guide for statuses, endpoints, webhooks and rules.

***

## Outstanding Balance & Early Settlement

For customers wanting to pay off their loan early (liquidacao antecipada):

```
GET /application/{id}/outstanding-balance?calculation_date=2026-03-15
```

**Response:**

```json
{
  "application_id": "6ffd813a-1e88-4a4a-a892-758ca310e607",
  "calculation_date": "2026-03-15",
  "remaining_principal": 278.48,
  "remaining_interest": 5.00,
  "fine_amount": 0,
  "late_interest": 0,
  "outstanding_balance": 283.48,
  "pending_installments": 3,
  "early_settlement_amount": 270.00,
  "early_settlement_discount": 13.48
}
```

The `early_settlement_amount` reflects the discounted value for paying off the entire loan before the original term.

***

## Installment Statuses

There are two distinct installment status vocabularies depending on the context:

### API response (`GET /person/{id}/loans`, payment plan)

These are the statuses returned by the BNPL WL API in the payment plan installment list:

| Status      | Description                         |
| ----------- | ----------------------------------- |
| `OPEN`      | Created, awaiting processing        |
| `PENDING`   | Scheduled, not yet due              |
| `PAID`      | Paid in full                        |
| `OVERDUE`   | Past due date, unpaid               |
| `CANCELLED` | Cancelled due to a full loan refund |

### QI Tech inbound webhook (`POST /webhooks/installment-status`)

These are the statuses sent by QI Tech when an installment payment event occurs. They are more granular than the API statuses:

| Status                 | Description                                                                               |
| ---------------------- | ----------------------------------------------------------------------------------------- |
| `WAITING_PAYMENT`      | Payment initiated but not yet confirmed by the financial institution                      |
| `PAID`                 | Paid on time and in full                                                                  |
| `PAID_EARLY`           | Paid before the due date                                                                  |
| `PAID_PARTIAL`         | Partially paid on or before due date                                                      |
| `OVERDUE_GRACE`        | Past due date; grace period active; no fines or interest yet                              |
| `OVERDUE_PENALTY`      | Past due date beyond the grace period; BNPL limit zeroed; fines and interest accrue daily |
| `PAID_OVERDUE`         | Paid in full after due date (includes fine and late interest)                             |
| `PAID_PARTIAL_OVERDUE` | Partially paid after due date                                                             |

**Common transitions (QI Tech webhook):**

* `PENDING` → `PAID` (normal on-time payment)
* `PENDING` → `OVERDUE_GRACE` (missed due date, normal limit maintained, no fines yet)
* `OVERDUE_GRACE` → `OVERDUE_PENALTY` (grace period expired, fines and interest apply)
* `OVERDUE_GRACE` → `PAID` (payment received during grace period, no fines)
* `PENDING` → `PAID_EARLY` (paid before due date)
* `OVERDUE_PENALTY` → `PAID_OVERDUE` (late payment with fine/interest)

***

## Invoice Statuses

| Status            | Description                                                                                                         |
| ----------------- | ------------------------------------------------------------------------------------------------------------------- |
| `OPEN`            | Invoice is open; has unpaid items, not yet overdue                                                                  |
| `CLOSED`          | Billing period ended with zero remaining balance (terminal state)                                                   |
| `PAID`            | All active items are paid — or all items were cancelled (zero-balance)                                              |
| `OVERDUE_GRACE`   | Past due date; within the grace period; normal BNPL limit applies; no fines or interest yet                         |
| `OVERDUE_PENALTY` | Past due date beyond the grace period; BNPL limit zeroed; fines (multa) and interest (juros mora) are being applied |

> Partial payments keep the invoice in `OPEN` status with an updated `remaining_amount`. There is no `PARTIALLY_PAID` status — use `remaining_amount` to determine how much is still owed.

***

## Webhook Events

The system sends/receives five types of webhook notifications:

### Payment Webhook (`POST /webhooks/payment`)

Called by the payment provider (QI Tech) when a PIX or Boleto payment is confirmed.

```json
{
  "person_id": "A001",
  "installment_id": "inst-002",
  "amount": 139.24,
  "payment_method": "PIX",
  "external_payment_id": "pay-ext-12345",
  "payment_date": "2026-03-13"
}
```

### Installment Status Webhook (`POST /webhooks/installment-status`)

Called by QI Tech when an installment status changes (e.g., PENDING → OVERDUE\_GRACE).

```json
{
  "person_id": "A001",
  "webhook_type": "installment.status_change",
  "installment_id": "inst-002",
  "previous_status": "PENDING",
  "new_status": "OVERDUE_GRACE",
  "event_datetime": "2026-03-14T00:00:01Z",
  "data": {
    "amount": 139.24,
    "paid_amount": 0,
    "due_date": "2026-03-13",
    "fine_amount": 0,
    "interest_amount": 0
  }
}
```

### Invoice Status Webhook (`POST /webhooks/invoice-status`)

Triggered when an invoice transitions between states.

```json
{
  "person_id": "A001",
  "webhook_type": "invoice.status_change",
  "invoice_id": "inv-2026-03-001",
  "previous_status": "OPEN",
  "new_status": "PAID",
  "event_datetime": "2026-03-13T14:30:00Z",
  "data": {
    "total_amount": 278.48,
    "paid_amount": 278.48,
    "due_date": "2026-03-15",
    "payment_method": "PIX"
  }
}
```

### Application Status Webhook (`POST /webhooks/application-status`)

Triggered when an application transitions between states (e.g., SUBMITTED\_TO\_FI → FUNDED). Useful for tracking application progress when a create or charge request times out.

```json
{
  "person_id": "A001",
  "webhook_type": "application.status_change",
  "application_id": "6ffd813a-1e88-4a4a-a892-758ca310e607",
  "previous_status": "SUBMITTED_TO_FI",
  "new_status": "FUNDED",
  "event_datetime": "2026-01-20T12:00:00Z"
}
```

### Refund Status Webhook (`POST /webhooks/refund-status`)

Triggered when a refund is created or its status changes.

```json
{
  "webhook_type": "refund.status_change",
  "refund_id": "9abc1234-def5-6789-abcd-ef0123456789",
  "application_id": "6ffd813a-1e88-4a4a-a892-758ca310e607",
  "person_id": "A001",
  "status": "PENDING",
  "refund_amount": 500.00,
  "payout_amount": 0.00,
  "transfer_amount": 0.00,
  "order_reference": "order_001",
  "partner_reference_id": "partner-refund-001",
  "created_at": "2026-01-22T11:00:00",
  "completed_at": null
}
```

When `status` is `ACTION_REQUIRED`, the PIX key provided is invalid or missing. The partner must call `PATCH /applications/{id}/refunds/{refund_id}` with a valid PIX key to unblock the refund.

**Key fields:**

* `refund_amount` — amount being refunded (set by partner at creation)
* `payout_amount` — total already paid by the consumer on this loan
* `transfer_amount` — `max(0, payout_amount − loan_amount)`: surplus to transfer back via PIX; 0 when the consumer has not overpaid
* `completed_at` — populated only when `status` is `COMPLETED`

### Renegotiation Webhooks (outbound)

Open Co also sends two renegotiation webhooks to your `webhook_url`, with the same signature as the other outbound webhooks:

* `renegotiation.status_change` — every status change. The first event means the renegotiation was created: `OFFERED` (offer without a PIX) or `PENDING_PAYMENT` (created already with the PIX).
* `renegotiation.offer_updated` — a variation outside the standard flow: Open Co changed the amount or validity of an `OFFERED` offer.

The agreement's PIX payment arrives as the usual `payment.status_change` (now with `renegotiation_id`) and one `invoice.status_change` per settled invoice. See the [Renegotiation Flow](renegotiation_flow.md) guide.

***

## Integration with QI Tech

The collection system integrates with QI Tech's banking infrastructure:

| QI Tech API                | Used For                                                      |
| -------------------------- | ------------------------------------------------------------- |
| **Debt Simulation**        | Calculate installment schedules, interest, IOF                |
| **Payment Generation**     | Create PIX QR Codes and Boletos                               |
| **Payment Notification**   | Webhook callbacks when payments are confirmed                 |
| **Installment Management** | Track installment statuses, calculate fines and late interest |

**References:**

* [QI Tech Debt Simulation](https://docs.qitech.com.br/documentation/emissao_de_divida/simulacao_de_divida_novo/)
* [QI Tech Payment Processing](https://docs.qitech.com.br/documentation/pagamentos/)

***

## Error Handling

| Error Code                    | Description                                                               | Resolution                   |
| ----------------------------- | ------------------------------------------------------------------------- | ---------------------------- |
| `PERSON_NOT_FOUND`            | Customer not found                                                        | Verify `person_id`           |
| `INVOICE_NOT_FOUND`           | Invoice doesn't exist                                                     | Verify `invoice_id`          |
| `INVOICE_ALREADY_PAID`        | Invoice is already fully paid                                             | No action needed             |
| `PAYMENT_PLAN_NOT_FOUND`      | Payment plan doesn't exist                                                | Verify `payment_plan_id`     |
| `INSTALLMENT_NOT_FOUND`       | Installment doesn't exist                                                 | Verify `installment_id`      |
| `INVALID_INSTALLMENT_STATE`   | Installment in invalid state for this operation                           | Check current status first   |
| `RENEGOTIATION_NOT_FOUND`     | Renegotiation doesn't exist for this partner                              | Verify `renegotiation_id`    |
| `RENEGOTIATION_NOT_AVAILABLE` | The renegotiation is `PAID`, expired or `CANCELLED` and can't be accepted | Wait for a new offer         |
| `DUPLICATE_PAYMENT`           | Payment already processed                                                 | Idempotency — safe to ignore |

**Example error response:**

```json
{
  "error": "INVALID_INSTALLMENT_STATE",
  "message": "One or more installments are already paid",
  "timestamp": "2026-01-21T10:00:00Z"
}
```