Direct charges
Your page collects the card or phone number, your server sends it to us, and our answer says what the customer does next.
Card details pass through your server. Send them straight to QwikiPay over HTTPS and never log or store them: not the number, the CVV, the PIN or the code.
Start a charge
POST /v1/charges
Authorization: Bearer qp_sk_live_...
QwikiPay-Business: qp_biz_test_...
{
"reference": "order-1001",
"amount": "50000",
"currency": "UGX",
"customer": { "email": "[email protected]", "name": "Amina Nakato" },
"redirect_url": "https://shop.example.com/orders/1001",
"method": {
"type": "card",
"card": { "number": "4242424242424242", "expiry_month": "12", "expiry_year": "30", "cvv": "123" }
}
}
For mobile money:
"method": { "type": "mobile_money", "mobile_money": { "network": "MTN", "phone": "0772123456" } }
reference is also the idempotency key for charges: sending the same reference and amount again returns the same charge instead of charging twice.
Follow next_step
{ "id": "qp_ch_8c1f...", "object": "charge", "status": "pending", "next_step": { "type": "pin" }, ... }
next_step.type | What to do |
|---|---|
pin | Ask for the card PIN, then POST /v1/charges/{id}/authorize with { "pin": "1234" } |
otp | Show next_step.message, ask for the code, then authorize with { "otp": "123456" } |
redirect | Send the customer to next_step.url (their bank's check). They come back to redirect_url. |
approve_on_phone | Show next_step.message. The customer approves on their phone; poll GET /v1/charges/{id} every few seconds. |
wait | Poll GET /v1/charges/{id}. |
none | Finished: status is successful or failed. |
A wrong PIN or code fails the charge, as the bank would; start a new charge with a new reference.
Mobile money
GET /v1/mobile-networks lists the networks for your business's country:
{ "country": "UG", "networks": [ { "code": "MTN", "name": "MTN Mobile Money" }, { "code": "AIRTEL", "name": "Airtel Money" } ] }
Python client
The Developers page has this filled in with your business ID:
import os, requests
API = "https://api.qwikipay.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['QWIKIPAY_SECRET']}", "QwikiPay-Business": "qp_biz_live_..."}
def charge(reference, amount, customer, method, redirect_url=None):
body = {"reference": reference, "amount": str(amount), "currency": "UGX", "customer": customer, "method": method, "redirect_url": redirect_url}
return requests.post(f"{API}/charges", json=body, headers=HEADERS, timeout=30).json()
def authorize(charge_id, pin=None, otp=None):
return requests.post(f"{API}/charges/{charge_id}/authorize", json={"pin": pin} if pin else {"otp": otp}, headers=HEADERS, timeout=30).json()
def verify(charge_id):
return requests.get(f"{API}/charges/{charge_id}", headers=HEADERS, timeout=30).json()