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

# Initialize Payment

> Initialize a new payment transaction to collect money from customers

Initialize a new payment transaction to collect money from customers via cards, bank transfers, or mobile wallets.

<Note>
  This endpoint creates a payment session and returns a checkout URL where customers can complete their payment securely.
</Note>

<Note>
  This is the primary canonical initialization endpoint for both the transaction and checkout flows. It maps to `POST /pms/transactions/initialize/`, and `api-reference/checkout/initialize-transaction` is an equivalent alias.
</Note>

## Endpoint

<Badge variant="success">**POST**</Badge> `/pms/transactions/initialize/`

## Request Body

<ParamField body="email" type="string" required>
  Customer's email address for transaction receipt and notifications
</ParamField>

<ParamField body="amount" type="string" required>
  Transaction amount in naira (NGN) or the smallest currency unit

  <Note>For ₦500.00, send `"500"` (500 naira)</Note>
</ParamField>

<ParamField body="currency" type="string" default="NGN">
  Three-letter ISO currency code

  **Supported currencies:** `NGN`, `USD`
</ParamField>

<ParamField body="reference" type="string">
  Unique transaction reference. If not provided, PayVessel will generate one automatically

  <Warning>Must be unique across all your transactions</Warning>
</ParamField>

<ParamField body="callback_url" type="string">
  URL to redirect customers after payment completion
</ParamField>

<ParamField body="channels" type="array">
  Payment methods to allow for this transaction

  **Available channels:** `BANK_TRANSFER`

  <Note>If not specified, all available channels will be enabled</Note>
</ParamField>

