> ## 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.

# Prepaid And Postpaid Subscription

> TransactBridge supports two primary subscription billing models: Prepaid and Postpaid.

## PREPAID

Pay first-->Use later
prepaid subscription is a billing model in which the customer pays the subscription amount in advance, and only after the payment is successful is the customer granted access to the service.
A prepaid subscription requires the customer to pay before accessing the service. The recurring amount is also collected before each renewal of the subscription.

### Configuration

**Create Subscription request**

```json theme={null}
{
  "billAtStart": true
}
```

<Info>
  If **billAtStart** is not supplied in the **Create Subscription API**, the backend treats it as `true`, and the subscription follows the prepaid model.
</Info>

Examples include Netflix, Spotify, Microsoft 365, memberships, and other services where access follows successful payment.

***

### Creation and Activation

1. The merchant calls the <a href="https://docs.transactbridge.com/#307dc665-ae10-4e43-8853-5b7f04961825">Create Subscription API </a> with `billAtStart: true`.
2. The subscription enters the **PENDING** state.
3. TransactBridge returns the subscription ID and payment URL.
4. The customer completes the initial payment using available payment methods through the hosted checkout at TransactBridge or through SDKs (Dropin or iframe).
5. After successful payment, the subscription becomes **ACTIVE** and service access can begin.

***

### Renewal and Collection

At the start of each renewal cycle, TransactBridge generates the invoice and attempts to collect the amount before the next service period begins. If collection succeeds, access continues. If it fails, the configured retry, due, overdue, and unpaid-invoice policies are applied.

> **Figure** : Prepaid subscription activation and renewal flow

```mermaid theme={null}
flowchart TB

A["Create<br/>billAtStart: true"]
--> B["PENDING"]
--> C["Hosted Checkout<br/>and Initial Payment"]

C --> D{"Payment<br/>Succeeds?"}

D -->|Yes| E["ACTIVE<br/>Service Access Begins"]

B -->|No / Expires| F["If Checkout Expires Before Payment<br/>PENDING_EXPIRED (Terminal)"]

E --> G["Next Cycle Begins<br/>Invoice Generated First"]

G --> H["Automatic Collection<br/>from Saved Mandate"]

H --> I{"Renewal<br/>Payment?"}

I -->|Success| J["Next Billing Cycle"]

J --> G

I -->|Failure| K["Retries, Due Handling,<br/>or Overdue Policy"]

K --> G
```

***

**Example:** Consider a Monthly plan

On **1st August**, the customer pays **₹999** and receives access from **1st August to 31st August**. Before the next period begins on **1st September**, the renewal amount is automatically debited. If the renewal succeeds, access will continue for the next month.

## POSTPAID

Use first-->Pay Later
a postpaid subscription is a billing model where the customer consumes the service first and pays later, at the end of the billing period.
This model is intended for businesses where the final amount depends on the customer's usage during the billing cycle, such as metered or resource-based billing.
A postpaid subscription allows the customer to use the service first and pay later. Charges are determined after the billing period based on the configured billing model, contract, or actual usage.

### Configuration

**Create Subscription request**

```json theme={null}
{
  "billAtStart": false
}
```

<Info>
  Note: No initial full amount is collected at the beginning of the billing period, but to make sure at the end of cycle platform is able to deduct the amount from customer timely, a payment mandate must be authorized by the customer for future debits.
  Examples include cloud services, utilities, and telecom postpaid plans.
</Info>

***

### Creation and Activation

1. The merchant creates the subscription with `billAtStart: false`.
2. The subscription enters the **PENDING** state.
3. TransactBridge returns the subscription ID and payment URL.
4. The customer completes the hosted checkout by adding or authorizing a payment mandate, such as a UPI AutoPay or debit/credit card Mandate.
5. After successful authorization, the subscription becomes **ACTIVE**. The customer does not need to pay the first postpaid invoice to activate the subscription.

***

### Invoice Generation and Approval

