eSchool Gateway

Zamfara State Internal Revenue Service

Developer documentation · v1

TSA Gateway API

Integrate your school portal or MDA system with the ZIRS Treasury Single Account gateway: create transactions, send payers to a branded checkout, receive signed webhooks and pull settlement reports.

Base URL: https://www.echopay.ng/api/v1 JSON over HTTPS HMAC-SHA512 signed

Overview

Every tertiary institution or MDA connected to the gateway receives its own public key, secret key and webhook secret from the State IRS (or from API & Webhooks in the institution portal). You use them to:

  • initialize a payment and redirect the payer to the hosted checkout, which shows your institution's logo and the payment channels the State has enabled for you;
  • receive a signed server-to-server webhook when the payment succeeds, fails or is reversed;
  • verify the payment before giving value, and pull transaction and settlement reports.

You never talk to Paystack, Flutterwave, Remita, Interswitch or CoralPay directly — the gateway handles the processors, fees, split settlement and reconciliation.

No system to integrate? Use payment links from the portal instead — no code needed.

Quick start

  1. Sign in to the institution portal → API & Webhooks. Copy your public key and secret key, and set your callback URL (webhook endpoint) and return URL.
  2. From your server, call POST /transactions/initialize with the amount, your own unique reference and the payer's details.
  3. Redirect the payer to the checkout_url in the response.
  4. Handle the webhook at your callback URL (verify the signature, respond 200).
  5. Before giving value, call GET /transactions/{reference}/verify and check status = "successful" and the amount.

Authentication

Every API request must include four headers. Requests are only accepted over HTTPS, from whitelisted IPs if your institution has an IP whitelist, and within 5 minutes of the timestamp.

HeaderValue
X-TSA-Public-KeyYour public key, e.g. pk_live_…
AuthorizationBearer sk_live_… (your secret key)
X-TSA-TimestampCurrent Unix time in seconds, e.g. 1796332721
X-TSA-Signaturehex( HMAC_SHA512( timestamp + "." + raw_body, secret_key ) ) — for GET requests raw_body is an empty string
Content-Typeapplication/json (POST requests)

Every request needs a fresh timestamp and signature: a signature that has already been used is rejected as a replay (HTTP 401). Sign the exact bytes you send as the body. Keep your secret key on your server only — never in a browser or mobile app. If it leaks, regenerate keys from the portal; old keys stop working immediately.

// PHP
$ts   = (string) time();
$body = json_encode($payload);
$sig  = hash_hmac('sha512', $ts . '.' . $body, $secretKey);

Payment flow

  1. Your server → POST /transactions/initialize → receives reference and checkout_url.
  2. Payer is redirected to checkout_url, sees your logo and amount, chooses a channel (card, transfer, USSD, Remita, PayDirect at bank, CoralPay…) and pays.
  3. The gateway confirms the payment with the processor server-side (never trusting browser parameters).
  4. The gateway sends a signed transaction.successful webhook to your callback URL and redirects the payer to your return URL.
  5. You verify and give value. Funds are split and settled to your TSA sub-account on the State's settlement cycle.

PayDirect / Remita: the payer may complete payment hours later at a bank branch. Keep the order open and rely on the webhook (or poll verify) rather than the browser return.

Initialize a transaction

POST https://www.echopay.ng/api/v1/transactions/initialize

FieldTypeRequiredDescription
amountnumberYesAmount in Naira, e.g. 45000.00. This is what your institution is owed; any processor fee is added on top when your fee bearer is customer.
merchant_referencestring ≤100YesYour unique reference (invoice/order ID). Re-using it returns the existing transaction (idempotent).
customer.namestringYesPayer's full name.
customer.emailemailYesReceipt is emailed here.
customer.phonestringNoPayer's phone number.
descriptionstring ≤255NoShown on checkout and receipt, e.g. "2026/2027 School fees – 200L".
processorstringNoSkip channel selection by pre-selecting a processor code (see processors).
callback_urlurlNoOverride your default webhook URL for this transaction.
return_urlurlNoWhere the payer is sent after payment (overrides default).
metadataobjectNoAny JSON you want echoed back (matric number, session, fee type…).
{
  "amount": 45000,
  "merchant_reference": "INV-2026-000123",
  "description": "2026/2027 Tuition - 200 Level",
  "customer": { "name": "Amina Yusuf", "email": "amina@example.com", "phone": "08031234567" },
  "metadata": { "matric_no": "CSC/2024/123", "session": "2026/2027" }
}

