PexiPay
Live Documentation
Base URL: http://localhost:8000

API Overview

Welcome to the PexiLabs API documentation. Our RESTful API allows you to integrate payment processing, transaction management, and merchant services into your applications.

Secure

All API endpoints use industry-standard security practices with API key authentication.

Fast

Optimized for performance with efficient data structures and caching.

RESTful

Clean, predictable URLs and standard HTTP methods for easy integration.

Development Environment

You are currently viewing the development environment. Use this for testing and integration.

Authentication

API Key Format

API keys follow the format: public_key:secret_key

Header Options

Authorization: Bearer {api_key} X-API-Key: {api_key}

API Scopes

read

Read access to transactions and data

write

Write access to create payments and sessions

Authentication

API key verification and authentication endpoints

POST /api/v1/auth/verify/

Verify API Key

Verify API key authentication and get partner information

Request

Authentication
Required - API Key

Response Example

{
  "authenticated": true,
  "message": "Authentication successful",
  "data": {
    "partner": {
      "id": "uuid",
      "name": "Partner Name",
      "code": "partner_code",
      "is_active": true
    },
    "app_key": {
      "id": "uuid",
      "name": "API Key Name",
      "key_type": "merchant",
      "scopes": [
        "read",
        "write"
      ],
      "status": "active"
    }
  }
}

cURL Example

curl -X POST "http://localhost:8000/api/v1/auth/verify/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"key": "value"}'

Checkout & Payments

Payment processing and checkout session management

Card Payment Requirements

  • Minimum payment amount: 5.00
  • expiry_month must be string format with zero-padding (e.g., "01", "12")
  • expiry_year must be string format (e.g., "2028", "2030")
  • Billing address is required when card details are provided for direct payment
  • Billing address must include: card_street (line1), card_city, card_state_code, card_post_code, card_country_code
POST /api/v1/checkout/make-payment/

Create Payment Session

Create a new payment session for processing payments. Supports two payment flows: Direct Payment (card information provided) and Hosted Payment (redirects to payment page).

Payment Flows

Direct Payment

Process payment immediately with card information provided in the request. Card details and billing address are required. Minimum amount: 5.00.

Card Info Required
Requirements:
  • Card number, CVV, expiry_month, expiry_year are required
  • Billing address fields (card_street, card_city, card_state_code, card_post_code, card_country_code) are required
  • expiry_month must be string format with zero-padding (e.g., "01", "12")
  • expiry_year must be string format (e.g., "2028", "2030")
  • Minimum amount: 5.00
Hosted Payment

Redirect customer to a hosted payment page where they enter their card information. No card details required in request.

Card Info Not Required
Requirements:
  • No card details needed in request
  • Customer redirected to secure payment page
  • Minimum amount: 5.00

Request Examples

Direct Payment Example
Card Info Required Min: 5.00

Note: For Direct Payment, billing address fields (card_street, card_city, card_state_code, card_post_code, card_country_code) are required when card details are provided. expiry_month and expiry_year must be strings (e.g., "01", "2028").

{
  "amount": 5.0,
  "currency": "USD",
  "customer_email": "omambiadauglous@gmal.com",
  "first_name": "Omambia",
  "last_name": "Dauglous",
  "customer_phone": "+254748885672",
  "payment_method": "card",
  "description": "Machine Leaning training course",
  "title": "Course Core Platform",
  "card_number": "4000000000003220",
  "cvv": "102",
  "expiry_month": "01",
  "expiry_year": "2028",
  "card_street": "123 Main Street",
  "card_city": "New York",
  "card_state_code": "NY",
  "card_post_code": "10001",
  "card_country_code": "US",
  "callback_url": "https://app.pexipay.com/callback/payment-success",
  "cancel_url": "https://app.pexipay.com/callback/payment-cancel",
  "redirect_url": "https://app.pexipay.com"
}
Hosted Payment Example
No Card Info Needed Min: 5.00
{
  "amount": 5.0,
  "currency": "USD",
  "customer_email": "omambiadauglous@gmal.com",
  "first_name": "Omambia",
  "last_name": "Dauglous",
  "customer_phone": "+254748885672",
  "payment_method": "card",
  "description": "Machine Leaning training course",
  "title": "Course Core Platform",
  "callback_url": "https://app.pexipay.com/callback/payment-success",
  "cancel_url": "https://app.pexipay.com/callback/payment-cancel",
  "redirect_url": "https://app.pexipay.com"
}

