# GH-Cash API — payment confirmation gateway (read-only, no transfers) Base URL: https://sham.ghawi.app Auth: header `Authorization: Bearer ` on every /v1 request. Your *secret* is never sent in requests. It is only used to verify webhook signatures. ## How it works 1. Create an invoice for one of your linked wallets. You get the exact amount, an invoice id, and the wallet address to pay. 2. Tell your customer to send exactly that amount, in that currency, to the wallet address. 3. While the invoice is pending, GH-Cash reads the wallet's latest incoming transfers. When one matches (same amount, same currency, received after the invoice was created, not used by another invoice) the invoice becomes `paid` and your webhook is called. GH-Cash cannot send money and never shows a balance. It only confirms incoming payments. ## Two invoices waiting for the same amount A transfer that fits more than one pending invoice of the same wallet is NOT assigned by guesswork: it is held, and the invoices stay `pending`. Ask the payer for the ShamCash transaction number (shown in their app as #123456789) and call `POST /v1/invoices/{id}/verify` with `{ "transaction_id": "123456789" }`. That exact transfer is checked (incoming, same currency, amount not below the invoice, not used before) and the invoice becomes `paid`. You can avoid this case by never keeping two pending invoices with the same amount (for example add a few cents), or by passing `payer_name` (part of the sender's name as ShamCash shows it) when you know it. Always offer the customer a "paste your transaction number" fallback. ## Endpoints GET /v1/wallets your wallets: [{ id, provider, address, status }] (status "active" = linked and readable) POST /v1/invoices body: { wallet_id, amount, currency: "SYP"|"USD", webhook_url?, metadata?, payer_name?, ttl_minutes? (default 30, max 1440) } GET /v1/invoices/{id} POST /v1/invoices/{id}/verify body optional: { transaction_id }. Without it: checks the wallet now. With it: claims that transfer. GET /v1/wallets/{id}/transactions last 20 transfers GH-Cash saw: [{ transaction_id, direction: "in"|"out", amount, currency, at, name, invoice_id }]. Add ?refresh=1 to read the wallet now. GET /pay/{id} hosted payment page you can redirect the customer to Invoice object: { id, amount, currency, status, created, expires, paid_at, paid_amount, transaction_id, wallet_id, wallet_address, metadata, pay_url } Invoice status: pending | paid | expired. Times are unix milliseconds. `paid_amount` is what actually arrived. ## Webhook (invoice.paid) POST to your webhook_url with JSON: { "event": "invoice.paid", "invoice": { id, amount, currency, status, paid_at, paid_amount, transaction_id, metadata } } webhook_url must be HTTPS on a public address. Answer 2xx within 5 s; redirects are not followed. Up to 8 retries with growing gaps. The hosted pay page /pay/{id} shows the wallet address, a QR of it, and lets the customer confirm with their transaction number. Headers: X-GHCash-Timestamp (unix seconds), X-GHCash-Signature = hex HMAC-SHA256(secret, timestamp + "." + rawBody) Reject if the signature does not match or the timestamp is older than 5 minutes. Respond 2xx. Failed deliveries are retried with backoff (8 attempts). A webhook is a hint: always re-check the invoice with GET /v1/invoices/{id} before fulfilling an order, and also poll that endpoint while the customer waits (the webhook can be late). ## Errors 401 MISSING_API_KEY | INVALID_API_KEY, 400 VALIDATION_ERROR, 404 NOT_FOUND, 402 SUBSCRIPTION_REQUIRED, 409 WALLET_NOT_READY (wallet not linked yet), 410 EXPIRED, 422 TX_NOT_FOUND | TX_MISMATCH | TX_USED | TX_TOO_OLD (verify with a transaction number: exact amount, same currency, sent after the invoice was created, not used before), 429 TOO_MANY_ATTEMPTS (10 transaction-number tries per invoice, 60 per key per hour), 503 wallet cannot be read right now Billing (for merchants): a prepaid balance in the dashboard pays each linked wallet's month automatically. When it runs out, that wallet stops being read and POST /v1/invoices answers 402 SUBSCRIPTION_REQUIRED until the balance is topped up.