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

# Orders

> Create, retrieve, edit, list, and verify Razorpay orders through the plugin endpoints.

The orders endpoints let you create Razorpay orders, inspect them, list historical orders, edit notes, fetch associated payments, and verify a payment signature against an order.

## Create order

`POST /api/auth/razorpay/create-order`

Creates a new Razorpay order. The returned order id is used with Razorpay Checkout on the frontend.

**Server API name:** `createRazorpayOrder`\
**Client method:** `authClient.razorpay.createOrder(...)`

**amount** `integer` *required*

Amount in the smallest currency subunit. For INR the minimum is `100` (₹1.00).

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

ISO 4217 currency code. Three characters.

**receipt** `string`

Your internal receipt identifier. Maximum 40 characters.

**notes** `object`

Up to 15 key-value pairs. Each value must be 256 characters or fewer.

**partialPayment** `boolean` (default: false)

Whether partial payments are allowed.

**firstPaymentMinAmount** `integer`

Minimum amount for the first partial payment. Required when `partialPayment` is `true`.

**paymentCapture** `boolean` (default: true)

Whether Razorpay should auto-capture payments against this order.

**id** `string`

Razorpay order id, for example `order_XXXX`.

**amount** `integer`

Amount in subunits.

**currency** `string`

Currency code.

**receipt** `string`

Receipt identifier.

**status** `string`

Order status, for example `created`.

> [!NOTE]
>
> If `amount` is below the minimum for the currency, the endpoint returns `INVALID_ORDER_AMOUNT`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.createOrder({
  amount: 50000,
  currency: "INR",
  receipt: "receipt_001",
  notes: { userId: "user_123" },
});
```

```ts server.ts theme={null}
const result = await auth.api.createRazorpayOrder({
  body: {
    amount: 50000,
    currency: "INR",
    receipt: "receipt_001",
    notes: { userId: "user_123" },
  },
  headers: await headers(),
});
```

## Get order

`GET /api/auth/razorpay/order`

Retrieves a single Razorpay order by id.

**Server API name:** `getRazorpayOrder`\
**Client method:** `authClient.razorpay.order({ query: { id } })`

**id** `string` *required*

Razorpay order id.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.order({
  query: { id: "order_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.getRazorpayOrder({
  query: { id: "order_XXXX" },
  headers: await headers(),
});
```

## List orders

`GET /api/auth/razorpay/order/list`

Lists Razorpay orders with pagination and optional filters.

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

**from** `integer`

Unix timestamp. Return orders created after this time.

**to** `integer`

Unix timestamp. Return orders created before this time.

**count** `integer`

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

**skip** `integer`

Number of orders to skip.

**authorized** `boolean`

Filter by authorization status.

**receipt** `string`

Filter by receipt identifier.

**expand** `string`

Comma-separated list of related resources to expand.

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

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

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

## Edit order

`POST /api/auth/razorpay/order/edit`

Updates the notes on an existing Razorpay order.

**Server API name:** `editOrder`\
**Client method:** `authClient.razorpay.order.edit(...)`

**orderId** `string` *required*

Razorpay order id to update.

**notes** `object`

New notes object. Up to 15 key-value pairs, values 256 characters or fewer.

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

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

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

## Order payments

`GET /api/auth/razorpay/order/payments`

Fetches all payments associated with a given order.

**Server API name:** `fetchPaymentsForOrder`\
**Client method:** `authClient.razorpay.order.payments({ query: { orderId } })`

**orderId** `string` *required*

Razorpay order id.

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

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.order.payments({
  query: { orderId: "order_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchPaymentsForOrder({
  query: { orderId: "order_XXXX" },
  headers: await headers(),
});
```

## Verify payment

`POST /api/auth/razorpay/verify-payment`

Verifies the Razorpay payment signature and checks that the payment is captured and matches the expected order and amount. This is typically called after the customer completes Checkout and your frontend receives `razorpay_order_id`, `razorpay_payment_id`, and `razorpay_signature`.

**Server API name:** `verifyRazorpayPayment`\
**Client method:** `authClient.razorpay.verifyPayment(...)`

**razorpayOrderId** `string` *required*

Razorpay order id returned by Checkout.

**razorpayPaymentId** `string` *required*

Razorpay payment id returned by Checkout.

**razorpaySignature** `string` *required*

Signature string returned by Checkout.

**expectedAmount** `integer`

Optional. If provided, the endpoint also checks that the captured amount matches.

**valid** `boolean`

`true` only when the signature is valid, the payment is captured, the order matches, and the expected amount (if given) matches.

**paymentStatus** `string`

Razorpay payment status, for example `captured`.

**amount** `number`

Captured amount in subunits.

**currency** `string`

Currency code.

**orderId** `string | null`

The order id associated with the payment.

**reason** `string`

Present when `valid` is `false`. One of `invalid_signature`, `order_mismatch`, `amount_mismatch`, `payment_not_captured`.

> [!WARNING]
>
> Do not rely on client-side verification alone to fulfill orders. Always confirm payment on the `order.paid` webhook handler (`onOrderPaid`) before delivering goods or services.

> [!NOTE]
>
> Errors: `INVALID_PAYMENT_SIGNATURE` (bad signature), `PAYMENT_FETCH_FAILED` (unable to fetch payment from Razorpay).

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.verifyPayment({
  razorpayOrderId: "order_XXXX",
  razorpayPaymentId: "pay_YYYY",
  razorpaySignature: "signature_string",
  expectedAmount: 50000,
});
```

```ts server.ts theme={null}
const result = await auth.api.verifyRazorpayPayment({
  body: {
    razorpayOrderId: "order_XXXX",
    razorpayPaymentId: "pay_YYYY",
    razorpaySignature: "signature_string",
    expectedAmount: 50000,
  },
  headers: await headers(),
});
```


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