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 (12-16 alphanumeric characters). If omitted, we generate one.
callbackURLstringNoURL to redirect the customer after successful payment. Payment ID and reference 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": "[email protected]",
    "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": "checkoutORDER12345678",
    "paid": true,
    "paidAt": "2024-01-15T14:30:00Z",
    "paymentAmount": "5000.00",
    "paymentCurrency": "NGN",
    "token": "USDC",
    "network": "base"
  }
}

Response Fields

FieldTypeDescription
paymentIdstringThe payment ID
paymentReferencestringYour reference (prefixed with checkout)
paidbooleanWhether the payment has been received
paidAtstringISO 8601 timestamp when payment was received (empty if not paid)
paymentAmountstringThe fiat amount
paymentCurrencystringThe fiat currency code (NGN, GHS, KES, ZAR, or USD)
tokenstringThe cryptocurrency used (USDT or USDC)
networkstringThe blockchain network used

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",
    "reference": "checkoutORDER12345678",
    "paymentURL": "https://pay.chainpal.org/c/abc123xyz",
    "callbackURL": "https://yoursite.com/webhook",
    "customerInfo": {
      "email": "[email protected]",
      "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)
referencestringYour reference (prefixed with checkout)
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": {
    "items": [
      {
        "_id": "507f1f77bcf86cd799439011",
        "reference": "checkoutORDER12345678",
        "fiatAmount": "5000.00",
        "currency": "NGN",
        "status": "completed",
        "created_at": "2024-01-15T14:00:00Z"
      }
    ],
    "page": 1,
    "pageSize": 10,
    "totalItems": 1,
    "totalPages": 1
  }
}