Response 201 Created

{
  "status": true,
  "message": "Transaction initialized",
  "data": {
    "reference": "TSA261027K3J9QX2L1M",
    "merchant_reference": "INV-2026-000123",
    "status": "pending",
    "amount": 45000,
    "fee": 0,
    "fee_bearer": "customer",
    "total_amount": 45000,
    "currency": "NGN",
    "processor": null,
    "checkout_url": "https://www.echopay.ng/pay/TSA261027K3J9QX2L1M",
    "customer": { "name": "Amina Yusuf", "email": "amina@example.com", "phone": "08031234567" },
    "metadata": { "matric_no": "CSC/2024/123", "session": "2026/2027" },
    "created_at": "2026-10-27T10:15:22+01:00"
  }
}

Redirect the payer to data.checkout_url. fee and total_amount are updated once the payer picks a channel.

Verify a transaction

GET https://www.echopay.ng/api/v1/transactions/{reference}/verify

Accepts either the gateway reference or your merchant_reference. If still pending, the gateway re-queries the processor before answering. Always verify before giving value, and confirm data.status == "successful" and data.amount matches what you expect.

{
  "status": true,
  "message": "Transaction successful",
  "data": {
    "reference": "TSA261027K3J9QX2L1M",
    "merchant_reference": "INV-2026-000123",
    "status": "successful",
    "amount": 45000, "fee": 675, "fee_bearer": "customer", "total_amount": 45675,
    "processor": "paystack", "channel": "card", "processor_reference": "4099260516",
    "paid_at": "2026-10-27T10:17:03+01:00",
    "settlement_status": "unsettled",
    ...
  }
}

Get / list transactions

GET https://www.echopay.ng/api/v1/transactions/{reference} — returns the stored record without re-querying.

GET https://www.echopay.ng/api/v1/transactions?status=successful&from=2026-10-01&to=2026-10-31&per_page=50&page=1

{ "status": true, "data": [ { ...transaction... } ], "meta": { "page": 1, "per_page": 50, "total": 1284, "last_page": 26 } }

For GET requests with a query string, sign an empty body: HMAC(timestamp + ".", secret).

Payment processors

GET https://www.echopay.ng/api/v1/processors — channels currently enabled for your institution.

CodeProcessorNotes
paystackPaystackCards, bank transfer, USSD and bank via Paystack checkout.
flutterwaveFlutterwaveCards, transfer, USSD and more via Flutterwave Standard.
remitaRemitaRemita Retrieval Reference (RRR) - pay online or at any bank branch.
interswitchInterswitch Web CheckoutVerve, Mastercard, Visa, transfer and USSD via Interswitch Webpay.
paydirectInterswitch PayDirectPay at any bank branch or Quickteller using the payment reference.
coralpayCoralPay VergeC'Gate USSD, cards, NQR and bank transfer via CoralPay Verge.

Settlements

Successful payments are split (State share, consultant commission, other beneficiaries, remainder to your account) and batched into settlements on the State's cycle — Instant, T+0, T+1, weekly or custom.

GET https://www.echopay.ng/api/v1/settlements — list settlement batches with destination accounts.

GET https://www.echopay.ng/api/v1/settlements/{reference} — one batch, its destination accounts and the transactions it covers.

{
  "status": true,
  "data": {
    "reference": "STL261028AB12CD34", "status": "settled", "cycle": "t1",
    "transactions_count": 482, "gross_amount": 21690000, "fees_amount": 0, "net_amount": 21690000,
    "settled_at": "2026-10-28T11:02:10+01:00",
    "accounts": [
      { "beneficiary": "State Polytechnic", "type": "institution", "bank": "Central Bank of Nigeria (TSA)", "account_number": "0123456789", "amount": 20605500, "status": "paid", "payout_reference": "NIP-88210" },
      { "beneficiary": "IRS (State share)", "type": "state", "amount": 1084500, "status": "paid" }
    ],
    "transactions": [ { "reference": "TSA…", "merchant_reference": "INV-…", "amount": 45000, "paid_at": "…" } ]
  }
}

Webhooks (callbacks)

When a transaction changes status the gateway sends a POST with a JSON body to your callback URL.

EventWhen
transaction.successfulPayment confirmed by the processor
transaction.failedPayment declined, failed or amount mismatch
transaction.reversedPayment reversed (e.g. PayDirect reversal)
test.pingSent from the portal's "Send test webhook" button

