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

# Initialize a payment

> Creates a pending transaction and returns a reference, access code, and checkout URL. The reference is generated (`VPY_TXN_…`).




## OpenAPI

````yaml /openapi.yaml post /payment/initialize
openapi: 3.1.0
info:
  title: Vestrapay Payments API
  version: '1.0'
  description: >
    Initialize payments, collect card or bank transfer at checkout, and verify
    transactions. Amounts are major units as strings (100 naira is "100.00").
    Successful HTTP JSON is always `{ "status": "success", "data": … }`.
    Failures are `{ "status": "failed", "error", "message" }`. Webhook bodies
    are `{ "event", "data", "timestamp" }` and are not wrapped.
servers:
  - url: https://server.staging.vestrapay.app/v1
    description: Staging
  - url: https://api.vestrapay.com/v1
    description: Production
security:
  - SecretKey: []
tags:
  - name: Payments
    description: Server-to-server initialize and verify
  - name: Checkout
    description: Customer checkout session (access code)
paths:
  /payment/initialize:
    post:
      tags:
        - Payments
      summary: Initialize a payment
      description: >
        Creates a pending transaction and returns a reference, access code, and
        checkout URL. The reference is generated (`VPY_TXN_…`).
      operationId: initialize-payment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitializePayment'
            examples:
              basic:
                value:
                  amount: '100.00'
                  email: customer@email.com
                  customerName: Jane Doe
                  callbackUrl: https://yourapp.com/paid
                  description: Order 12345
                  metadata:
                    orderId: ORD_12345
              withDistribution:
                value:
                  amount: '100.00'
                  email: customer@email.com
                  distribution:
                    utility: 70
                    logistics: 30
      responses:
        '201':
          description: Transaction created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitializePaymentResponse'
              example:
                status: success
                data:
                  reference: VPY_TXN_ACME001
                  accessCode: a1b2c3d4e5f6a1b2
                  checkoutUrl: https://checkout.vestrapay.com/a1b2c3d4e5f6a1b2
                  amount: '100.00'
                  cardFee: '1.50'
                  transferFee: '1.00'
                  cardTotal: '101.50'
                  transferTotal: '101.00'
                  currency: NGN
                  merchantBearsCost: false
                  channels:
                    - card
                    - bank_transfer
                    - bank_payment
                    - ussd
                  status: pending
        '401':
          description: Missing or invalid secret key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    InitializePayment:
      type: object
      required:
        - amount
      properties:
        amount:
          type: string
          example: '100.00'
          description: Major units as a string. Not kobo.
        currency:
          type: string
          default: NGN
        email:
          type: string
          format: email
        customerName:
          type: string
        callbackUrl:
          type: string
          format: uri
        description:
          type: string
        metadata:
          type: object
          additionalProperties: true
        distribution:
          type: object
          additionalProperties:
            type: number
          description: serviceKey to amount in the same unit as amount
        merchantBearsCost:
          type: boolean
    InitializePaymentResponse:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          enum:
            - success
        data:
          $ref: '#/components/schemas/InitializePaymentData'
    ErrorEnvelope:
      type: object
      required:
        - status
        - error
        - message
      properties:
        status:
          type: string
          enum:
            - failed
        error:
          type: string
        message:
          type: string
    InitializePaymentData:
      type: object
      properties:
        reference:
          type: string
        accessCode:
          type: string
        checkoutUrl:
          type: string
        amount:
          type: string
        cardFee:
          type: string
        transferFee:
          type: string
        cardTotal:
          type: string
        transferTotal:
          type: string
        currency:
          type: string
        merchantBearsCost:
          type: boolean
        channels:
          type: array
          items:
            type: string
        status:
          type: string
          example: pending
        distribution:
          type: object
          additionalProperties:
            type: number
  securitySchemes:
    SecretKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Secret key (sk_test_ or sk_live_). Authorization Bearer with the same
        value is also accepted.

````