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

# Manage Invoice

> Manage, retrieve, update, approve, refund, and email invoices using Transact Bridge.

Transact Bridge provides APIs to manage the complete invoice lifecycle. Merchants can retrieve individual invoices, retrieve multiple invoices, update and approve draft invoices, process refunds, and email invoices to customers.

## Invoice Operations

| Operation                 | Description                                                        |
| ------------------------- | ------------------------------------------------------------------ |
| **Get Invoice**           | Retrieve the details of a specific invoice.                        |
| **Get All Invoice**       | Retrieve a list of invoices associated with the merchant.          |
| **Update Draft Invoice**  | Update the details of an invoice while it is in the `DRAFT` state. |
| **Approve Draft Invoice** | Approve a draft invoice so that it can proceed for collection.     |
| **Refund Invoice**        | Refund a payment associated with an invoice.                       |
| **Email Invoice**         | Send an invoice to the customer's email address.                   |

## Invoice Lifecycle

The following flow illustrates the typical invoice management lifecycle.

```mermaid theme={null}
flowchart TD
    A[Subscription Created] --> B{Billing Type}

    B -->|Prepaid| C[Subscription becomes ACTIVE after successful payment]
    B -->|Postpaid| D[Subscription becomes ACTIVE after payment method authorization]

    C --> E[Billing Period Begins]
    D --> F[Customer Uses Service During Billing Period]

    E --> G[Prepaid Invoice Generated]
    F --> H[Billing Period Ends]
    H --> I[Postpaid Draft Invoice Generated]

    G --> J[Invoice Auto-Approved]
    I --> K[Draft Invoice Webhook Sent to Merchant]

    K --> L[Merchant Reviews Draft Invoice]
    L --> M[Update Draft Invoice if Required]
    M --> N[Approve Draft Invoice]
    N --> O{Approved within 24 Hours?}

    O -->|Yes| P[Invoice Approved]
    O -->|No| P

    J --> Q[Payment Collection]
    P --> Q

    Q --> R{Payment Successful?}

    R -->|Yes| S[Invoice Paid]
    S --> T[Subscription Continues]
    T --> U[Next Billing Cycle]

    R -->|No| V[Retry / Due / Overdue / Unpaid Invoice Policies]
    V --> W{Payment Recovered?}

    W -->|Yes| S
    W -->|No| X[Apply Unpaid Invoice Policy]

    U --> B
```

## 1. Get Invoice

Use the [**Get Invoice** API](https://docs.transactbridge.com/#4f9b7a56-2989-4fd9-b99c-fb5a825c95df) to retrieve the details of a specific invoice.

This can be used when the merchant needs to:

* Retrieve invoice details.
* Check the invoice status.
* View invoice amount and currency.
* Retrieve customer and billing information.
* Check payment or transaction details associated with the invoice.

***

## 2. Get All Invoice

Use the [**Get All Invoice** API](https://docs.transactbridge.com/#46ff3912-41ef-4be8-ac89-ca1ce5da3a82) to retrieve invoices associated with the merchant.

This can be used when the merchant needs to:

* Display invoices in an internal dashboard.
* Retrieve multiple invoices.
* Track invoice statuses.
* Search or manage invoice records.

***

## 3. Update Draft Invoice

Use the [**Update Draft Invoice** API](https://docs.transactbridge.com/#d41f45ed-8581-423a-b96d-af54d339c0bf) to modify an invoice while it is in the `DRAFT` state.

A merchant can use this API when invoice details need to be updated before the invoice is approved.

### Typical Use Cases

* Update the invoice amount based on actual usage.
* Add or modify billing information.
* Update invoice items.
* Apply the final billing amount before approval.

<Note>
  Draft invoice details should be updated before the invoice is approved. Once the invoice has progressed beyond the draft stage, the applicable invoice update rules apply.
</Note>

***

## 4. Approve Draft Invoice

Use the [**Approve Draft Invoice** API](https://docs.transactbridge.com/#7acd088e-1eb1-4056-94f3-d3050e69c517) to approve a draft invoice after the merchant has completed the required updates.

Once approved, the invoice can proceed to the applicable payment collection process.

### Example Scenario

For a postpaid subscription, the merchant may receive the customer's usage information after the billing period.

For example:

| Usage         |     Amount |
| ------------- | ---------: |
| Compute usage |     ₹1,500 |
| Storage usage |       ₹500 |
| Data transfer |       ₹300 |
| **Total**     | **₹2,300** |

The merchant can update the draft invoice with the final amount and then approve it for collection.

***

## 5. Refund Invoice

Use the [**Refund Invoice** API](https://docs.transactbridge.com/#ed7480f6-f60d-43f7-a01d-f99b37bcee05) when the merchant needs to refund a payment associated with an invoice.

### Typical Use Cases

* Customer requests a refund.
* Order or service is cancelled.
* Duplicate payment.
* Incorrect amount charged.
* Merchant decides to provide a full or applicable partial refund.

### Refund Flow

```mermaid theme={null}
flowchart TD
    A[Paid Invoice]
    --> B[Refund Request]

    B --> C{Refund Successful?}

    C -->|Yes| D[Refund Processed]
    C -->|No| E[Refund Failed]
```

<Note>
  The refund amount and applicable refund rules should follow the parameters and business rules defined for the Refund Invoice API.
</Note>

***

## 6. Email Invoice

Use the [**Email Invoice** API](https://docs.transactbridge.com/#8fcf1aed-340d-44e8-97fe-8006e488154c) to send an invoice to the customer through email.

This can be used when the merchant wants to:

* Send an invoice to the customer's registered email address.
* Resend an invoice.
* Provide the customer with invoice details after payment.
* Share an invoice for record-keeping purposes.

### Email Flow

```mermaid theme={null}
sequenceDiagram
    participant M as Merchant
    participant TB as Transact Bridge
    participant C as Customer

    M->>TB: Email Invoice request
    TB->>C: Send invoice email
    C-->>TB: Invoice received
    TB-->>M: Email status
```

***
