Developers
Kadja Pay API
A Paystack-style test gateway: generate keys, initialize a transaction on your server, send the customer to a hosted checkout, then verify the payment and receive a signed webhook.
Overview
Every payment follows three steps:
- 1. Initialize — create a transaction with your secret key and get an authorization_url.
- 2. Checkout — redirect the customer to that URL. The sandbox checkout completes the payment.
- 3. Verify — call the verify endpoint or wait for the charge.success webhook.
Amounts are integers in the smallest currency unit. USD 5000 means $50.00.
Authentication
Generate keys in Dashboard → API keys. Send the secret key from your server only:
Authorization: Bearer sk_test_...Create multiple labelled keys and revoke them individually. Live keys stay locked until PSP onboarding. Never expose a secret key in browser JavaScript. Requests without a valid key return 401; revoked keys fail immediately.
Versioning
The current API is /api/v1. Every response includes an X-Kadja-Api-Version header. We add fields without breaking existing clients; breaking changes ship under a new path such as /api/v2 and are announced before the old version is retired.
Pin your integration to a version path. Do not depend on undocumented response fields.
Initialize a transaction
curl -X POST https://your-domain.com/api/v1/transactions/initialize \
-H "Authorization: Bearer $KADJA_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"amount": 5000,
"currency": "USD",
"reference": "order_1042",
"callback_url": "https://example.com/thank-you",
"metadata": { "order_id": "1042" }
}'Supported currencies: USD, EUR, GBP, SDG, EGP. The minimum amount is 100. If you omit reference, Kadja Pay generates one.
{
"status": true,
"message": "Authorization URL created",
"data": {
"authorization_url": "https://your-domain.com/pay/ac_...",
"access_code": "ac_...",
"reference": "order_1042"
}
}Idempotency
Send an Idempotency-Key header with initialize or refund requests. Retrying with the same key and body returns the original response; reusing the key with a different body returns 409.
curl -X POST https://your-domain.com/api/v1/transactions/initialize \
-H "Authorization: Bearer $KADJA_SECRET_KEY" \
-H "Idempotency-Key: order_1042_attempt_1" \
-H "Content-Type: application/json" \
-d '{"email":"customer@example.com","amount":5000}'Verify a transaction
curl https://your-domain.com/api/v1/transactions/verify/order_1042 \
-H "Authorization: Bearer $KADJA_SECRET_KEY"{
"status": true,
"message": "Verification successful",
"data": {
"reference": "order_1042",
"amount": 5000,
"currency": "USD",
"status": "success",
"environment": "test",
"payment_method": "card",
"fee_amount": 75,
"net_amount": 4925,
"paid_at": "2026-12-05T12:00:00.000Z",
"expires_at": "2026-12-06T12:00:00.000Z",
"refunded_at": null,
"refund_amount": null,
"customer": { "email": "customer@example.com" },
"metadata": { "order_id": "1042" }
}
}Check the returned status and amount before you fulfil an order. Possible statuses are pending, success, failed, refunded and abandoned.
Hosted checkout
Redirect the customer to the authorization_url. In test mode the page shows payment methods and a “Pay” button that marks the transaction successful and fires the webhook. No card is charged. If you supplied a callback_url, the receipt links back to it.
Sandbox methods: Card, Bank transfer and Mobile wallet. The chosen method is stored on the transaction and returned by verify and webhooks as payment_method.
JavaScript SDK
Initialize the transaction on your server with the secret key, then pass the returned access_code to the browser. The SDK opens a popup or an inline iframe and posts the result back through a callback.
<script src="https://your-domain.com/kadja.js"></script>
<script>
KadjaPay.checkout({
accessCode: "ac_...",
mode: "popup",
onSuccess: (result) => console.log("paid", result.reference),
onCancel: () => console.log("closed")
});
</script>Inline mode embeds the checkout in a container:
<div id="checkout"></div>
<script>
KadjaPay.checkout({
accessCode: "ac_...",
mode: "inline",
container: "#checkout",
height: "720px",
onSuccess: (result) => console.log("paid", result.reference)
});
</script>Mobile SDK
The React Native helper is a redirect flow. Create the transaction on your server, open the authorization_url with the device browser, then verify server-side when the customer returns. Never ship a secret key in the app bundle.
import { openCheckout } from "@kadja-pay/react-native";
await openCheckout(authorizationUrl);See sdks/react-native in the repository for the helper and deep-link notes.
Fees and settlements
Kadja Pay deducts a 1.5% processing fee from each successful payment, with a minimum of 0.50 in the transaction currency. The transaction keeps both fee_amount and net_amount.
In Dashboard → Settlements you can add a bank account, settle the available balance now, and review settlement history. The daily job creates T+1 settlements for payments older than 24 hours. Sandbox payouts do not move real money.
Webhooks
Add an endpoint in Dashboard → Webhooks. Kadja Pay sends charge.success, charge.failed, charge.abandoned, refund.processed, charge.dispute.created, charge.dispute.closed, settlement.created, settlement.paid and settlement.failed events with an x-kadja-signature header and an x-kadja-attempt counter. Settlement events carry a data.settlement object with the amounts, status and payout reference. Failed deliveries retry automatically with backoff (30s through 480s, max 5 attempts) and can be replayed from the dashboard.
{
"event": "charge.success",
"data": {
"reference": "order_1042",
"amount": 5000,
"currency": "USD",
"status": "success",
"environment": "test",
"paid_at": "2026-12-05T12:00:00.000Z",
"customer": { "email": "customer@example.com" }
}
}Verify the signature with the webhook secret from the API keys page:
import crypto from "node:crypto";
const expected = crypto
.createHmac("sha512", process.env.KADJA_WEBHOOK_SECRET)
.update(rawBody)
.digest("hex");
const received = request.headers.get("x-kadja-signature");
const valid =
received?.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));Refunds
Refund the full remaining amount or a partial amount in minor units. A full refund moves the payment to refunded; a partial refund stays success with a cumulative refund_amount. Each refund fires a refund.processed webhook.
curl -X POST https://your-domain.com/api/v1/transactions/refund \
-H "Authorization: Bearer $KADJA_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"transaction":"order_1042","amount":2000,"reason":"Partial return"}'Omit amount to refund the remaining balance. Processing fees are not returned by default. Refunds are allowed after settlement; the merchant payable ledger carries the shortfall into future settlements. Repeated requests with the same idempotency key return the original response.
Simulated failures
The hosted checkout includes a “Simulate a declined payment” action. It moves a pending transaction to failed and fires a charge.failed webhook, so you can test your failure and retry paths without real cards.
Errors
| Status | Meaning |
|---|---|
| 400 | Invalid body, amount, currency or URL. |
| 401 | Missing or invalid secret key. |
| 403 | Merchant email is not verified. |
| 404 | Transaction not found for this merchant. |
| 409 | Reference already exists or transaction is final. |