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

# Create Payment

> Create a new INR payment order and generate a UPI QR code.

## Endpoint

```
POST /api/merchant/inr/create
```

## Headers

| Header         | Required | Description                |
| -------------- | -------- | -------------------------- |
| `x-api-key`    | Yes      | Your CWMPay API key        |
| `Content-Type` | Yes      | Must be `application/json` |

## Request Body

| Field            | Type      | Required | Description                                                                              |
| ---------------- | --------- | -------- | ---------------------------------------------------------------------------------------- |
| `amount`         | `integer` | Yes      | Payment amount in INR (e.g. `499`)                                                       |
| `currency`       | `string`  | Yes      | Must be `"INR"`                                                                          |
| `customer`       | `object`  | No       | Customer details                                                                         |
| `customer.name`  | `string`  | No       | Customer name (max 50 chars)                                                             |
| `customer.email` | `string`  | No       | Customer email                                                                           |
| `customer.phone` | `string`  | No       | Customer phone (Indian 10-digit)                                                         |
| `redirectUrl`    | `string`  | No       | HTTPS URL to redirect after payment                                                      |
| `webhookUrl`     | `string`  | No       | HTTPS URL to receive payment notifications. Overrides dashboard webhook URL if provided. |

## Example Request

```bash theme={null}
curl -X POST https://api.cwmpay.in/api/merchant/inr/create \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "amount": 499,
    "currency": "INR",
    "customer": {
      "name": "Rahul Sharma",
      "email": "rahul@example.com",
      "phone": "9876543210"
    },
    "webhookUrl": "https://yoursite.com/webhook"
  }'
```

## Response

```json theme={null}
{
  "success": true,
  "message": "Payment created successfully!",
  "data": {
    "orderId": "CWMPay_1784798312415_04575dc339d7",
    "amount": 499,
    "finalAmount": 499.37,
    "currency": "INR",
    "upiString": "upi://pay?pa=bharatpe@fbpe&pn=CWMPay&am=499.37&tn=CWMPay_1784798312415",
    "qrCode": "data:image/png;base64,iVBORw0KGgo...",
    "status": "pending",
    "expiresAt": 1784798913288
  }
}
```

## Response Fields

| Field         | Type      | Description                                       |
| ------------- | --------- | ------------------------------------------------- |
| `orderId`     | `string`  | CWMPay generated order ID                         |
| `amount`      | `integer` | Original amount you passed                        |
| `finalAmount` | `float`   | Unique decimal amount for payment fingerprinting  |
| `currency`    | `string`  | `"INR"`                                           |
| `upiString`   | `string`  | Deep link to open UPI app directly (mobile)       |
| `qrCode`      | `string`  | Base64 encoded QR code image                      |
| `status`      | `string`  | `"pending"`                                       |
| `expiresAt`   | `integer` | Unix timestamp — payment expires after 10 minutes |

## Displaying to Customer

```javascript theme={null}
// Desktop — show QR code
const img = document.createElement('img');
img.src = response.data.qrCode;
document.getElementById('qr-container').appendChild(img);

// Mobile — open UPI app directly
const btn = document.createElement('a');
btn.href = response.data.upiString;
btn.innerText = 'Pay with UPI';
document.getElementById('pay-btn').appendChild(btn);
```

<Info>
  Always display `amount` (₹499) to the customer — never `finalAmount` (₹499.37). The QR code already has the correct amount encoded. Showing `finalAmount` will confuse customers.
</Info>

<Warning>
  Payment expires in **10 minutes**. After expiry, create a new payment order. Use `expiresAt` to show a countdown timer to your customer.
</Warning>

## Payment Flow

<Steps>
  <Step title="Create Payment">
    Call this endpoint to get QR code and UPI string.
  </Step>

  <Step title="Show to Customer">
    Display QR code on desktop. Show UPI deep link button on mobile.
  </Step>

  <Step title="Customer Pays">
    Customer scans QR or clicks the UPI button and completes payment.
  </Step>

  <Step title="Verify Payment">
    Call [Verify Payment](/inr/verify-payment) with the UTR number, or wait for the automatic webhook.
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Verify Payment" icon="circle-check" href="/inr/verify-payment">
    Verify payment with UTR number
  </Card>

  <Card title="Webhooks" icon="webhook" href="/webhooks/overview">
    Receive automatic payment notifications
  </Card>
</CardGroup>