Headers

X-TSA-Event:      transaction.successful
X-TSA-Timestamp:  1793112456
X-TSA-Signature:  hex( HMAC_SHA512( timestamp + "." + raw_body, webhook_secret ) )

Body

{ "event": "transaction.successful", "data": { ...same shape as the verify response... } }

Verifying (PHP)

$raw = file_get_contents('php://input');
$ts  = $_SERVER['HTTP_X_TSA_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_TSA_SIGNATURE'] ?? '';
$expected = hash_hmac('sha512', $ts . '.' . $raw, getenv('TSA_WEBHOOK_SECRET'));
if (!hash_equals($expected, $sig) || abs(time() - (int) $ts) > 300) { http_response_code(401); exit; }
$event = json_decode($raw, true);
// Look up your order by $event['data']['merchant_reference'], call /verify, then give value once.
http_response_code(200);

Respond with any 2xx within 20 seconds. Non-2xx responses and timeouts are retried after 1 min, 5 min, 15 min, 1 h and 2 h (6 attempts). Webhooks can arrive more than once — make your handler idempotent. Delivery history is visible in the portal.

Return URL

After payment the payer sees a gateway receipt with a Return to … button that opens your return URL with:

https://your-portal/return?reference=TSA261027K3J9QX2L1M&merchant_reference=INV-2026-000123&status=successful

These parameters are for display only — always confirm with /verify or the webhook.

Statuses & errors

Transaction statusMeaning
PendingCreated; awaiting payment or confirmation
SuccessfulPaid and confirmed — give value
FailedDeclined / failed / amount mismatch
AbandonedExpired without payment
ReversedReversed after success
HTTPMeaning
200 / 201OK / created
401Missing/invalid keys, timestamp or signature
403Institution suspended or IP not whitelisted
404Transaction / settlement not found
409merchant_reference reused with a different amount
422Validation failed — see errors
429Rate limit (120 requests/minute)
{ "status": false, "message": "Validation failed", "errors": { "customer.email": ["The customer.email field must be a valid email address."] } }

Settlement status on a transaction: unsettled → batched (in a pending settlement) → settled.

Fees & splits

Each processor has a fee (percentage + flat, optionally capped) configured by the State. Your institution's fee bearer decides who pays it:

  • Customer — the fee is added to the amount at checkout; you receive the full amount before splits.
  • Institution — the payer pays amount; the fee is deducted before splits.

Split rules (State share, consultant commission, other beneficiaries) are then applied in order as fixed amounts or percentages, and the remainder goes to your settlement account. Each transaction's split lines are visible in the portal.

Payouts are automatic. When the payer chooses Paystack, Flutterwave, Remita or Interswitch, the gateway sends the split to the processor with the payment, and the processor pays each beneficiary account directly on its normal settlement schedule. PayDirect payments settle according to the split configured with Interswitch. CoralPay has no split settlement, so the State pays those out from its collection account. The settlement_status and the settlement endpoints show which accounts were paid.

Code samples

<?php
function tsa(string $method, string $path, ?array $payload = null): array {
    $pk = getenv('TSA_PUBLIC_KEY'); $sk = getenv('TSA_SECRET_KEY');
    $body = $payload ? json_encode($payload) : '';
    $ts = (string) time();
    $ch = curl_init('https://www.echopay.ng/api/v1' . $path);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => $body ?: null,
        CURLOPT_HTTPHEADER => [
            'Content-Type: application/json', 'Accept: application/json',
            'X-TSA-Public-Key: ' . $pk,
            'Authorization: Bearer ' . $sk,
            'X-TSA-Timestamp: ' . $ts,
            'X-TSA-Signature: ' . hash_hmac('sha512', $ts . '.' . $body, $sk),
        ],
    ]);
    $res = json_decode(curl_exec($ch), true);
    curl_close($ch);
    return $res;
}

$init = tsa('POST', '/transactions/initialize', [
    'amount' => 45000, 'merchant_reference' => 'INV-2026-000123',
    'customer' => ['name' => 'Amina Yusuf', 'email' => 'amina@example.com'],
]);
header('Location: ' . $init['data']['checkout_url']);

// later
$v = tsa('GET', '/transactions/INV-2026-000123/verify');
if ($v['data']['status'] === 'successful' && $v['data']['amount'] == 45000) { /* give value */ }
const crypto = require('crypto');

