Skip to main content

Payments API

The Payments API allows you to create, verify, and retrieve payment sessions programmatically.

Initialize Payment

Creates a new payment session and returns a hosted checkout URL.
Authentication: Requires a Public Key (cp_pk_test_ or cp_pk_live_)
POST /api/v1/payments

Request Body

ParameterTypeRequiredDescription
amountnumberYesThe payment amount in your account’s local currency (or USD if collectInUSD is true)
customerEmailstringYesCustomer’s email address
customerFirstNamestringNoCustomer’s first name (2-50 characters)
customerLastNamestringNoCustomer’s last name (2-50 characters)
collectInUSDbooleanNoIf true, the amount is treated as USD. Default: false
referencestringNoYour unique reference for this payment (8-64 alphanumeric characters). If omitted, we generate one.
callbackURLstringNoURL to redirect the customer after successful payment. paymentId (ObjectID) and reference (your clientReference) are appended as query params.
failureURLstringNoURL to redirect the customer on payment failure or expiration
metadataobjectNoKey-value pairs of custom data (string values only)

Example Request

curl -X POST https://api.chainpal.org/api/v1/payments \
  -H "Authorization: Bearer cp_pk_test_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "customerEmail": "customer@example.com",
    "customerFirstName": "John",
    "customerLastName": "Doe",
    "reference": "ORDER12345678",
    "metadata": {
      "orderId": "12345",
      "productName": "Premium Plan"
    }
  }'

Response

{
  "success": true,
  "message": "payment initialized successfully",
  "data": {
    "paymentId": "507f1f77bcf86cd799439011",
    "paymentURL": "https://pay.chainpal.org/c/abc123xyz"
  }
}

Response Fields

FieldTypeDescription
paymentIdstringUnique identifier for this payment session
paymentURLstringURL to redirect your customer to complete payment

Verify Payment

Retrieves the payment status and key details. Use this to verify that a payment has been completed.
Authentication: Requires a Secret Key (cp_sk_test_ or cp_sk_live_)IP Whitelisting: This endpoint respects IP whitelist configuration.
GET /api/v1/payments/:paymentId/verify

Path Parameters

ParameterTypeRequiredDescription
paymentIdstringYesThe payment ID returned from Initialize Payment

Example Request

curl https://api.chainpal.org/api/v1/payments/507f1f77bcf86cd799439011/verify \
  -H "Authorization: Bearer cp_sk_test_xyz789"

Response

{
  "success": true,
  "message": "payment status fetched successfully",
  "data": {
    "paymentId": "507f1f77bcf86cd799439011",
    "paymentReference": "ORDER12345678",
    "paid": true,
    "paidAt": "2024-01-15T14:30:00Z",
    "status": "completed",
    "paymentAmount": "5000.00",
    "cryptoAmount": "3.029024",
    "paymentCurrency": "NGN",
    "token": "USDC",
    "network": "base"
  }
}

Response Fields

FieldTypeDescription
paymentIdstringThe payment ID
paymentReferencestringYour reference (as passed during payment creation, never mutated)
paidbooleanWhether the payment has been received
paidAtstringISO 8601 timestamp when payment was received. Omitted from the response when the payment hasn’t been received yet.
statusstringThe current status of the payment (e.g., processing, completed)
paymentAmountstringThe fiat amount
cryptoAmountstringThe actual crypto amount collected
paymentCurrencystringThe fiat currency code (NGN, GHS, KES, ZAR, or USD)
tokenstringThe cryptocurrency used (USDT or USDC)
networkstringThe blockchain network used

Verify Payment by Reference

Retrieves the payment status and key details using the clientReference you passed during payment creation.
Authentication: Requires a Secret Key (cp_sk_test_ or cp_sk_live_)IP Whitelisting: This endpoint respects IP whitelist configuration.
GET /api/v1/payments/reference/:reference/verify

Path Parameters

ParameterTypeRequiredDescription
referencestringYesThe clientReference you passed when creating the payment

Example Request

curl https://api.chainpal.org/api/v1/payments/reference/ORDER12345678/verify \
  -H "Authorization: Bearer cp_sk_test_xyz789"

Response

Same response as Verify Payment.

Get Payment Details

Retrieves complete details of a payment including customer info, transaction hashes, and timestamps.
Authentication: Requires a Secret Key (cp_sk_test_ or cp_sk_live_)IP Whitelisting: This endpoint respects IP whitelist configuration.
GET /api/v1/payments/:paymentId

