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

  1. Your server creates a payment → you get a checkout_url.
  2. Redirect the customer to checkout_url. They enter their Sahal number, dial *883*your-number*amount# and tap “I have paid”.
  3. QalinPay finds the money in your Golis account (same amount, same sender number, in time) and marks the payment paid.
  4. We send a payment.paid webhook to your server and send the customer to your success_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.

HTTP
Authorization: Bearer qp_live_xxxxxxxxxxxxxxxx

Create a payment

POST /payments

FieldTypeDescription
amountnumber, requiredUSD, max 2 decimals. Example 2.5
referencestringYour order id (max 100). Shown to the customer and searchable.
descriptionstringWhat the customer is paying for (max 200).
customer_phonestringCustomer's Sahal number, if you know it. Skips the phone step.
success_urlstringWhere to send the customer after payment.
cancel_urlstringLink shown if the payment expires.
webhook_urlstringOverrides your default webhook URL for this payment.
expires_in_minutesinteger5–1440, default 30.
metadataobjectYour own key/value data, returned in webhooks.
cURL
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
<?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"]);
JavaScript (Node 18+)
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_url

Response 201:

JSON
{
  "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.

JSON
"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.

HTTP
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).

JSON
{
  "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
<?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);
JavaScript (Express)
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

pendingWaiting for the customer's money.
paidMoney found and matched. Final.
expiredNot paid in time. Can still become paid if the money was sent before expiry but found later.
paid_lateMatched by hand by the merchant after expiry.
refundedMerchant 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:

JSON
{ "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).