* **Billing cycle end:** TransactBridge generates an invoice at the end of the billing cycle.
* **Billing Date Anchor:** If configured, the invoice is generated on the fixed anchor date like 5th of the month irrespective of when the subscription actually starts.
* **Draft invoice webhook:** TransactBridge sends the merchant a draft invoice webhook so that the merchant can update the invoice amount based on actual usage or billing inputs.
* **Approval window:** The merchant has 24 hours to update and approve the draft invoice. If no action is taken within that period, the invoice is automatically marked as approved.
* **Collection:** After approval, TransactBridge attempts to collect the approved invoice amount using the saved payment mandate.

<Info>
  Note: **Draft invoice webhook** & **Approval window** only applies to postpaid subscriptions. Prepaid subscriptions do not have this step as there is no metered billing that would change the invoice amount.
</Info>

> **Figure**:  Postpaid usage, invoice approval, and collection flow

```mermaid theme={null}
flowchart TB

A["Create<br/>billAtStart: false"]
--> B["PENDING"]
--> C["Hosted Checkout<br/>Mandate Authorization"]
--> D["ACTIVE"]
--> E["Customer Uses<br/>Service"]
--> F["Cycle End or<br/>Billing Date Anchor"]

F --> G["Draft Invoice Generated<br/>Webhook Sent"]

G --> H["Merchant Updates &<br/>Approves Within 24 Hours"]

H --> I["Auto-Approved if No<br/>Action Within 24 Hours"]

H --> J["Collection Attempted<br>Using Saved Payment Mandate<br/>"]

I --> J

J --> K{"Payment<br/>Succeeds?"}

K -->|Yes| L["Next Billing Cycle"]

L --> F

K -->|No| M["Retries, Due Handling,<br/>Overdue, or Subscription Action<br/>as per Configuration"]

M --> F
```

**Business Example:** Cloud services

The customer uses cloud resources throughout **August**. At the end of the month, the total usage is calculated and an invoice is generated. The invoice may be updated and approved by the merchant, after which payment is collected using the customer's saved payment mandate.

***

**Comparison between Prepaid & Postpaid**

| Module                      | Prepaid                                 | Postpaid                                           |
| --------------------------- | --------------------------------------- | -------------------------------------------------- |
| Billing timing              | Before the service period               | After the service period or according to usage     |
| Activation requirement      | Successful initial payment              | Successful payment-method or mandate authorization |
| Invoice timing              | Beginning of the billing cycle          | End of the billing cycle                           |
| Create Subscription setting | `billAtStart: true`                     | \`billAtStart: false'                              |
| Typical examples            | OTT, memberships, productivity software | Cloud services, utilities, telecom postpaid plans  |

**Subscription Model Selection**

```mermaid theme={null}
%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
flowchart TB

    A([Create Subscription API])
    B[PENDING]
    C{"billAtStart?"}

    D["Prepaid<br/>Customer pays first"]
    E["Postpaid<br/>Customer authorizes mandate"]

    F([ACTIVE])

    G["Checkout not completed<br/>before <b>'pendingExpire'</b>"]
    H["PENDING_EXPIRED<br/><b>Terminal state</b>"]

    A --> B
    B --> C

    C -->|true| D
    C -->|false| E

    D --> F
    E --> F

    B -. timeout .-> G
    G --> H

    classDef pending fill:#f3f4f6,stroke:#6b7280,color:#111827;
    classDef active fill:#e8f5e9,stroke:#2e7d32,color:#111827;
    classDef prepaid fill:#e3f2fd,stroke:#1976d2,color:#111827;
    classDef postpaid fill:#e0f2f1,stroke:#00897b,color:#111827;
    classDef expired fill:#ffebee,stroke:#d32f2f,color:#111827;
    classDef decision fill:#fff8dc,stroke:#b8860b,color:#111827;

    class B pending;
    class C decision;
    class D prepaid;
    class E postpaid;
    class F active;
    class G,H expired;
```

***
