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

# Create Razorpay Order

> Create a local Razorpay Order record with the caller's user context, create a Razorpay Order, and return Checkout options for the client-side Razorpay Checkout script.



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/payments.yaml post /api/payments/razorpay/{environment}/orders
openapi: 3.0.3
info:
  title: Insforge Payments API
  version: 1.0.0
  description: >-
    Provider-specific Stripe and Razorpay payment setup, runtime flows, catalog
    management, sync, and webhook projections
servers: []
security: []
tags:
  - name: Stripe Payments
    description: >-
      Stripe Checkout, Billing Portal, catalog, sync, customer, subscription,
      and transaction routes
  - name: Razorpay Payments
    description: >-
      Razorpay Orders, Subscriptions, catalog, manual webhook setup, sync,
      customer, and transaction routes
  - name: Payment Webhooks
    description: Provider webhook ingestion routes
paths:
  /api/payments/razorpay/{environment}/orders:
    post:
      tags:
        - Razorpay Payments
      summary: Create Razorpay Order
      description: >-
        Create a local Razorpay Order record with the caller's user context,
        create a Razorpay Order, and return Checkout options for the client-side
        Razorpay Checkout script.
      parameters:
        - $ref: '#/components/parameters/EnvironmentPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRazorpayOrderBody'
            example:
              amount: 50000
              currency: INR
              receipt: order-team_123-pro
              description: Pro upgrade
              subject:
                type: team
                id: team_123
              customerEmail: buyer@example.com
      responses:
        '201':
          description: Razorpay Order created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateRazorpayOrderResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  parameters:
    EnvironmentPath:
      name: environment
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/PaymentEnvironment'
      description: Payment provider environment.
  schemas:
    CreateRazorpayOrderBody:
      type: object
      required:
        - amount
        - currency
      additionalProperties: false
      description: Notes keys starting with insforge_ are reserved and rejected.
      properties:
        amount:
          type: integer
          minimum: 1
          example: 50000
        currency:
          type: string
          minLength: 3
          maxLength: 3
          example: INR
        receipt:
          type: string
          nullable: true
          minLength: 1
          maxLength: 40
        description:
          type: string
          nullable: true
          maxLength: 2048
        subject:
          $ref: '#/components/schemas/BillingSubject'
        customerName:
          type: string
          nullable: true
          minLength: 1
          maxLength: 255
        customerEmail:
          type: string
          format: email
          nullable: true
        customerContact:
          type: string
          nullable: true
          minLength: 1
          maxLength: 32
        callbackUrl:
          type: string
          format: uri
          nullable: true
        notes:
          description: >-
            Native Razorpay notes. Use stable app identifiers such as `order_id`
            for webhook fulfillment triggers.
          allOf:
            - $ref: '#/components/schemas/Metadata'
    CreateRazorpayOrderResponse:
      type: object
      required:
        - order
        - checkoutOptions
      properties:
        order:
          $ref: '#/components/schemas/RazorpayOrder'
        checkoutOptions:
          type: object
          required:
            - key
            - amount
            - currency
            - order_id
            - prefill
          additionalProperties: false
          properties:
            key:
              type: string
              example: rzp_test_xxx
            amount:
              type: integer
              minimum: 1
            currency:
              type: string
              example: INR
            order_id:
              type: string
              example: order_123
            name:
              type: string
              nullable: true
            description:
              type: string
              nullable: true
            callback_url:
              type: string
              nullable: true
            prefill:
              $ref: '#/components/schemas/RazorpayCheckoutPrefill'
    PaymentEnvironment:
      type: string
      enum:
        - test
        - live
    BillingSubject:
      type: object
      required:
        - type
        - id
      additionalProperties: false
      properties:
        type:
          type: string
          minLength: 1
          maxLength: 100
          example: team
        id:
          type: string
          minLength: 1
          maxLength: 255
          example: team_123
    Metadata:
      type: object
      additionalProperties:
        type: string
    RazorpayOrder:
      type: object
      required:
        - id
        - environment
        - status
        - subjectType
        - subjectId
        - customerName
        - customerEmail
        - customerContact
        - orderId
        - receipt
        - amount
        - amountPaid
        - amountDue
        - currency
        - attempts
        - verifiedPaymentId
        - verifiedAt
        - notes
        - lastError
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
        environment:
          $ref: '#/components/schemas/RazorpayEnvironment'
        status:
          $ref: '#/components/schemas/RazorpayOrderStatus'
        subjectType:
          type: string
          nullable: true
        subjectId:
          type: string
          nullable: true
        customerName:
          type: string
          nullable: true
        customerEmail:
          type: string
          format: email
          nullable: true
        customerContact:
          type: string
          nullable: true
        orderId:
          type: string
          nullable: true
          example: order_123
        receipt:
          type: string
          nullable: true
        amount:
          type: integer
          example: 50000
        amountPaid:
          type: integer
          nullable: true
        amountDue:
          type: integer
          nullable: true
        currency:
          type: string
          example: inr
        attempts:
          type: integer
          nullable: true
        verifiedPaymentId:
          type: string
          nullable: true
          example: pay_123
        verifiedAt:
          type: string
          format: date-time
          nullable: true
        notes:
          $ref: '#/components/schemas/Metadata'
        lastError:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    RazorpayCheckoutPrefill:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          nullable: true
        email:
          type: string
          format: email
          nullable: true
        contact:
          type: string
          nullable: true
    ErrorResponse:
      type: object
      required:
        - error
        - message
        - statusCode
      properties:
        error:
          type: string
          example: INVALID_INPUT
        message:
          type: string
          example: 'environment: Invalid enum value'
        statusCode:
          type: integer
          example: 400
        nextActions:
          type: string
          nullable: true
    RazorpayEnvironment:
      $ref: '#/components/schemas/PaymentEnvironment'
    RazorpayOrderStatus:
      type: string
      enum:
        - initialized
        - created
        - attempted
        - paid
        - failed
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````