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

# Invoice Types

Modem Pay automatically determines your invoice type based on the data you provide.

## Simple Invoices

Simple invoices contain a single total amount without itemized breakdown. They're automatically created when you **don't include line items**.

### When to Use Simple Invoices

* **Fixed Subscription Plans** - Monthly/annual fees
* **Membership Dues** - Gym memberships, club fees
* **Service Subscriptions** - SaaS with flat-rate pricing
* **Donations** - Single amount payments
* **Simple Service Fees** - Consulting retainers

### Example: Monthly SaaS Subscription

<CodeGroup>
  ```typescript nodejs theme={null}
  const invoice = await modempay.invoices.create({
    amount: 2500,
    customer_email: "user@modempay.com",
    customer_name: "Modem Pay Inc", 
    due_date: "2025-12-31",
    notes: "Pro Plan - December 2025"
  });
  ```
</CodeGroup>

### With Discounts

<CodeGroup>
  ```typescript nodejs theme={null}
  const invoice = await modempay.invoices.create({
    amount: 5000,
    customer: "b7ca54db-a2ad-4153-8603-d8873dbffc2d",
    discount: {
      type: "percentage",
      amount: 20 // 20% discount
    }
  });

  // Calculation:
  // Subtotal: 5000
  // Discount: 1000 (20% of 5000) 
  // Total: 4000
  ```
</CodeGroup>

<Info>
  For simple invoices, the `amount` becomes the subtotal, and discounts calculate the final total.
</Info>

## Professional Invoices

Professional invoices include detailed line items. They're automatically created when you **include the `line_items` array**.

### When to Use Professional Invoices

* **Usage-Based Billing** - Metered services, API calls
* **Multi-Product Subscriptions** - Bundles with multiple components
* **Tiered Pricing** - Base fee + overage charges
* **Product Sales** - E-commerce with multiple items
* **Transparent Pricing** - When customers need breakdowns

### Example: Usage-Based Subscription

<CodeGroup>
  ```typescript nodejs theme={null}
  const invoice = await modempay.invoices.create({
    amount: 0,
    customer_email: "api-customer@tech.com",
    customer_name: "Tech Guru",
    line_items: [
      {
        item: "API Calls",
        quantity: 150000,
        unit_price: 0.02
      },
      {
        item: "Storage (GB)",
        quantity: 50,
        unit_price: 100
      },
      {
        item: "Pro Plan Base Fee",
        quantity: 1, 
        unit_price: 2000
      }
    ]
  });

  // Auto-calculated:
  // API Calls: 150,000 × 0.02 = 3000
  // Storage: 50 × 100 = 5000  
  // Base Fee: 1 × 2000 = 2000
  // Total: 10,000
  ```
</CodeGroup>

<Tip>
  The `amount` parameter is ignored when line items are present. Total is calculated from line items.
</Tip>

## Discount Types

### Percentage Discount

```typescript theme={null}
{
  discount: {
    type: "percentage",
    amount: 15 // 15% off
  }
}
```

### Fixed Amount Discount

```typescript theme={null}
{
  discount: {
    type: "fixed", 
    amount: 500 // 500 off
  }
}
```

## Choosing the Right Type

**Simple Invoice Checklist**

* Single product/service
* Fixed, predictable pricing
* No itemization needed
* Flat subscription fee

**Professional Invoice Checklist**

* Multiple products/services
* Usage-based or metered billing
* Customer needs breakdown
* Variable pricing
