POS Integration Guide

Collect donations through the SGGG middleware

Your POS terminal reserves a receipt number, runs the card payment on your switch, then tells us whether it succeeded or failed. Three calls, one key per machine. This page has everything your integrator needs.

BASE URLhttps://apiserv.sggg.in/api

00What this does

The middleware issues a unique receipt sequence number for every donation and records the final payment outcome so our books match your receipts. Card data never touches us — payment stays entirely on your side.

A donation captures: donor name, address, purpose, amount, an 80G checkbox, and optionally PAN / Aadhaar. You send those when you reserve; we hand back a sequence number to print on the receipt.

01Integration flow

Call reserve first so the sequence number is ready to print, run the payment, then call confirm or fail.

1

Reserve

Send donor + amount details to /reserve.php. Get back a sequence_no and status RESERVED.

2

Run the payment

Your POS / switch charges the card or QR. The middleware isn't involved.

3

Confirm or fail

On success call /confirm.phpSUCCESS. On failure call /fail.phpFAILED. Print the sequence number on the receipt for successful donations.

Use the same txn_reference across all three calls for one donation, so every call points at the same record.

02Authentication

Every request carries the terminal's API key as a bearer token. One key per physical machine.

Authorization: Bearer sggg_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DetailValue
HeaderAuthorization: Bearer <key> (or X-API-Key: <key>)
ScopeOne key = one terminal. The key maps to a machine number (e.g. POS007) that appears in every sequence it issues.
Content-Typeapplication/json on every request
MethodAll endpoints are POST
Keys are secrets. Store them in the device's secure storage. Never commit them to a shared app build or send them in plain email. If a key leaks, SGGG rotates it and the old one stops working instantly.

03Reserve a sequence

POST/api/reserve.php→ 201 Created

Validates the donation, issues a receipt sequence number, and records it as RESERVED.

Request body

FieldTypeNotes
txn_referencestring requiredYour unique id for this attempt. The idempotency key.
donor_namestring required
purposestring requiredFund / purpose of donation.
amountnumber required*Rupees, e.g. 501.00.
amount_paiseinteger alt*Send this or amount, not both.
donor_addressstring optional
want_80gboolean optionalIf true, pan becomes required.
panstring optionalFormat ABCDE1234F.
aadhaarstring optional12 digits.
extraobject optionalAny future fields; stored as-is.

Example request

curl -X POST https://apiserv.sggg.in/api/reserve.php \ -H "Authorization: Bearer sggg_your_key" \ -H "Content-Type: application/json" \ -d '{ "txn_reference": "POSVENDOR-TXN-90210", "donor_name": "Anita Sharma", "purpose": "Annadanam", "amount": 501.00, "want_80g": true, "pan": "ABCDE1234F" }'

Response 201

{ "ok": true, "data": { "sequence_no": "POS007-2026-07-09-0042", "txn_reference": "POSVENDOR-TXN-90210", "status": "RESERVED", "amount": "501.00", "service_date": "2026-07-09" } }
Idempotent. Re-sending the same txn_reference returns the same sequence_no — no duplicate is created.

04Confirm a payment

POST/api/confirm.php→ 200 OK

Marks a reserved donation as SUCCESS after the payment clears.

Request body

FieldTypeNotes
txn_referencestring one of†Same reference used in reserve.
sequence_nostring one of††Send txn_reference or sequence_no.
payment_refstring optionalBank / POS payment id, for reconciliation.
curl -X POST https://apiserv.sggg.in/api/confirm.php \ -H "Authorization: Bearer sggg_your_key" \ -H "Content-Type: application/json" \ -d '{ "txn_reference": "POSVENDOR-TXN-90210", "payment_ref": "PL-AUTH-55231" }'
Idempotent. Confirming twice returns the same SUCCESS. Confirming a transaction already marked failed returns 409.

05Report a failure

POST/api/fail.php→ 200 OK

Marks a reserved donation as FAILED. The sequence number is burned — kept for audit, never reused.

Request body

FieldTypeNotes
txn_referencestring one of†
sequence_nostring one of††Send either one.
failure_reasonstring optionalFree text.
curl -X POST https://apiserv.sggg.in/api/fail.php \ -H "Authorization: Bearer sggg_your_key" \ -H "Content-Type: application/json" \ -d '{ "txn_reference": "POSVENDOR-TXN-90210", "failure_reason": "Card declined" }'

06Sequence number

Print this exactly as returned on the receipt. Don't reformat or pad it.

{MACHINE}-{YYYY-MM-DD}-{NNNN} POS007-2026-07-09-0042
MACHINEThe terminal's machine number, tied to its API key.
YYYY-MM-DDService date (IST).
NNNNCounter that resets to 0001 each day, per machine.
A failed payment keeps its number as a FAILED record. Numbers are never reused.

07Retries & idempotency

POS networks time out. Every endpoint is safe to retry as long as you reuse the same txn_reference.

txn_reference ruleWhy
Generate once per attemptBefore the reserve call. A UUID or your internal txn id works.
Unique per terminalTwo donations must never share one reference.
Reuse across all 3 callsSo reserve → confirm/fail all resolve to the same record.

Retry policy

Timeout / 5xxRetry the same request up to 3× with backoff (1s, 2s, 4s).
4xxDon't blindly retry — fix the request. It's a data or auth problem, not a glitch.
Lost resultIf a payment succeeds but the confirm never lands, the record stays RESERVED. Send confirm later with the same reference — it still works.

08Error codes

All errors share one shape: { "ok": false, "error": "message" }

HTTPMeaningWhat to do
400Bad request / invalid JSONCheck the body is valid JSON.
401Missing / invalid API keyCheck the Authorization header and key.
403Terminal revoked or vendor suspendedContact SGGG.
404Transaction not foundThe reference/sequence doesn't exist for this terminal.
409Conflicting statusOutcome already recorded — reconcile, don't retry.
422Validation errorRead error; fix the field (e.g. 80G without PAN).
500Server errorSafe to retry with the same txn_reference.

09Request builder

Fill these in to generate a ready-to-run curl command for a reserve call. Nothing is sent from this page — it only builds the command for you to run.

10Go-live checklist

Run these against your test key before asking SGGG for production keys.

Happy path

reserve → confirm. You get a sequence_no and a final SUCCESS.

Failed payment

reserve → fail. Status is FAILED and the number isn't reissued to the next donation.

Idempotent reserve

Send the same txn_reference twice — identical sequence_no, one record.

80G without PAN

Confirm you get a 422 and your UI blocks it before submit.

Bad key

A wrong key returns 401 and the device handles it gracefully.

Support: when reporting an issue, include the machine number and the txn_reference — that's enough for SGGG to trace any transaction in the logs.