# Generate Checkout Link

**Method:** `POST`

**Path:** `/api/checkout/v1/orders`

**Category:** Checkout

**Authentication:** Required

## Description

Generate an Infinity Checkout link. Returns a redirect URL where
the customer can complete payment on Pine Labs' hosted checkout page.


## Request Body

Content-Type: `application/json`

- `merchant_order_reference` (`string`) **required** — **Idempotency Key.** Unique identifier for the order request. Duplicate requests with the same `merchant_order_reference` will return the existing order instead of creating a new one.
- `order_amount` (`object`) **required** — Monetary amount with currency.
  - `value` (`integer`) **required** — Amount in the smallest currency unit (e.g., paisa for INR).
  - `currency` (`string`) **required** — Three-letter ISO 4217 currency code.

- `integration_mode` (`REDIRECT | IFRAME | SDK`) — The integration mode through which you want to accept payments. By default, the integration mode is set to REDIRECT. 
- `pre_auth` (`boolean`) — The pre-authorization type. false (default): When pre-authorization is not required. true: When pre-authorization is needed. 
- `allowed_payment_methods` (`string[]`) — The type of payment methods you want to offer your customers.
- `notes` (`string`) — The note you want to show against an order.
- `callback_url` (`string`) — URL to redirect your customers to specific success or failure pages.
- `purchase_details` (`object`) — Object that contains the details of customer information and product details.
  - `customer` (`object`) — Customer details for checkout.
    - `email_id` (`string`) — Customer's email address.
    - `first_name` (`string`) — Customer's first name.
    - `last_name` (`string`) — Customer's last name.
    - `customer_id` (`string`) — Unique identifier of the customer.
    - `mobile_number` (`string`) — Customer's mobile number.
    - `country_code` (`string`) — Country code of the mobile number.
    - `billing_address` (`object`) — Physical address.
      - `address1` (`string`) — Address line 1.
      - `address2` (`string`) — Address line 2.
      - `address3` (`string`) — Address line 3.
      - `pincode` (`string`) — Postal/ZIP code.
      - `city` (`string`) — City name.
      - `state` (`string`) — State or province.
      - `country` (`string`) — Country name.
      - `full_name` (`string`) — Full name of the address holder.
      - `adddress_type` (`string`) — Type of address (e.g., Home, Office).
      - `address_category` (`billing | shipping`) — Category of the address.

    - `shipping_address` (`object`) — Physical address.
      - `address1` (`string`) — Address line 1.
      - `address2` (`string`) — Address line 2.
      - `address3` (`string`) — Address line 3.
      - `pincode` (`string`) — Postal/ZIP code.
      - `city` (`string`) — City name.
      - `state` (`string`) — State or province.
      - `country` (`string`) — Country name.
      - `full_name` (`string`) — Full name of the address holder.
      - `adddress_type` (`string`) — Type of address (e.g., Home, Office).
      - `address_category` (`billing | shipping`) — Category of the address.


  - `product` (`CheckoutProduct[]`) — Mandatory for EMI Order. An array of objects that contains the list of product details.
    - `product_code` (`string`) — Unique product identifier.
    - `product_amount` (`object`) — Monetary amount with currency.
      - `value` (`integer`) **required** — Amount in the smallest currency unit (e.g., paisa for INR).
      - `currency` (`string`) **required** — Three-letter ISO 4217 currency code.




### Example Request

```json
{
  "merchant_order_reference": "112345",
  "order_amount": {
    "value": 50000,
    "currency": "INR"
  },
  "integration_mode": "REDIRECT",
  "allowed_payment_methods": [
    "CARD",
    "UPI"
  ],
  "notes": "Order1",
  "callback_url": "https://sample-callback-url",
  "purchase_details": {
    "customer": {
      "email_id": "john@example.com",
      "first_name": "Kevin",
      "last_name": "Bob",
      "customer_id": "123456",
      "mobile_number": "9876543210",
      "country_code": "91",
      "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "billing"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "billing"
      }
    },
    "product": [
      {
        "product_code": "redmi_10",
        "product_amount": {
          "value": 50000,
          "currency": "INR"
        }
      }
    ]
  }
}
```

## Responses

- `200` — Checkout link generated successfully.
- `400` — 
- `401` — 
- `422` — Unprocessable entity.
- `500` — 

### Response Schema

- `token` (`string`) — Token generated by Pine Labs for Infinity Checkout.
- `order_id` (`string`) — Unique identifier of the order in the Pine Labs Online database.
- `redirect_url` (`string`) — The checkout link generated on Pine Labs system.
- `response_code` (`integer`) — Response code of the request.
- `response_message` (`string`) — Corresponding message to the response code.

### Example Response

```json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "order_id": "v1-5757575757-aa-hU1rUd",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=REDIRECT_TOKEN",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}
```

---

Reference: https://localhost:3000/api/checkout/generate-checkout-link
