> ## Documentation Index
> Fetch the complete documentation index at: https://better-auth-razorpay.amankushwaha.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoices

> Create, retrieve, list, edit, issue, delete, cancel, and notify Razorpay invoices through the plugin endpoints.

The invoices endpoints let you create Razorpay invoices, fetch individual invoices, list historical invoices, edit draft invoices, issue them, cancel them, delete them, and send notifications.

## Create invoice

`POST /api/auth/razorpay/invoice/create`

Creates a new Razorpay invoice. You must provide at least one line item.

**Server API name:** `createInvoice`\
**Client method:** `authClient.razorpay.invoice.create(...)`

**type** `string` (default: invoice)

Invoice type. One of `invoice` or `link`.

**description** `string`

Description of the invoice.

**date** `integer`

Unix timestamp for the invoice date.

**customer\_id** `string`

Razorpay customer id. Required if `customer` is not provided.

**currency** `string` (default: INR)

ISO 4217 currency code.

**customer** `object`

Customer details when creating an invoice without an existing customer id.

**customer fields**

**customer.name** `string`

Customer name.

**customer.email** `string`

Customer email.

**customer.contact** `string`

Customer phone number.

**customer.billing\_address** `object`

Billing address with `line1`, optional `line2`, `zipcode`, `city`, optional `state`, and `country`.

**customer.shipping\_address** `object`

Shipping address with the same shape as `billing_address`.

**order\_id** `string`

Razorpay order id to link to the invoice.

**line\_items** `array` *required*

Array of line items. At least one item is required.

**line item fields**

**line\_items\[].id** `string`

Existing Razorpay item id.

**line\_items\[].name** `string`

Item name.

**line\_items\[].amount** `integer`

Item amount in subunits.

**line\_items\[].currency** `string`

Item currency.

**line\_items\[].description** `string`

Item description.

**line\_items\[].quantity** `integer`

Quantity of the item.

**expire\_by** `integer`

Unix timestamp when the invoice expires.

**sms\_notify** `boolean`

Whether to send SMS notifications.

**email\_notify** `boolean`

Whether to send email notifications.

**partial\_payment** `boolean`

Whether partial payments are allowed.

**notes** `object`

Up to 15 key-value pairs for internal metadata.

**receipt** `string`

Internal receipt identifier.

**amount** `integer`

Total invoice amount in subunits. Optional when line items are provided.

> [!NOTE]
>
> Errors: `INVOICE_CREATE_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.create({
  type: "invoice",
  description: "Monthly consulting fee",
  currency: "INR",
  line_items: [
    {
      name: "Consulting",
      amount: 50000,
      currency: "INR",
      quantity: 1,
    },
  ],
  email_notify: true,
  sms_notify: false,
});
```

```ts server.ts theme={null}
const result = await auth.api.createInvoice({
  body: {
    type: "invoice",
    description: "Monthly consulting fee",
    currency: "INR",
    line_items: [
      {
        name: "Consulting",
        amount: 50000,
        currency: "INR",
        quantity: 1,
      },
    ],
    email_notify: true,
    sms_notify: false,
  },
  headers: await headers(),
});
```

## Get invoice

`GET /api/auth/razorpay/invoice/get`

Retrieves a single Razorpay invoice by id.

**Server API name:** `fetchInvoice`\
**Client method:** `authClient.razorpay.invoice.get({ query: { invoiceId } })`

**invoiceId** `string` *required*

Razorpay invoice id.

> [!NOTE]
>
> Errors: `INVOICE_NOT_FOUND`, `INVOICE_FETCH_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.get({
  query: { invoiceId: "inv_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchInvoice({
  query: { invoiceId: "inv_XXXX" },
  headers: await headers(),
});
```

## List invoices

`GET /api/auth/razorpay/invoice/list`

Lists Razorpay invoices with pagination and optional filters.

**Server API name:** `fetchAllInvoices`\
**Client method:** `authClient.razorpay.invoice.list({ query: { ... } })`

**from** `integer`

Unix timestamp. Return invoices created after this time.

**to** `integer`

Unix timestamp. Return invoices created before this time.

**count** `integer`

Maximum number of invoices to return. Maximum value is `100`.

**skip** `integer`

Number of invoices to skip.

**type** `string`

Filter by invoice type (`invoice` or `link`).