When to Use Each Flow

Direct Payment
  • Card information (card_number, cvv, expiry_month, expiry_year) is REQUIRED
  • Billing address (card_street, card_city, card_state_code, card_post_code, card_country_code) is REQUIRED when card details are provided
  • expiry_month must be string format with zero-padding: "01" through "12" (not integer 1-12)
  • expiry_year must be string format: "2028", "2030", etc. (not integer 2028)
  • Minimum payment amount: 5.00
  • Payment is processed immediately without redirecting the customer
  • Best for server-to-server integrations where you collect card details
  • Card details are securely processed and never stored
  • Use when you have PCI-compliant infrastructure to handle card data
  • Response includes payment status immediately after processing
Hosted Payment
  • Card information is NOT required in the request
  • Billing address fields are optional (customer enters on payment page)
  • Minimum payment amount: 5.00
  • Customer is redirected to a secure hosted payment page
  • Customer enters card details on PexiPay's secure payment page
  • Best for client-side integrations or when you want to avoid handling card data
  • Reduces PCI compliance burden on your side
  • Use redirect_url to specify where to redirect after payment completion
  • Payment status is communicated via callback_url after completion

Request

Authentication
Required - API Key with write scope
Parameters

Note: Card fields (card_number, cvv, expiry_month, expiry_year) are required for Direct Payment but not needed for Hosted Payment.

amount
decimal required

Payment amount (positive number, minimum 5.00 for card payments)

currency
string required

Currency code (USD, EUR, KES, etc.)

customer_email
string required

Customer email address

first_name
string required

Customer first name

last_name
string required

Customer last name

middle_name
string optional

Customer middle name (optional)

customer_phone
string required

Customer phone number

description
string required

Payment description

payment_method
string optional

Payment Method (card, crypto). Defaults to "card"

title
string optional

Payment title/subject

reference_id
string optional

Custom reference ID (auto-generated if not provided)

metadata
object optional

Additional metadata as JSON object

callback_url
string optional

Success callback URL

cancel_url
string optional

Cancel/failure callback URL

redirect_url
string optional

URL to redirect after payment completion (for hosted payments)

card_number
string optional

Card number (Required for Direct Payment, not needed for Hosted Payment)

cvv
string optional

Card CVV/CVC (Required for Direct Payment, not needed for Hosted Payment)

expiry_month
string optional

Card expiry month in string format with zero-padding (e.g., "01", "12") (Required for Direct Payment, not needed for Hosted Payment)

expiry_year
string optional

Card expiry year in string format (e.g., "2028", "2030") (Required for Direct Payment, not needed for Hosted Payment)

customer_date_of_birth
string optional

Customer date of birth in YYYY-MM-DD format

customer_state_of_residence
string optional

Customer state of residence (required if country is US)

card_street
string optional

Billing street address (Required for Direct Payment when card details are provided, e.g., "123 Main Street")

card_city
string optional

Billing city (Required for Direct Payment when card details are provided, e.g., "New York")

card_state_code
string optional

Billing state/province code (Required for Direct Payment when card details are provided, e.g., "NY", "CA")

card_post_code
string optional

Billing postal/ZIP code (Required for Direct Payment when card details are provided, e.g., "10001")

card_country_code
string optional

Billing country code in ISO 3166-1 alpha-2 format (Required for Direct Payment when card details are provided, e.g., "US", "CA", "GB")

Response Example

{
  "success": true,
  "transaction_id": "uuid",
  "reference_id": "PEX-REF-XXXXXXXX",
  "expires_at": "2024-01-01T12:00:00Z",
  "amount": 100.0,
  "currency": "USD",
  "payment_url": "https://app.pexipay.com/api/v1/checkout/process-payment/{transaction_id}/?session_id={session_id}",
  "status": "pending",
  "payment_method": "card",
  "message": "Payment session created successfully"
}

