Documentation
ZeePay API Documentation
Base URL: https://api.zeepay.co.zw · Version: v1 (2024-01)
Quickstart
Install the SDK and create your first payment:
npm install zeepay
import ZeePay from "zeepay";
const zee = new ZeePay(process.env.ZEEPAY_SECRET_KEY);
const payment = await zee.payments.create({
amount: 10,
currency: "USD",
reference: "invoice_1042"
});
// Redirect the customer to payment.checkoutUrlAuthentication
Authenticate with a secret key in the Authorization: Bearer zp_sk_... header. Use zp_test_sk_... keys in sandbox mode — no real payments are processed. Never expose secret keys in client-side code.
API Reference
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/payments | Create a payment |
| GET | /v1/payments/:id | Retrieve a payment |
| GET | /v1/payments | List payments |
| POST | /v1/refunds | Create a refund |
| GET | /v1/refunds/:id | Retrieve a refund |
| GET | /v1/customers | List customers |
| POST | /v1/payment_links | Create a payment link |
| GET | /v1/settlements | List settlements |
| POST | /v1/webhooks | Register a webhook endpoint |
| POST | /v1/subscriptions | Create a subscription (auto-deduct) |
| GET | /v1/subscriptions | List subscriptions |
| GET | /v1/subscriptions/:id | Retrieve a subscription |
| PATCH | /v1/subscriptions/:id | Pause, resume, or cancel |
| POST | /v1/subscriptions/:id/approve | Approve a mandate (sandbox) |
| POST | /v1/payouts | Disburse funds to a customer wallet |
| GET | /v1/payouts | List payouts |
| GET | /v1/payouts/:ref | Look up a payout by externalReference |
Full OpenAPI 3.0 specification: docs/openapi.yaml
Subscriptions & Auto-Deduct
ZeePay subscriptions debit your customers automatically on each billing date — including EcoCash, InnBucks and Omari wallets that don't natively support recurring payments. A mandate is created when you create a subscription; the customer approves it once, then ZeePay handles every debit.
- Create:
POST /v1/subscriptionswithmethodCode,amount,intervaland customer details. - Approve: the customer authorizes once (wallet PIN / card 3DS) via the returned
approvalUrl. In sandbox, callPOST /v1/subscriptions/:id/approveto simulate it. - Auto-deduct: the billing engine debits on each
nextBillingDate. Failed debits retry automatically (subscription becomespast_due) untilmaxRetriesis exhausted.
const sub = await zee.subscriptions.create({
merchantReference: "plan_premium",
amount: 9.99,
currency: "USD",
interval: "monthly",
methodCode: "ecocash", // auto-deduct EcoCash monthly!
customerPhone: "+263771234567"
});
// Redirect customer to sub.approvalUrl to authorize the mandatePayouts & Disbursements
Send money out to customer wallets via the EcoCash EPG services — synchronous, PIN-free, and idempotent on your externalReference.
| serviceType | Use case |
|---|---|
enterprise_cash_in | Bulk disbursement — payroll, growers, grants, claims |
change_disbursement | POS change paid into the customer's wallet |
merchant_to_subscriber | Single merchant payout to a subscriber |
const payout = await zee.payouts.create({
serviceType: "enterprise_cash_in",
amount: 150.00,
currency: "USD",
recipientMsisdn: "263777000000",
externalReference: "payroll-2024-01-emp042", // idempotency key
beneficiaryReference: "Emp042"
});
// Result is synchronous — payout.status is "succeeded" immediatelyWebhooks
ZeePay sends signed events to your endpoint. Verify signatures using HMAC-SHA256 with your webhook secret in the X-ZeePay-Signature header. Failed deliveries retry up to 5 times with exponential backoff.
| Event | Description |
|---|---|
payment.succeeded | Payment completed successfully |
payment.failed | Payment attempt failed |
payment.expired | Checkout session expired |
refund.succeeded | Refund completed |
settlement.paid | Settlement paid to merchant |
dispute.created | A dispute was opened |
subscription.created | Subscription created (mandate pending) |
subscription.activated | Mandate approved, auto-deduct enabled |
subscription.charge_succeeded | Recurring debit succeeded |
subscription.charge_failed | Recurring debit failed (will retry) |
subscription.updated | Subscription paused or resumed |
subscription.cancelled | Subscription ended |
payout.succeeded | Disbursement credited to the customer |
payout.failed | Disbursement failed |
Errors & Idempotency
Errors use conventional HTTP codes — 4xx for client errors and 5xx for platform errors. All create endpoints accept an Idempotency-Key header to safely retry requests without duplicating charges.