QalinPay API
Base URL: https://pay.qalintech.com/api/v1. All requests and responses are JSON. Amounts are in US dollars (e.g. 2.5 = $2.50).
How it works
- Your server creates a payment → you get a
checkout_url. - Redirect the customer to
checkout_url. They enter their Sahal number, dial*883*your-number*amount#and tap “I have paid”. - QalinPay finds the money in your Golis account (same amount, same sender number, in time) and marks the payment
paid. - We send a
payment.paidwebhook to your server and send the customer to yoursuccess_url.
Always confirm the order from the webhook (or by fetching the payment), never from the success_url redirect alone.
Authentication
Create keys on the Developers page. Send the key in the Authorization header. qp_test_… keys create test payments, qp_live_… keys create real ones. Keep keys on your server only.
Authorization: Bearer qp_live_xxxxxxxxxxxxxxxxCreate a payment
POST /payments
| Field | Type | Description |
|---|---|---|
| amount | number, required | USD, max 2 decimals. Example 2.5 |
| reference | string | Your order id (max 100). Shown to the customer and searchable. |
| description | string | What the customer is paying for (max 200). |
| customer_phone | string | Customer's Sahal number, if you know it. Skips the phone step. |
| success_url | string | Where to send the customer after payment. |
| cancel_url | string | Link shown if the payment expires. |
| webhook_url | string | Overrides your default webhook URL for this payment. |
| expires_in_minutes | integer | 5–1440, default 30. |
| metadata | object | Your own key/value data, returned in webhooks. |
curl -X POST https://pay.qalintech.com/api/v1/payments \
-H "Authorization: Bearer qp_test_xxx" \
-H "Content-Type: application/json" \
-d '{"amount": 2.5, "reference": "ORDER-1001", "description": "T-shirt",
"success_url": "https://yourshop.so/thanks?order=1001"}'<?php
$ch = curl_init("https://pay.qalintech.com/api/v1/payments");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("QALINPAY_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"amount" => 2.5,
"reference" => "ORDER-1001",
"success_url" => "https://yourshop.so/thanks?order=1001",
]),
]);
$payment = json_decode(curl_exec($ch), true);
header("Location: " . $payment["checkout_url"]);const res = await fetch("https://pay.qalintech.com/api/v1/payments", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.QALINPAY_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ amount: 2.5, reference: "ORDER-1001" }),
});
const payment = await res.json();
// redirect the customer to payment.checkout_urlResponse 201:
{
"id": "pay_8fK2mQ0aZxY1bC3d",
"object": "payment",
"livemode": false,
"status": "pending",
"amount": 2.5,
"amount_display": "2.50",
"currency": "USD",
"reference": "ORDER-1001",
"description": "T-shirt",
"customer_phone": null,
"checkout_url": "https://pay.qalintech.com/c/pay_8fK2mQ0aZxY1bC3d",
"ussd_code": "*883*907123456*2*5#",
"metadata": {},
"created_at": "2026-11-24T12:00:00.000Z",
"expires_at": "2026-11-24T12:30:00.000Z",
"paid_at": null,
"transaction": null
}Get a payment
GET /payments/:id returns the same object. When paid, transaction holds the Golis Tix, sender number and time.
"transaction": {
"tix": "7603495366",
"amount": 2.5,
"sender_phone": "906170062",
"sender_name": "CABDIQAYUUM MAXAMED",
"occurred_at": "2026-11-24T12:03:12.000Z",
"source": "portal"
}List payments
GET /payments?status=paid&reference=ORDER-1001&limit=20 — newest first, max 100.
Claim (if you build your own checkout)
Only needed if you do not use our checkout page. Call it when the customer says they paid. tix is optional; if given it must match exactly.
POST /payments/:id/claim
{ "phone": "907123456", "tix": "7603495366" }Webhooks
Set your URL on the Developers page. We send POST requests with these events:
payment.paid— money found and matched. Mark the order paid.payment.expired— the customer did not pay in time.webhook.test— sent by the “Send test event” button.
Reply with any 2xx status within 10 seconds. Otherwise we retry after 1 min, 5 min, 30 min, 2 h and 12 h. The same event can arrive more than once, so make your handler idempotent (use data.id).
{
"id": "evt_...",
"type": "payment.paid",
"livemode": true,
"created_at": "2026-11-24T12:03:20.000Z",
"data": { ...payment object... }
}Verify the signature
Header X-QalinPay-Signature: t=1795000000,v1=5257a8…. Compute HMAC-SHA256 of t + "." + raw body with your webhook secret and compare it to v1. Reject if t is older than 5 minutes.
<?php
$secret = getenv("QALINPAY_WEBHOOK_SECRET");
$body = file_get_contents("php://input");
$header = $_SERVER["HTTP_X_QALINPAY_SIGNATURE"] ?? "";
parse_str(str_replace(",", "&", $header), $sig); // ["t" => ..., "v1" => ...]
$expected = hash_hmac("sha256", $sig["t"] . "." . $body, $secret);
if (!hash_equals($expected, $sig["v1"] ?? "") || abs(time() - (int)$sig["t"]) > 300) {
http_response_code(400); exit;
}
$event = json_decode($body, true);
if ($event["type"] === "payment.paid") {
$orderId = $event["data"]["reference"];
// mark order $orderId as paid (only once)
}
http_response_code(200);import crypto from "node:crypto";
import express from "express";
app.post("/qalinpay/webhook", express.raw({ type: "application/json" }), (req, res) => {
const sig = Object.fromEntries(
(req.get("X-QalinPay-Signature") ?? "").split(",").map((p) => p.split("="))
);
const expected = crypto
.createHmac("sha256", process.env.QALINPAY_WEBHOOK_SECRET)
.update(`${sig.t}.${req.body}`)
.digest("hex");
const ok = sig.v1 && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig.v1));
if (!ok || Math.abs(Date.now() / 1000 - Number(sig.t)) > 300) return res.sendStatus(400);
const event = JSON.parse(req.body);
if (event.type === "payment.paid") {
// mark order event.data.reference as paid (only once)
}
res.sendStatus(200);
});Statuses
| pending | Waiting for the customer's money. |
| paid | Money found and matched. Final. |
| expired | Not paid in time. Can still become paid if the money was sent before expiry but found later. |
| paid_late | Matched by hand by the merchant after expiry. |
| refunded | Merchant recorded that they sent the money back. |
Test mode
Payments created with a qp_test_ key show an orange “Test mode” bar on the checkout page and a Simulate payment button, which pretends the money arrived. Webhooks are sent as normal, with "livemode": false.
Errors
Errors use normal HTTP status codes and this body:
{ "error": { "code": "invalid_amount", "message": "amount must be a positive number..." } }Common codes: unauthorized (401), invalid_request, invalid_amount, invalid_phone, wallet_not_configured (400), not_found (404), rate_limited (429, max 120 requests/minute per key).