Skip to main content

Overview

Process payment for a delivery (or all deliveries in a bulk) from your wallet balance. This endpoint supports idempotency through the reference parameter.
Required permission: payment:create

Endpoint

POST /api/payments/charge

Request

Headers

X-API-Key
string
required
Your Chidori API key
Content-Type
string
required
Must be application/json

Body parameters

deliveryId
string
required
The delivery ID to pay for. If this delivery belongs to a bulk, all deliveries in the bulk will be paid.
reference
string
required
Client-generated idempotency key. Re-using the same reference will not double-charge.
amount
number
Optional amount verification. If provided, must match the computed delivery amount.

Response

Success response

status
boolean
Always true for successful requests
data
object

Examples

Single delivery payment

curl -X POST https://api.chidori.africa/api/payments/charge \
  -H "X-API-Key: sk_live_xxx.yyy" \
  -H "Content-Type: application/json" \
  -d '{
    "deliveryId": "abc123-def456-ghi789",
    "reference": "order_12345_payment"
  }'
{
  "status": true,
  "data": {
    "deliveryId": "abc123-def456-ghi789",
    "bulk": null,
    "amount": 2500,
    "paymentChannel": "Wallet",
    "reference": "order_12345_payment"
  }
}

Bulk payment behavior

When you pay for a delivery that belongs to a bulk:
  1. The system identifies the bulk ID from the delivery
  2. Calculates the total amount for all unpaid deliveries in that bulk
  3. Charges the full bulk total from your wallet
  4. Marks all deliveries in the bulk as paid
You can pass any deliveryId from the bulk—the system will find and charge the entire bulk.

Idempotency

The reference parameter ensures safe retries:
  • If a request fails due to network issues, you can safely retry with the same reference
  • If the original request succeeded, the retry will return the same response without double-charging
  • Use unique references for each distinct payment (e.g., include your order ID)
// Good: Unique reference per order
const reference = `order_${orderId}_delivery_payment`;

// Bad: Reusing references across different orders
const reference = 'payment'; // Don't do this!

Error handling

StatusMessageAction
400Validation errorCheck request parameters
401UnauthorizedVerify API key
402Insufficient wallet balanceAdd funds to wallet
403ForbiddenCheck API key permissions
404Delivery not foundVerify delivery ID

Wallet management

Ensure your wallet has sufficient balance before attempting payment. Fund your wallet through the Chidori Dashboard.

Next steps