openapi: 3.1.0
info:
  title: Experia360 Merchant API
  version: 1.0.0
  description: Server-side hosted collection order API for approved Experia360 merchants.
  contact:
    name: Experia360 Private Limited
    url: https://experia360.com/contact
servers:
  - url: https://api.theexperia360.com/api/v1
    description: Production API gateway
tags:
  - name: Collections
  - name: Platform
webhooks:
  paymentConfirmed:
    post:
      summary: Signed payment confirmation callback
      description: Verify the signature against the exact raw request body before parsing or acknowledging the event.
      parameters:
        - name: X-Experia-Event-Id
          in: header
          required: true
          schema: { type: string, format: uuid }
        - name: X-Experia-Timestamp
          in: header
          required: true
          schema: { type: string, pattern: '^[0-9]+$' }
        - name: X-Experia-Signature
          in: header
          required: true
          schema: { type: string, pattern: '^v1=[a-f0-9]{64}$' }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentConfirmedEvent'
      responses:
        '200':
          description: Callback accepted
paths:
  /health:
    get:
      tags: [Platform]
      summary: Service health
      operationId: health
      security: []
      responses:
        '200':
          description: API process is reachable
          content:
            application/json:
              schema:
                type: object
  /merchant/payment-orders:
    post:
      tags: [Collections]
      summary: Create a hosted payment order
      operationId: createPaymentOrder
      security:
        - ClientId: []
          ClientSecret: []
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentOrder'
      responses:
        '201':
          description: Payment order created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentOrderEnvelope'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          description: API client rate limit exceeded
  /merchant/payment-orders/{order}:
    get:
      tags: [Collections]
      summary: Retrieve a payment order
      operationId: getPaymentOrder
      security:
        - ClientId: []
          ClientSecret: []
      parameters:
        - name: order
          in: path
          required: true
          description: Experia360 UUID or order_id
          schema:
            type: string
      responses:
        '200':
          description: Current authoritative payment order
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentOrderEnvelope'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Order not found in the API client's organization
components:
  securitySchemes:
    ClientId:
      type: apiKey
      in: header
      name: X-Experia-Client-Id
    ClientSecret:
      type: http
      scheme: bearer
      bearerFormat: exs_ token
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: UUID retained and reused for safe retries of the same merchant operation
      schema:
        type: string
        format: uuid
  schemas:
    CreatePaymentOrder:
      type: object
      required: [amount_paise, purpose]
      properties:
        amount_paise:
          type: integer
          minimum: 100
          maximum: 10000000000
          examples: [125000]
        purpose:
          type: string
          minLength: 3
          maxLength: 255
        customer_name:
          type: [string, 'null']
          maxLength: 120
        customer_email:
          type: [string, 'null']
          format: email
          maxLength: 190
        customer_phone:
          type: [string, 'null']
          pattern: '^[6-9][0-9]{9}$'
        merchant_order_reference:
          type: [string, 'null']
          maxLength: 120
        expires_in_minutes:
          type: [integer, 'null']
          minimum: 5
          maximum: 1440
          default: 15
        callback_url:
          type: [string, 'null']
          format: uri
          description: Public HTTPS URL; required with callback_secret
        callback_secret:
          type: [string, 'null']
          minLength: 32
          maxLength: 500
          writeOnly: true
        return_url:
          type: [string, 'null']
          format: uri
          description: Public HTTPS URL used only for browser return
    PaymentOrder:
      type: object
      properties:
        id: { type: string, format: uuid }
        order_id: { type: string }
        merchant_order_reference: { type: [string, 'null'] }
        amount_paise: { type: integer }
        currency: { type: string, const: INR }
        status:
          type: string
          enum: [AWAITING_CUSTOMER, PENDING_PAYMENT, AWAITING_CONFIRMATION, PAID, MANUALLY_CONFIRMED, FAILED, EXPIRED, CANCELLED, REFUNDED]
        purpose: { type: string }
        bank_transaction_id: { type: [string, 'null'] }
        confirmed_at: { type: [string, 'null'], format: date-time }
        expires_at: { type: [string, 'null'], format: date-time }
        verification_mode: { type: string }
        checkout_url: { type: string, format: uri }
    PaymentConfirmedEvent:
      type: object
      required: [event, event_id, created_at, data]
      properties:
        event: { type: string, const: collection.payment_confirmed }
        event_id: { type: string, format: uuid }
        created_at: { type: string, format: date-time }
        data:
          type: object
          required: [order_id, status, amount_paise, currency]
          properties:
            order_id: { type: string }
            merchant_order_reference: { type: [string, 'null'] }
            status: { type: string, const: PAID }
            amount_paise: { type: integer }
            currency: { type: string, const: INR }
            bank_transaction_id: { type: [string, 'null'] }
            confirmed_at: { type: [string, 'null'], format: date-time }
    PaymentOrderEnvelope:
      type: object
      required: [success, data, request_id]
      properties:
        success: { type: boolean, const: true }
        data: { $ref: '#/components/schemas/PaymentOrder' }
        request_id: { type: string }
    ErrorEnvelope:
      type: object
      required: [success, error]
      properties:
        success: { type: boolean, const: false }
        error:
          type: object
          required: [code, message, request_id]
          properties:
            code: { type: string }
            message: { type: string }
            request_id: { type: string }
            details: { type: object, additionalProperties: true }
  responses:
    Unauthorized:
      description: API client authentication failed
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
    Forbidden:
      description: Scope, organization or product access denied
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
    ValidationError:
      description: Request validation failed
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