async function tsa(method, path, payload) {
  const body = payload ? JSON.stringify(payload) : '';
  const ts = Math.floor(Date.now() / 1000).toString();
  const sig = crypto.createHmac('sha512', process.env.TSA_SECRET_KEY).update(ts + '.' + body).digest('hex');
  const res = await fetch('https://www.echopay.ng/api/v1' + path, {
    method,
    headers: {
      'Content-Type': 'application/json', Accept: 'application/json',
      'X-TSA-Public-Key': process.env.TSA_PUBLIC_KEY,
      Authorization: 'Bearer ' + process.env.TSA_SECRET_KEY,
      'X-TSA-Timestamp': ts, 'X-TSA-Signature': sig,
    },
    body: body || undefined,
  });
  return res.json();
}

const init = await tsa('POST', '/transactions/initialize', {
  amount: 45000, merchant_reference: 'INV-2026-000123',
  customer: { name: 'Amina Yusuf', email: 'amina@example.com' },
});
// res.redirect(init.data.checkout_url)

// Webhook (Express): use express.raw({ type: 'application/json' }) so you sign the raw bytes
app.post('/tsa/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const ts = req.get('X-TSA-Timestamp');
  const expected = crypto.createHmac('sha512', process.env.TSA_WEBHOOK_SECRET).update(ts + '.' + req.body).digest('hex');
  if (expected !== req.get('X-TSA-Signature')) return res.sendStatus(401);
  const event = JSON.parse(req.body);
  res.sendStatus(200);
});
import hmac, hashlib, json, os, time, requests

def tsa(method, path, payload=None):
    body = json.dumps(payload, separators=(',', ':')) if payload else ''
    ts = str(int(time.time()))
    sk = os.environ['TSA_SECRET_KEY']
    sig = hmac.new(sk.encode(), f'{ts}.{body}'.encode(), hashlib.sha512).hexdigest()
    headers = {
        'Content-Type': 'application/json', 'Accept': 'application/json',
        'X-TSA-Public-Key': os.environ['TSA_PUBLIC_KEY'],
        'Authorization': f'Bearer {sk}', 'X-TSA-Timestamp': ts, 'X-TSA-Signature': sig,
    }
    return requests.request(method, 'https://www.echopay.ng/api/v1' + path, data=body or None, headers=headers).json()

init = tsa('POST', '/transactions/initialize', {
    'amount': 45000, 'merchant_reference': 'INV-2026-000123',
    'customer': {'name': 'Amina Yusuf', 'email': 'amina@example.com'},
})
print(init['data']['checkout_url'])
PK="pk_live_xxx"; SK="sk_live_xxx"
BODY='{"amount":45000,"merchant_reference":"INV-2026-000123","customer":{"name":"Amina Yusuf","email":"amina@example.com"}}'
TS=$(date +%s)
SIG=$(printf '%s' "$TS.$BODY" | openssl dgst -sha512 -hmac "$SK" | sed 's/^.* //')

curl -X POST https://www.echopay.ng/api/v1/transactions/initialize \
  -H "Content-Type: application/json" \
  -H "X-TSA-Public-Key: $PK" -H "Authorization: Bearer $SK" \
  -H "X-TSA-Timestamp: $TS" -H "X-TSA-Signature: $SIG" \
  -d "$BODY"

# Test your credentials
TS=$(date +%s); SIG=$(printf '%s' "$TS." | openssl dgst -sha512 -hmac "$SK" | sed 's/^.* //')
curl https://www.echopay.ng/api/v1/ping -H "X-TSA-Public-Key: $PK" -H "Authorization: Bearer $SK" -H "X-TSA-Timestamp: $TS" -H "X-TSA-Signature: $SIG"

Go-live checklist

  • GET /ping returns your institution name (keys and signature are correct).
  • Your server clock is accurate (NTP) — timestamps more than 5 minutes off are rejected.
  • merchant_reference is unique per order; retries reuse it.
  • Webhook endpoint verifies X-TSA-Signature, is idempotent and returns 200 quickly.
  • You call /verify and check status and amount before giving value.
  • Return URL page does not give value by itself.
  • Secret key and webhook secret are stored server-side only (environment variables / vault).
  • Optional: provide your server IPs to the State IRS for whitelisting.

Support: support@echosystems.ng · +2347058883434