Developers
An API that shows its working.
Create a payment in one call, get told exactly what happened, and see what it cost, line by line. REST and JSON at api.rano.co.za, with a TypeScript SDK.
{
"id": "pay_01k7f3m9q2v8x4c6n0b5h1t7wz",
"object": "payment",
"amount": 38600,
"currency": "ZAR",
"status": "succeeded",
"payment_method_type": "card",
"payment_method_details": null,
"description": "Order #2048",
"metadata": { "order_id": "2048" },
"amount_refunded": 0,
"fee": {
"currency": "ZAR",
"total": 795,
"costs": 359,
"margin": 436,
"vat": 57,
"margin_excl_vat": 379,
"price_plan": "plan_01k6z8c3r4w5t2y9n7b1d0m6qe",
"lines": [
{ "code": "interchange", "kind": "cost",
"label": "Card issuer (interchange)", "amount": 224 },
{ "code": "scheme", "kind": "cost",
"label": "Card scheme", "amount": 58 },
{ "code": "acquirer", "kind": "cost",
"label": "Acquiring bank", "amount": 77 },
{ "code": "rano", "kind": "margin",
"label": "rano", "amount": 436 }
]
},
"fee_waived": false,
"net": 37805,
"next_action": null,
"last_error": null,
"cancellation_reason": null,
"checkout_url": "https://pay.rano.co.za/pay/Xb4kQ9…",
"return_url": null,
"livemode": false,
"created": 1791532800
}Quick start
Three steps from test keys to a working payment.
Get your test keys
Request access and we’ll send you a secret key starting
sk_test_. Test mode needs no paperwork. Keep the key on your server, never in the browser.Create a payment
Amounts are in cents. Send an idempotency key so a retry can never charge twice.
curl https://api.rano.co.za/v1/payments \ -H "Authorization: Bearer $RANO_SECRET_KEY" \ -H "Idempotency-Key: order-2048" \ -H "Content-Type: application/json" \ -d '{ "amount": 38600, "currency": "ZAR", "payment_method_type": "card", "confirm": true }'Read the result
The payment comes back with its
statusand the full fee breakdown, like the object at the top of this page. Listen for webhooks to hear about anything that changes after the call returns.
The hosted payment page
The fastest way to take bank payments. Every payment has a checkout_url: send the customer there and rano handles PayShap and EFT, then sends them back to your return_url.
// On your server, when the customer checks out:
const payment = await rano.payments.create(
{
amount: 38600,
currency: "ZAR",
description: "Order #2048",
return_url: "https://shop.example/orders/2048",
},
{ idempotencyKey: "order-2048" },
);
// Send the customer to rano's page. They pay by PayShap or EFT there,
// on whichever device they like, and come back to return_url.
res.redirect(303, payment.checkout_url);- Moves between devices. The page carries a QR code and a share link, and every open copy stays in step: pay on the phone and the computer shows it paid.
- Lets the customer try again. If a PayShap request is declined or runs out of time, the page offers PayShap and EFT again with a note on what went wrong. You get
payment.failedfor each failed try; the payment only ends asfailedafter five. - Gives an EFT days, not minutes. An EFT reference stays open for five days. A transfer that lands later still pays, as long as the customer hasn’t paid another way.
- Tells you once. Fulfil the order on the
payment.succeededwebhook, not on the customer coming back toreturn_url: they might close the tab.
Choose the method yourself with payment_method_type and the page offers only that one. Collecting PayShap details in your own checkout instead? Confirm with payment_method_data.payshap.phone and .bank.
API basics
REST and JSON, shaped the way most developers already expect. If you’ve used a modern payments API, nothing here will surprise you.
One base URL
Every request goes to https://api.rano.co.za with your secret key in an Authorization: Bearer header. Requests and responses are JSON.
Amounts are integers in cents
R386.00 is 38600, always sent with a currency. No floats, no rounding surprises.
IDs tell you what they are
Payments start pay_, refunds rfnd_, payouts po_, events evt_. They sort by time and can’t be guessed.
Retries are safe
Send an Idempotency-Key header when you create, confirm, cancel or refund. Repeating the request within 24 hours returns the original result instead of charging twice. The SDK adds one for you.
Test and live keys are separate
sk_test_ keys only ever reach the simulator. sk_live_ keys move real money, once your business is verified.
Payments have honest states
requires_payment_method, requires_action, processing, succeeded, failed, canceled. If a bank times out, we say processing and find out, rather than guess. A declined or expired try hands the payment back for another go; after five it failed for good.
Endpoints
Lists return the newest first and take limit (1 to 100, default 10) and starting_after to page through.
| Method | Path | What it does |
|---|---|---|
POST | /v1/payments | Create a payment, and confirm it in the same call |
GET | /v1/payments | List payments, newest first |
GET | /v1/payments/:id | Retrieve a payment |
POST | /v1/payments/:id/confirm | Confirm a payment |
POST | /v1/payments/:id/cancel | Cancel a payment before it’s paid |
POST | /v1/refunds | Refund a payment |
GET | /v1/refunds | List refunds for a payment |
GET | /v1/refunds/:id | Retrieve a refund |
GET | /v1/balance | Your pending, available and reserved balance |
GET | /v1/balance_transactions | Movements of your available balance; with payout, what it paid out |
POST | /v1/payouts | Pay out now, on top of automatic payouts |
GET | /v1/payouts | List payouts |
GET | /v1/payouts/:id | Retrieve a payout |
GET | /v1/events | List events, optionally by type |
GET | /v1/events/:id | Retrieve an event |
POST | /v1/webhook_endpoints | Add a webhook endpoint |
GET | /v1/webhook_endpoints | List webhook endpoints |
DELETE | /v1/webhook_endpoints/:id | Remove a webhook endpoint |
POST | /v1/webhook_endpoints/:id/replay | Send an event to an endpoint again |
POST | /v1/test_helpers/payments/:id/approve | Test mode: the customer approves |
POST | /v1/test_helpers/payments/:id/decline | Test mode: the customer declines |
POST | /v1/test_helpers/payments/:id/simulate_eft | Test mode: the customer’s EFT lands on our bank statement |
Fees on every payment
Every payment carries a fee object: the total, what went to banks and card networks (costs), what we kept (margin), and one line per party that took a share. The breakdown is fixed when the payment is made, so later price changes never rewrite history.
| Code | Kind | Appears on | What it is |
|---|---|---|---|
interchange | cost | Card payments | The customer’s card issuer. Set by the card network. |
scheme | cost | Card payments | Visa or Mastercard network fees. |
acquirer | cost | Card payments | The acquiring bank that processes the card. |
bank | cost | PayShap and EFT | Clearing and bank costs, flat per payment. |
rano | margin | Every payment | Our fee. The only part we keep. |
VAT at 15% applies to our margin only and is already in it: fee.vat shows how much, and fee.margin_excl_vat the rest. net is what reaches your bank account: amount minus fee.total.
Balance and payouts
What you’re owed, when it’s yours, and how it reaches your bank.
- Pending, then available. A payment’s net (the amount less the fee) is pending until two business days after it succeeds, then available. Business days skip weekends and South African public holidays. Higher-risk accounts may wait longer and keep a small rolling reserve, shown as
reserveinGET /v1/balance. - Paid out every business day. Your available balance goes to your verified bank account each morning (or weekly, or only when you ask; choose in the dashboard). Pay out now with
POST /v1/payouts. The smallest payout is R50. - Easy to reconcile. Each payout shows on your bank statement as its
statement_reference, andGET /v1/balance_transactions?payout=…lists the payments and refunds it paid out. The dashboard exports the same as a spreadsheet. - Refunds come from your balance. Before a payment is available its refund comes out of pending, after from available. rano keeps its fee on a refunded payment, except when a customer pays after the payment was canceled: rano refunds that itself and gives the whole fee back (
fee_waived).
{
"id": "po_01k7g2x8r4m6c2v9t1b5n3d7qa",
"object": "payout",
"amount": 75610,
"currency": "ZAR",
"status": "paid",
"automatic": true,
"bank_account": "ba_01k7d0m4q8w2e6r9t3y5g1h7ka",
"statement_reference": "RANO-PO-N3D7QA2K",
"arrival_date": "2026-10-22",
"failure_code": null,
"failure_message": null,
"reconciled": true,
"livemode": false,
"created": 1792044000,
"paid": 1792044060
}// What a payout paid out: the payments (less refunds) that funded it.
const payouts = await rano.payouts.list({ limit: 10 });
for (const payout of payouts.data) {
const moves = await rano.balanceTransactions.list({ payout: payout.id });
for (const m of moves.data) {
// m.type: "payment", "refund", "reserve_release", ...
// m.source: the pay_ or rfnd_ ID; m.amount: + adds to the payout
}
}Webhooks
We POST an event to your endpoint whenever a payment, refund, payout or your account changes. Every event is signed and retried with backoff for about three days. Subscribe to the types you need, or * for all of them.
POST /webhooks/rano HTTP/1.1
Content-Type: application/json
Rano-Signature: t=1791532800,v1=5f0c9e2a7b…
{
"id": "evt_01k7f3m9t5r2y8d4p6e0a3s9gq",
"object": "event",
"type": "payment.succeeded",
"livemode": false,
"created": 1791532800,
"data": {
"object": { "id": "pay_01k7f3m9q2v8x4c6n0b5h1t7wz", "status": "succeeded", … }
}
}Verify the signature
The Rano-Signature header holds a Unix timestamp t and v1, a hex HMAC-SHA256 of <t>.<body> using your endpoint’s secret. The SDK checks it for you, including rejecting timestamps more than five minutes old to block replays.
import { Rano } from "@rano/sdk";
const rano = new Rano(process.env.RANO_SECRET_KEY);
// Throws if the signature doesn't match. Pass the body exactly as received.
const event = rano.webhooks.constructEvent(
rawBody,
req.headers["rano-signature"],
process.env.RANO_WEBHOOK_SECRET,
);Events
payment.created- A payment was created.
payment.requires_action- Waiting on the customer: 3D Secure, approval in their banking app, or an EFT.
payment.succeeded- Money is confirmed. Safe to fulfil the order.
payment.failed- A try at paying was declined or ran out of time. last_error says why. The payment goes back to requires_payment_method for the customer to try again, or to failed after five tries.
payment.canceled- You canceled the payment.
payment.reversed- The bank took the money back (a recalled EFT). amount_reversed says how much came off your balance.
refund.created- A refund was created and is on its way to the bank.
refund.succeeded- The refund has been sent back to the customer.
refund.failed- The bank rejected the refund. failure_code says why.
payout.created- A payout to your bank account was made.
payout.paid- The bank confirmed the payout left for your account.
payout.failed- The bank refused the payout or sent it back. The money is back in your balance; failure_code says why.
account.updated- Your account's status changed: activated, in review, restricted or rejected.
- Delivery is at least once. Use the event
idto ignore duplicates. - Order isn’t guaranteed. Each event carries the object as it was when the event happened. When order matters, retrieve the object for its latest state.
- Reply with any
2xxquickly, then do slow work in the background. - Missed one? Every event can be fetched again with
GET /v1/eventsorGET /v1/events/:id.
Test mode
A full copy of rano running against simulated banks. Pick the outcome with the last two digits of the amount in cents. Declines come back as a payment with status: requires_payment_method and the reason in last_error.code.
| Cents end in | Example | Outcome | You’ll see |
|---|---|---|---|
01 | 10001 | Declined | requires_payment_method · insufficient_funds |
02 | 10002 | Declined | requires_payment_method · do_not_honour |
05 | 10005 | Times out, then succeeds | processing → succeeded |
06 | 10006 | Times out, then is declined | processing → requires_payment_method |
07 | 10007 | Times out before the bank sees it | processing → requires_payment_method · processing_error |
08 | 10008 | Card needs 3D Secure | requires_action |
Anything else | 38600 | Card succeeds; PayShap and EFT wait for the customer | succeeded · requires_action |
PayShap and EFT in test mode
PayShap and EFT payments wait for the customer, just like in real life, unless the amount picks one of the outcomes above. In test mode, play the customer with a test helper: approve or decline. Test helpers don’t exist in live mode. Refunds follow the same rule: an amount ending in 01 is rejected, and 05 times out, then succeeds.
// PayShap and EFT payments wait for the customer in test mode too.
await rano.testHelpers.payments.approve("pay_01k7f3m9q2v8x4c6n0b5h1t7wz");
// Or have the customer say no.
await rano.testHelpers.payments.decline("pay_01k7f3m9q2v8x4c6n0b5h1t7wz");For EFT, POST /v1/test_helpers/payments/:id/simulate_eft puts the customer’s transfer on a simulated bank statement and matches it exactly as a real one would be. Change amount or reference to try short payments, overpayments and typos.
Payouts and activation in test mode
Test payments never need activation. To try payouts, activate your test account in the dashboard: the checks run against simulated providers and approve ordinary details at once. Bank accounts ending 9999 fail verification, and payouts to accounts ending 0000 come back. The simulated bank writes a statement every morning with the previous day’s settlements and payouts, so reconciled turns true the next business day.
Errors
Every error has the same shape: a type for broad handling, a code for your logic, a message written for whoever is debugging, and the param at fault, if any.
{
"error": {
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "currency is required.",
"param": "currency"
}
}| Type | HTTP | Meaning |
|---|---|---|
invalid_request_error | 400, 404, 409 | A parameter is missing or wrong, the object doesn’t exist, or it’s in the wrong state. param says which. |
authentication_error | 401 | The API key is missing, revoked or for the wrong mode. |
idempotency_error | 400, 409, 422 | A key was reused with a different request, or the first request is still running. |
rate_limit_error | 429 | Too many requests. Wait for the number of seconds in Retry-After, then retry. |
api_error | 500, 503 | Something went wrong on our side, or a provider we rely on is down. The same key returns the same answer, so check whether the object was created before retrying with a new key. |
Common codes
parameter_missing- A required parameter wasn’t sent.
parameter_invalid- A parameter has the wrong type or format.
parameter_unknown- A parameter we don’t recognise. Check the spelling.
amount_invalid- The amount isn’t a positive whole number of cents.
amount_too_large- More than a single payment can be, or more than is left to refund.
currency_invalid- We don’t support that currency.
return_url_invalid- return_url must be a full https address (http only for localhost).
metadata_invalid- Too many metadata keys, or a key or value is too long.
amount_too_small- The fee would be at least the whole payment. Use a larger amount.
payment_method_unavailable- That payment method isn’t available for this currency yet.
payment_unexpected_state- The payment can’t do that from its current status.
resource_missing- No object with that ID on your account.
payment_not_refundable- Only a succeeded payment can be refunded.
payment_already_refunded- The payment has already been refunded.
partial_refund_unsupported- Refunds are for the whole amount for now.
insufficient_balance- Your balance can’t cover the refund or payout. The message says what’s available.
api_key_missing- No API key in the Authorization header.
api_key_invalid- The API key isn’t recognised or has been revoked.
api_key_wrong_mode- A live key sent to test mode, or the other way round.
idempotency_key_reused- The same Idempotency-Key with a different request body.
idempotency_request_in_progress- The first request with this key hasn’t finished. Retry in a moment.
test_mode_only- Test helpers only work with a test key.
account_not_activated- Live payments start once your account is activated in the dashboard.
amount_above_account_limit- More than your account can take in one payment for now. Ask us to raise it.
account_restricted- Live payments are paused on your account while we review it. Check the dashboard.
account_limit_reached- This payment would take your account over its daily or monthly limit.
amount_above_method_limit- PayShap takes up to R50,000 a payment. Use EFT for more.
payshap_phone_rate_limited- Too many PayShap requests have gone to that phone number recently.
rate_limited- Too many requests a second. Wait a second and retry; Retry-After says how long.
payouts_disabled- Payouts start once your account is activated and your bank account verified.
bank_account_unverified- The bank hasn’t confirmed your payout account yet.
bank_account_new- Your payout account changed recently. Payouts to it start the next business day.
url_invalid- A webhook URL must be a valid public address; live endpoints must use https.
event_type_invalid- An event type we don’t send. Check the list above.
Declines aren’t errors
A declined payment is a normal result, not an HTTP error. You get 200 and the payment, back in requires_payment_method with last_error holding a code for your logic and a sentence you can show your customer. Confirm it again to retry, with the same method or another; after five tries the payment is failed.
{
"id": "pay_01k7f3n2c8w5j9r1x6m4d0a7kp",
"object": "payment",
"amount": 10001,
"status": "requires_payment_method",
"last_error": {
"code": "insufficient_funds",
"message": "The customer's account has insufficient funds."
},
…
}SDKs and tooling
Both come with your test keys. The SDK is for Node.js on your server, where your secret key stays.
- TypeScript SDK
- @rano/sdk: typed methods for payments, refunds, balance, payouts, events and webhook endpoints, webhook verification, idempotency keys and automatic retries.
- OpenAPI spec
- One file describing every endpoint, object and error, served at GET /openapi.json.
AI agents, CLI and sandbox bank
Tools that take the waiting out of integrating: let your coding agent do the wiring, test webhooks without a public URL, and approve test payments on your own phone.
The MCP server and CLI go on npm when the sandbox opens to developers; until then these commands are what you’ll run.
MCP server for AI coding agents
@rano/mcp gives Claude Code, Cursor and other MCP clients tools to create, confirm, cancel and refund test payments, play the customer, add webhook endpoints, read events, your balance and payouts, and search these docs and the API reference. It only accepts sk_test_ keys unless you set RANO_ALLOW_LIVE=true.
claude mcp add rano --env RANO_API_KEY=sk_test_… -- npx -y @rano/mcpCLI: webhooks on localhost
rano listen forwards your account’s events to a URL on your machine, signed exactly like real deliveries with a signing secret it prints, so the same verification code works locally and in production. No tunnel needed. rano trigger makes payment and refund events happen in test mode; rano events tail, rano payments list, rano balance and rano payouts list show what’s going on.
npm install -g @rano/cli
rano login
# Forward your test events to a local handler, signed like real webhooks.
rano listen --forward-to http://localhost:3000/webhooks
# Ready. Forwarding events to http://localhost:3000/webhooks
# Your webhook signing secret is whsec_… (set it as RANO_WEBHOOK_SECRET)
# In another terminal: make an event happen.
rano trigger payment.succeededSandbox bank on your phone
In test mode, open Developers → Sandbox bank in the dashboard and scan the QR code. Sign in with the test cellphone number and bank you used on the payment page, and test PayShap requests arrive like they would in a banking app, ready to approve or decline. Waiting EFTs get a Pay this EFT button. When the customer tries again after a decline, the new request replaces the old one. The test-mode box on every hosted payment page has a QR code that opens the sandbox bank on that one payment.
Request test keys.
Leave your email and we’ll send sandbox keys to early-access developers as we onboard them.