Path Parameters

ParameterTypeRequiredDescription
paymentIdstringYesThe payment ID

Example Request

curl https://api.chainpal.org/api/v1/payments/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer cp_sk_test_xyz789"

Response

{
  "success": true,
  "message": "payment fetched successfully",
  "data": {
    "id": "507f1f77bcf86cd799439011",
    "businessId": "507f1f77bcf86cd799439022",
    "userId": "507f1f77bcf86cd799439033",
    "environment": "test",
    "payCode": "abc123xyz",
    "fiatAmount": "5000.00",
    "collectedFiatAmount": "5000.00",
    "currency": "NGN",
    "status": "completed",
    "clientReference": "ORDER12345678",
    "paymentURL": "https://pay.chainpal.org/c/abc123xyz",
    "callbackURL": "https://yoursite.com/webhook",
    "failureURL": "https://yoursite.com/cancel",
    "customerInfo": {
      "email": "customer@example.com",
      "firstName": "John",
      "lastName": "Doe"
    },
    "metadata": {
      "orderId": "12345"
    },
    "cryptoAmount": "3.50",
    "collectedCryptoAmount": "3.50",
    "token": "USDC",
    "network": "base",
    "txHash": "0x123abc...",
    "primaryAddress": "0x456def...",
    "createdAt": "2024-01-15T14:00:00Z",
    "updatedAt": "2024-01-15T14:30:00Z",
    "completedAt": "2024-01-15T14:30:00Z",
    "expiresAt": "2024-01-15T15:00:00Z"
  }
}

Response Fields

FieldTypeDescription
idstringUnique payment identifier
businessIdstringYour business ID
userIdstringYour user ID
environmentstringtest or live
payCodestringShort code used in the checkout URL
fiatAmountstringOriginal requested fiat amount
collectedFiatAmountstringActual fiat amount collected after conversion
currencystringFiat currency code
statusstringPayment status (see Types)
clientReferencestringYour reference (as passed during payment creation, never mutated). If you didn’t pass one, this is auto-populated at creation time.
paymentURLstringHosted checkout URL
callbackURLstringWebhook URL for this payment
failureURLstringFailure redirect URL
customerInfoobjectCustomer details (email, firstName, lastName)
metadataobjectYour custom key-value data
cryptoAmountstringExpected crypto amount
collectedCryptoAmountstringActual crypto amount received
surplusAmountstringOverpayment amount (if any)
deficitAmountstringUnderpayment amount (if any)
tokenstringCryptocurrency token (USDT or USDC)
networkstringBlockchain network
txHashstringBlockchain transaction hash
primaryAddressstringDeposit address used
totalSentAmountstringAmount sent to exchange
merchantFeestringFee charged
errorMessagestringError description if failed
createdAtstringISO 8601 creation timestamp
updatedAtstringISO 8601 last update timestamp
completedAtstringISO 8601 completion timestamp
expiresAtstringISO 8601 expiration timestamp

List Payments

Retrieves a paginated list of your payments.
Authentication: Requires a Secret Key (cp_sk_test_ or cp_sk_live_)IP Whitelisting: This endpoint respects IP whitelist configuration.
GET /api/v1/payments

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
pageSizeinteger20Number of results per page
sortBystringcreated_atSort field (created_at or status)
sortOrderstringdescSort order (asc or desc)
statusstring-Filter by status (see Types)

Example Request

curl "https://api.chainpal.org/api/v1/payments?page=1&pageSize=10&status=completed" \
  -H "Authorization: Bearer cp_sk_test_xyz789"

Response

{
  "success": true,
  "message": "payments fetched successfully",
  "data": {
    "data": [
      {
        "id": "507f1f77bcf86cd799439011",
        "clientReference": "ORDER12345678",
        "fiatAmount": "5000.00",
        "currency": "NGN",
        "status": "completed",
        "created_at": "2024-01-15T14:00:00Z"
      }
    ],
    "currentPage": 1,
    "pageSize": 10,
    "totalItems": 1,
    "totalPages": 1,
    "hasNext": false,
    "hasPrev": false
  }
}

Pagination Response Fields

FieldTypeDescription
dataarrayThe payment records on this page
currentPageintegerThe page returned (1-indexed)
pageSizeintegerItems per page
totalItemsintegerTotal payments matching the filter
totalPagesintegerTotal page count
hasNextbooleanTrue if a next page exists
hasPrevbooleanTrue if a previous page exists