cURL Example

curl -X POST "http://localhost:8000/api/v1/checkout/make-payment/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"key": "value"}'
GET /api/v1/checkout/transaction/

Get Transaction by Reference ID

Retrieve transaction details using the reference_id returned when creating a payment session

Request

Authentication
Required - API Key (read or write scope)
Parameters
reference_id
string required

The reference ID of the transaction (e.g., PEX-REF-EC0D9370)

Response Example

{
  "success": true,
  "transaction_id": "878fe3ef-335b-4b7c-8d2e-c63adb7d7a8d",
  "reference_id": "PEX-REF-EC0D9370",
  "amount": 3.0,
  "currency": "USD",
  "payment_url": "http://localhost:8000/api/v1/checkout/process-payment/878fe3ef-335b-4b7c-8d2e-c63adb7d7a8d/?session_id=0a8e46f5-86d8-4b8b-9f80-9ba040b30f14",
  "requires_3ds": true,
  "status": "pending",
  "payment_method": "card",
  "message": "Payment authentication required.",
  "expires_at": "2025-11-24T21:46:36.055213+00:00"
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/checkout/transaction/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"

Transaction Management

Transaction listing, details, and statistics

GET /api/v1/transactions/

List Transactions

Get paginated list of transactions with filtering options

Request

Authentication
Required - API Key
Parameters
page
integer optional

Page number (default: 1)

page_size
integer optional

Items per page (default: 20, max: 100)

status
string optional

Filter by transaction status

type
string optional

Filter by transaction type

payment_method
string optional

Filter by payment method(crypto, card)

date_from
string optional

Start date (YYYY-MM-DD)

date_to
string optional

End date (YYYY-MM-DD)

search
string optional

Search by reference or email

amount_min
decimal optional

Minimum amount filter

amount_max
decimal optional

Maximum amount filter

currency
string optional

Filter by currency

Response Example

{
  "success": true,
  "data": {
    "transactions": [],
    "pagination": {
      "current_page": 1,
      "total_pages": 5,
      "total_count": 100,
      "page_size": 20,
      "has_next": true,
      "has_previous": false
    }
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/transactions/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/transactions/stats/

Transaction Statistics

Get comprehensive transaction statistics and metrics

Request

Authentication
Required - API Key
Parameters
date_from
string optional

Start date (YYYY-MM-DD)

date_to
string optional

End date (YYYY-MM-DD)

period
string optional

Predefined period (today, week, month, quarter, year)

Response Example

{
  "success": true,
  "data": {
    "stats": {
      "total_transactions": 150,
      "completed_transactions": 142,
      "failed_transactions": 8,
      "success_rate": 94.67,
      "total_volume": "15000.00",
      "total_fees": "435.00",
      "net_volume": "14565.00"
    },
    "period": {
      "from": "2023-12-01",
      "to": "2023-12-31"
    }
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/transactions/stats/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/transactions/choices/

Transaction Choices

Get available choices for transaction filters

Request

Authentication
Required - API Key

Response Example

{
  "success": true,
  "data": {
    "transaction_statuses": [
      {
        "value": "pending",
        "display": "Pending",
        "description": "Transaction created and awaiting processing. Status remains PENDING during payment processing."
      },
      {
        "value": "processing",
        "display": "Processing",
        "description": "Transaction is being processed (legacy status, transactions now remain PENDING during processing)"
      },
      {
        "value": "completed",
        "display": "Completed",
        "description": "Transaction completed successfully"
      },
      {
        "value": "failed",
        "display": "Failed",
        "description": "Transaction failed"
      },
      {
        "value": "cancelled",
        "display": "Cancelled",
        "description": "Transaction was cancelled"
      },
      {
        "value": "expired",
        "display": "Expired",
        "description": "Transaction expired"
      },
      {
        "value": "refunded",
        "display": "Refunded",
        "description": "Transaction was refunded"
      },
      {
        "value": "partially_refunded",
        "display": "Partially Refunded",
        "description": "Transaction was partially refunded"
      },
      {
        "value": "disputed",
        "display": "Disputed",
        "description": "Transaction is under dispute"
      },
      {
        "value": "frozen",
        "display": "Frozen",
        "description": "Transaction is frozen"
      }
    ],
    "transaction_types": [
      {
        "value": "payment",
        "display": "Payment"
      },
      {
        "value": "refund",
        "display": "Refund"
      }
    ],
    "payment_methods": [
      {
        "value": "card",
        "display": "Card Payment"
      },
      {
        "value": "crypto",
        "display": "Cryptocurrency"
      }
    ]
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/transactions/choices/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/transactions/<uuid:transaction_id>/

Get Transaction by ID

Get detailed information about a specific transaction by ID

Request

Authentication
Required - API Key
Parameters
transaction_id
uuid required

Transaction UUID

Response Example

{
  "success": true,
  "data": {
    "transaction": {
      "id": "uuid",
      "reference": "TXN-REF-123",
      "amount": "100.00",
      "currency": "USD",
      "status": "completed",
      "created_at": "2024-01-01T12:00:00Z"
    }
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/transactions/<uuid:transaction_id>/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/transactions/reference/<str:reference>/

Get Transaction by Reference

Get detailed information about a specific transaction by reference

Request

Authentication
Required - API Key
Parameters
reference
string required

Transaction reference

Response Example

{
  "success": true,
  "data": {
    "transaction": {
      "id": "uuid",
      "reference": "TXN-REF-123",
      "amount": "100.00",
      "currency": "USD",
      "status": "completed",
      "created_at": "2024-01-01T12:00:00Z"
    }
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/transactions/reference/<str:reference>/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"

Alternative Payment Methods

Mobile money payments, bank transfers, FX rates, and B2C payouts via Alternative Payment Methods

POST /api/v1/lamps/mobile-money/payment/

Create Mobile Money Payment

Create a mobile money payment transaction

Request

Authentication
Required - API Key with write scope
Parameters
amount
decimal required

Payment amount (e.g., 100.00)

currency
string required

Currency code: KES (Kenya), UGX (Uganda), TZS (Tanzania), NGN (Nigeria), XOF (West Africa)

payer_phone
string required

Payer phone number with country code (e.g., 254712345001 for Kenya)

payer_email
string optional

Payer email address

payment_method_code
string optional

Payment method code for mobile money network (e.g., MPESA_KEN, AIRTEL_KEN, HALOTELTZA, TIGOTZA, VODACOMTZA, AIRTELTZA, MTNBEN, MOOVBEN, MTNCIV, ORANGECIV, ORANGESEN, FREESEN, MTNMOMONGA, AIRTELNGA). See supported countries section for available codes.

country_code
string optional

Country code: KEN (Kenya), UG (Uganda), TZ (Tanzania), NG (Nigeria), BJ (Benin), CI (Ivory Coast), SN (Senegal)

reference_id
string optional

Custom reference ID for tracking

metadata
object optional

Additional metadata as JSON object

webhook_url
string optional

Webhook URL for payment notifications

description
string optional

Payment description or purpose

Response Example

{
  "success": true,
  "data": {
    "transaction_id": "123456789",
    "reference_id": "alternative_payment_methods_abc123",
    "amount": "100.00",
    "total_amount": "105.00",
    "transaction_charge": "5.00",
    "currency": "KES",
    "status": "pending",
    "message": "Request to charge customer was successfully placed",
    "payment_method": "MPESA_KEN",
    "country_code": "KEN"
  }
}

cURL Example

curl -X POST "http://localhost:8000/api/v1/lamps/mobile-money/payment/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"key": "value"}'
POST /api/v1/lamps/payouts/local/

Create Local Payout

Create a local B2C payout to mobile money or bank account

Request

Authentication
Required - API Key with write scope
Parameters
amount
decimal required

Payout amount

recipient_phone
string required

Recipient phone number

recipient_name
string required

Recipient full name

destination_type
string optional

Destination type (MOBILE, BANK)

destination_name
string optional

Destination name (MPESA_KEN, etc.)

currency
string optional

Currency code (default: KES)

reference_id
string optional

Custom reference ID

metadata
object optional

Additional metadata

callback_url
string optional

Callback URL for status updates

description
string optional

Payout description

Response Example

{
  "success": true,
  "data": {
    "payout_reference": "payout_abc123",
    "amount": "100.00",
    "currency": "KES",
    "status": "pending",
    "message": "Payout request has been accepted for processing",
    "destination_type": "MOBILE",
    "destination_name": "MPESA_KEN",
    "recipient_phone": "254700000000",
    "recipient_name": "John Doe"
  }
}

cURL Example

curl -X POST "http://localhost:8000/api/v1/lamps/payouts/local/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"key": "value"}'
GET /api/v1/lamps/fx/rates/

Get Exchange Rates

Get real-time foreign exchange rates

Request

Authentication
Required - API Key
Parameters
base_currency
string optional

Base currency (default: USD)

Response Example

{
  "success": true,
  "data": {
    "base_currency": "USD",
    "rates": {
      "KES": {
        "buying": "158.496617",
        "selling": "164.509032"
      },
      "NGN": {
        "buying": "908.749572",
        "selling": "956.287051"
      }
    },
    "timestamp": "2024-01-01T12:00:00Z"
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/lamps/fx/rates/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/lamps/payments/{transaction_id}/status/

Get Payment Status

Get payment status by transaction ID

Request

Authentication
Required - API Key
Parameters
transaction_id
string required

Transaction ID

Response Example

{
  "success": true,
  "data": {
    "transaction_id": "123456789",
    "reference_id": "alternative_payment_methods_abc123",
    "amount": "100.00",
    "currency": "KES",
    "status": "completed",
    "event": "successful_payment",
    "payment_status": 700,
    "payer_phone": "254700000000",
    "payment_date": "2024-01-01T12:00:00Z",
    "payment_method": "MPESA_KEN"
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/lamps/payments/{transaction_id}/status/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
GET /api/v1/lamps/payouts/{payout_reference}/status/

Get Payout Status

Get payout status by reference

Request

Authentication
Required - API Key
Parameters
payout_reference
string required

Payout reference

Response Example

{
  "success": true,
  "data": {
    "payout_reference": "payout_abc123",
    "amount": "100.00",
    "currency": "KES",
    "status": "completed",
    "payment_status": 700,
    "recipient_phone": "254700000000",
    "recipient_name": "John Doe",
    "transaction_time": "2024-01-01T12:00:00Z",
    "destination_name": "MPESA_KEN",
    "transaction_cost": "5.00",
    "wallet_balance": "1000.00"
  }
}

cURL Example

curl -X GET "http://localhost:8000/api/v1/lamps/payouts/{payout_reference}/status/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE"
POST /api/v1/lamps/test/

Test Integration

Test Alternative Payment Methods integration connection

Request

Authentication
Required - API Key

Response Example

{
  "success": true,
  "message": "Alternative Payment Methods integration is working correctly",
  "merchant": "Test Merchant",
  "config": {
    "consumer_key_configured": true,
    "consumer_secret_configured": true,
    "iv_key_configured": true,
    "sandbox_mode": true
  }
}

cURL Example

curl -X POST "http://localhost:8000/api/v1/lamps/test/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -d '{"key": "value"}'

API Testing

Interactive Testing

Test API endpoints directly from your browser. All test requests are made to the current environment.

Quick Test Commands

Test Authentication

curl -X POST "http://localhost:8000/api/auth/verify/" \ -H "X-API-Key: YOUR_API_KEY"

List Transactions

curl -X GET "http://localhost:8000/api/transactions/" \ -H "X-API-Key: YOUR_API_KEY"

Response Codes

200 Success
400 Bad Request
401 Unauthorized
404 Not Found
500 Server Error