<ParamField body="customer" type="object">
  Customer information object

  <Expandable title="Customer Object">
    <ParamField body="customer.email" type="string">
      Customer's email address (alternative to root-level email)
    </ParamField>

    <ParamField body="customer.first_name" type="string">
      Customer's first name
    </ParamField>

    <ParamField body="customer.last_name" type="string">
      Customer's last name
    </ParamField>

    <ParamField body="customer.phone" type="string">
      Customer's phone number in international format
    </ParamField>
  </Expandable>
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://sandbox.payvessel.com/pms/transactions/initialize/ \
    -H "api-key: YOUR_API_KEY" \
    -H "api-secret: YOUR_SECRET" \
    -H "Content-Type: application/json" \
    -d '{
      "customer_email": "test@example.com",
      "customer_name": "Test Customer",
      "customer_phone_number": "08012345678",
      "amount": "50",
      "currency": "NGN",
      "channels": [
          "BANK_TRANSFER"
      ]
  }'
  ```

  ```javascript Node.js theme={null}
  const payvessel = require('payvessel')(process.env.PAYVESSEL_SECRET_KEY);

  const transaction = await payvessel.transaction.initialize({
    email: 'customer@example.com',
    amount: '50',
    currency: 'NGN',
    reference: 'TXN_2024_001',
    callback_url: 'https://yourapp.com/payment/callback',
    channels: ['BANK_TRANSFER'],
    customer: {
      first_name: 'John',
      last_name: 'Doe',
      phone: '+2348012345678'
    }
  });
  ```

  ```php PHP theme={null}
  <?php
  $payvessel = new \Payvessel\Payvessel(getenv('PAYVESSEL_SECRET_KEY'));

  $transaction = $payvessel->transaction->initialize([
    'email' => 'customer@example.com',
    'amount' => '50',
    'currency' => 'NGN',
    'reference' => 'TXN_2024_001',
    'callback_url' => 'https://yourapp.com/payment/callback',
    'channels' => ['BANK_TRANSFER'],
    'customer' => [
      'first_name' => 'John',
      'last_name' => 'Doe',
      'phone' => '+2348012345678'
    ]
  ]);
  ?>
  ```

  ```python Python theme={null}
  import payvessel

  payvessel.api_key = os.environ['PAYVESSEL_SECRET_KEY']

  transaction = payvessel.Transaction.initialize(
      email='customer@example.com',
      amount='50',
      currency='NGN',
      reference='TXN_2024_001',
      callback_url='https://yourapp.com/payment/callback',
      channels=['BANK_TRANSFER'],
      customer={
          'first_name': 'John',
          'last_name': 'Doe',
          'phone': '+2348012345678'
      }
  )
  ```
</CodeGroup>

## Response

<ResponseField name="status" type="string">
  Request status indicator - `"success"` or `"error"`
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable message describing the result
</ResponseField>

<ResponseField name="data" type="object">
  Transaction data object

  <Expandable title="Data Object">
    <ResponseField name="data.authorization_url" type="string">
      Secure checkout URL where customers complete payment
    </ResponseField>

    <ResponseField name="data.access_code" type="string">
      Access code for the transaction session
    </ResponseField>

    <ResponseField name="data.reference" type="string">
      Unique transaction reference
    </ResponseField>

    <ResponseField name="data.amount" type="integer">
      Transaction amount in the smallest currency unit
    </ResponseField>

    <ResponseField name="data.currency" type="string">
      Transaction currency code
    </ResponseField>

    <ResponseField name="data.status" type="string">
      Current transaction status - `"pending"`
    </ResponseField>

    <ResponseField name="data.created_at" type="string">
      ISO 8601 timestamp when transaction was created
    </ResponseField>
  </Expandable>
</ResponseField>

## Example Response

<CodeGroup>
  ```json 200 Success theme={null}
  {
    "status": true,
    "message": "Checkout transaction successfully initialized",
    "data": {
      "id": "52b9bb2d-01d1-46ac-9800-14d34cb5f882",
      "transaction_ref": "B0C866BD914C487895ACB8C45B939017",
      "amount": "5000.00",
      "status": "PENDING",
      "access_code": "TEST-ACS-7AF7VH-2QIHE83N-TCTL28-BSDH",
      "checkout_url": "https://checkout.payvessel.com/TEST-ACS-7AF7VH-2QIHE83N-TCTL28-BSDH",
      "created_datetime": "2026-04-01T15:46:56.171229"
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "success": false,
    "message": "amount must be at least 50",
    "details": [
      {
        "code": "invalid",
        "detail": "amount must be at least 50",
        "attr": "amount"
      },
      {
        "code": "required",
        "detail": "This field is required.",
        "attr": "channels"
      },
      {
        "code": "blank",
        "detail": "This field may not be blank.",
        "attr": "customer_email"
      }
    ]
  }
  ```

  ```json 401 Unauthorized   theme={null}
  {
    "status": "error",
    "message": "Unauthorized. Please check your API key"
  }
  ```
</CodeGroup>

After initializing a payment:

<CardGroup cols={2}>
  <Card title="Verify Payment" icon="check-circle" href="/api-reference/transactions/verify-payment">
    Confirm transaction status after payment
  </Card>

  <Card title="Handle Webhooks" icon="webhook" href="/api-basics/webhooks">
    Receive real-time payment notifications
  </Card>
</CardGroup>

## Webhook Events

This endpoint triggers the following webhook events:

* `transaction.pending` - Transaction created and pending payment
* `transaction.success` - Payment completed successfully
* `transaction.failed` - Payment failed or was declined

<Tip>
  **Best Practice**: Always verify transaction status using the verification endpoint, even after receiving webhook notifications, to ensure data integrity.
</Tip>


## OpenAPI

````yaml POST /pms/transactions/initialize/
openapi: 3.1.0
info:
  title: PayVessel API
  description: >-
    PayVessel API for accepting payments, sending money, verifying identities,
    and managing wallets
  version: 1.0.0
servers:
  - url: https://api.payvessel.com
  - url: https://sandbox.payvessel.com
security:
  - {}
paths:
  /pms/transactions/initialize/:
    post:
      tags:
        - Checkout
      summary: Initialize Transaction
      description: >-
        Initialize a new payment transaction with customer details, amount, and
        payment channels. This creates a transaction session that can be used
        for payment processing.
      parameters:
        - name: api-key
          in: header
          description: Your Payvessel public API key
          required: true
          schema:
            type: string
        - name: api-secret
          in: header
          description: Your Payvessel secret
          required: true
          schema:
            type: string
        - name: Content-Type
          in: header
          description: Request content type
          required: true
          schema:
            type: string
            enum:
              - application/json
          example: application/json
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitializeTransactionRequest'
            example:
              amount: '5000.00'
              channels:
                - BANK_TRANSFER
              currency: NGN
              customer_name: John Doe
              customer_email: customer@example.com
              customer_phone_number: '+2348012345678'
              redirect_url: https://yourapp.com/payment/callback
      responses:
        '200':
          description: Transaction initialized successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitializeTransactionResponse'
              example:
                status: true
                message: Checkout transaction successfully initialized
                data:
                  id: 52b9bb2d-01d1-46ac-9800-14d34cb5f882
                  transaction_ref: B0C866BD914C487895ACB8C45B939017
                  amount: '5000.00'
                  status: PENDING
                  access_code: TEST-ACS-7AF7VH-2QIHE83N-TCTL28-BSDH
                  checkout_url: >-
                    https://checkout.payvessel.com/TEST-ACS-7AF7VH-2QIHE83N-TCTL28-BSDH
                  created_datetime: '2026-04-01T15:46:56.171229'
components:
  schemas:
    InitializeTransactionRequest:
      type: object
      required:
        - amount
        - channels
        - currency
        - customer_name
        - customer_email
        - customer_phone_number
      properties:
        amount:
          type: string
          description: Transaction amount in naira (for NGN) or minor currency units
        channels:
          type: array
          items:
            type: string
            enum:
              - BANK_TRANSFER
          description: Payment channels to enable for this transaction
        currency:
          type: string
          description: Transaction currency code
          enum:
            - NGN
            - USD
        metadata:
          type: object
          description: Additional information about the transaction
        customer_name:
          type: string
          description: Customer's full name
        customer_email:
          type: string
          format: email
          description: Customer's email address
        customer_phone_number:
          type: string
          description: Customer's phone number
        redirect_url:
          type: string
          format: uri
          description: URL to redirect customer after payment completion
        reference:
          type: string
          description: >-
            Unique transaction reference (optional - auto-generated if not
            provided)
    InitializeTransactionResponse:
      type: object
      properties:
        status:
          type: boolean
          description: Transaction initialization status
        message:
          type: string
          description: Response message
        data:
          type: object
          properties:
            id:
              type: string
              description: Unique transaction ID
            transaction_ref:
              type: string
              description: Transaction reference
            amount:
              type: string
              description: Transaction amount
            status:
              type: string
              description: Transaction status
            access_code:
              type: string
              description: Access code for transaction session
            checkout_url:
              type: string
              description: URL to redirect customer for payment
            created_datetime:
              type: string
              description: Transaction creation timestamp

````