**payment\_id** `string`

Filter by Razorpay payment id.

**receipt** `string`

Filter by receipt identifier.

**customer\_id** `string`

Filter by Razorpay customer id.

**subscription\_id** `string`

Filter by Razorpay subscription id.

> [!NOTE]
>
> Errors: `INVOICE_LIST_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.list({
  query: { count: 10, skip: 0, type: "invoice" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchAllInvoices({
  query: { count: 10, skip: 0, type: "invoice" },
  headers: await headers(),
});
```

## Edit invoice

`POST /api/auth/razorpay/invoice/edit`

Updates a draft Razorpay invoice. Razorpay only allows editing invoices that have not yet been issued.

**Server API name:** `editInvoice`\
**Client method:** `authClient.razorpay.invoice.edit(...)`

**invoiceId** `string` *required*

Razorpay invoice id to update.

**notes** `object`

New notes object.

**customer\_details** `object`

Updated customer details.

**line\_items** `array`

Updated line items array.

**expire\_by** `integer`

New expiration timestamp.

**sms\_notify** `boolean`

Updated SMS notification setting.

**email\_notify** `boolean`

Updated email notification setting.

**partial\_payment** `boolean`

Updated partial payment setting.

**receipt** `string`

Updated receipt identifier.

> [!NOTE]
>
> Errors: `INVOICE_EDIT_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.edit({
  invoiceId: "inv_XXXX",
  notes: { updated: "true" },
});
```

```ts server.ts theme={null}
const result = await auth.api.editInvoice({
  body: {
    invoiceId: "inv_XXXX",
    notes: { updated: "true" },
  },
  headers: await headers(),
});
```

## Issue invoice

`POST /api/auth/razorpay/invoice/issue`

Issues a draft Razorpay invoice, making it active and sending it to the customer.

**Server API name:** `issueInvoice`\
**Client method:** `authClient.razorpay.invoice.issue(...)`

**invoiceId** `string` *required*

Razorpay invoice id to issue.

> [!NOTE]
>
> Errors: `INVOICE_ISSUE_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.issue({
  invoiceId: "inv_XXXX",
});
```

```ts server.ts theme={null}
const result = await auth.api.issueInvoice({
  body: { invoiceId: "inv_XXXX" },
  headers: await headers(),
});
```

## Delete invoice

`POST /api/auth/razorpay/invoice/delete`

Deletes a draft Razorpay invoice.

**Server API name:** `deleteInvoice`\
**Client method:** `authClient.razorpay.invoice.delete(...)`

**invoiceId** `string` *required*

Razorpay invoice id to delete.

> [!NOTE]
>
> Errors: `INVOICE_DELETE_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.delete({
  invoiceId: "inv_XXXX",
});
```

```ts server.ts theme={null}
const result = await auth.api.deleteInvoice({
  body: { invoiceId: "inv_XXXX" },
  headers: await headers(),
});
```

## Cancel invoice

`POST /api/auth/razorpay/invoice/cancel`

Cancels an issued Razorpay invoice.

**Server API name:** `cancelInvoice`\
**Client method:** `authClient.razorpay.invoice.cancel(...)`

**invoiceId** `string` *required*

Razorpay invoice id to cancel.

> [!NOTE]
>
> Errors: `INVOICE_CANCEL_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.cancel({
  invoiceId: "inv_XXXX",
});
```

```ts server.ts theme={null}
const result = await auth.api.cancelInvoice({
  body: { invoiceId: "inv_XXXX" },
  headers: await headers(),
});
```

## Notify by invoice

`POST /api/auth/razorpay/invoice/notify`

Sends a notification for an invoice via email or SMS.

**Server API name:** `notifyByInvoice`\
**Client method:** `authClient.razorpay.invoice.notify(...)`

**invoiceId** `string` *required*

Razorpay invoice id.

**medium** `string` *required*

Notification medium. One of `email` or `sms`.

> [!NOTE]
>
> Errors: `INVOICE_NOTIFY_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.invoice.notify({
  invoiceId: "inv_XXXX",
  medium: "email",
});
```

```ts server.ts theme={null}
const result = await auth.api.notifyByInvoice({
  body: {
    invoiceId: "inv_XXXX",
    medium: "email",
  },
  headers: await headers(),
});
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.