# PayVerify: getting started PayVerify verifies Ethiopian mobile-money and bank payments (Telebirr, CBE) for your app. Your customer pays your Telebirr number or CBE account with their own app; your server asks PayVerify whether that payment really happened, for the right amount, to you, and was not used before. You get APPROVED, REJECTED or NEEDS_REVIEW, inline or by webhook. Base URL: `https://app.verifytx.com.et/api/v1`. JSON in and out, UTF-8, times in ISO 8601 UTC. Successful responses are `{ "data": }`; errors are `{ "error": { code, message, request_id } }`. ## Three ways the customer proves a payment 1. **SMS match (Telebirr, instant):** the customer types only the last 4 digits of the phone they paid from. The bank SMS on the merchant's phone (forwarded by SMSWire or any SMS forwarder via a custom webhook) approves it within seconds. Needs SMS matching on for the project. See `sms-match` and `checkout-ux`. 2. **Transaction number:** the customer types the txn/reference from their bank SMS or app. PayVerify checks it with the bank. See `verify`. 3. **Receipt:** the customer uploads a screenshot or PDF. Checked by bank API when it has a txn, otherwise by OCR plus rules (asynchronous, result by webhook). See `verify`. ## Env vars (server side only, never in source or the browser) ```sh PAYVERIFY_URL="https://app.verifytx.com.et" PAYVERIFY_API_KEY="pk_test_…" # pk_live_… in production PAYVERIFY_WEBHOOK_SECRET="whsec_…" # verifies X-PayVerify-Signature ``` ## A typical integration 0. `GET https://app.verifytx.com.et/api/v1/capabilities` once while building: it says which of the flows above this merchant can actually use, and which to build around (`capabilities`). 1. A small server-side client: `POST https://app.verifytx.com.et/api/v1/verifications` with the key, the expected amount, the provider, and `externalRef` = your order id (idempotent retries). 2. Checkout UI that collects what the chosen flow needs and shows the pending state (`checkout-ux`). 3. A webhook route that verifies the signature over the raw body and marks the order paid on `verification.approved` (`webhooks`). 4. Test end to end with a `pk_test_` key (`test-mode`), then switch to a `pk_live_` key. ## Endpoints | method | path | | |---|---|---| | POST | /api/v1/verifications | submit a payment (JSON or multipart with a receipt) | | GET | /api/v1/verifications | list, newest first (?status=&limit=&cursor=) | | GET | /api/v1/verifications/:id | one verification | | POST | /api/v1/verifications/:id/transaction | SMS match fallback: attach the txn number | | POST | /api/v1/payment-requests | optional payment intent | | GET | /api/v1/payment-requests/:id | one payment request | | POST | /api/v1/transactions/lookup | read a bank transaction, store nothing | | GET | /api/v1/capabilities | which methods work right now, per bank | | GET | /qr/<token>.svg | the scan-to-pay image for a claim (no API key; see `qr`) | With the PayVerify MCP server (`https://app.verifytx.com.et/mcp`), an agent can create the project, keys and webhook and run sandbox payments itself: see `agents`. --- # Authentication Send the project's API key on every request, from your server only: ```http Authorization: Bearer pk_live_… ``` (`x-api-key: pk_live_…` also works.) Keys are created in the dashboard (API keys tab) or by an agent with `create_api_key`, and shown once; only a hash is kept. - `pk_live_…`: live mode. `pk_test_…`: sandbox (see `test-mode`). - Missing key: `401 unauthorized`. Wrong, revoked or expired key: `401 invalid_api_key`. - Every response has an `x-request-id` header; quote it in support requests. - Rate limit per key (default 120/min, set per project): headers `x-ratelimit-limit`, `x-ratelimit-remaining`, `x-ratelimit-reset`; over it, `429 rate_limited` with `retry-after` (seconds). - The account's plan sets a monthly live-verification limit shared by all its projects: over it, `402 quota_exceeded`. More projects/keys than the plan allows: `402 plan_limit_reached`; a method it doesn't include: `402 plan_feature_unavailable`. Test keys are exempt. --- # Test mode A `pk_test_…` key works against a sandbox in the same project: - Its verifications and payment requests have `livemode: false`. Live keys never see test data and vice versa (`404`); reusing an `externalRef` across modes is `409 external_ref_conflict`. - Test data skips the monthly quota, the duplicate-transaction ledger and analytics. - Test verifications are matched **only by simulated bank SMS** (dashboard Playground, or the MCP tool `simulate_bank_sms`), never by real ones. - Bank lookups stay real and read-only, so a made-up txn number is `TRANSACTION_NOT_FOUND` in test mode too. - Webhooks still fire for test data, with `livemode: false` in `data`. **Check `livemode` before fulfilling an order.** ## Getting APPROVED in the sandbox SMS matching must be on for the project (dashboard SMS tab, or MCP `update_sms_match`). - **SMS match flow:** create a verification with `payerLast4: "1234"` (202 PENDING), then simulate a Telebirr SMS for the same amount and last 4 digits. It approves within the request (`decision.source = "SMS"`) and fires `verification.approved`. - **Txn flow:** simulate a Telebirr SMS with `transaction_number: "PGTEST0001"` first, then create a verification with `transactionNumber: "PGTEST0001"` and the same amount: 200 APPROVED from the stored SMS. - **Fallback flow:** create with `payerLast4`, then `POST /verifications/:id/transaction` with a txn you simulated. --- # Submit a verification `POST https://app.verifytx.com.et/api/v1/verifications`: JSON, or `multipart/form-data` when you upload a receipt file. | field | type | | |---|---|---| | amount | number, required | What the customer should have paid (ETB). | | providerCode | "TELEBIRR" \| "CBE", required | | | transactionNumber | string 3-64 | From the customer's bank SMS or app. | | payerLast4 | string, 4 digits | SMS match (Telebirr): last 4 digits of the paying phone. | | amountTag | boolean | Quote a unique amount instead (see `amount-tag`). Returns `pay_amount`; cannot be combined with the fields above or a receipt. | | receipt | file (multipart) | pdf, png, jpg, jpeg or webp, up to 10 MB. | | receiptUrl | https URL | Instead of a file. | | paymentRequestId | string | Links a payment request (see `payment-requests`). | | externalRef | string ≤200 | Your order id. Idempotency key: the same value returns the first verification (200). | | metadata | object | Echoed back and in webhooks (in multipart, a JSON string). | At least one of `transactionNumber`, a receipt, `payerLast4`, or `amountTag: true` is required. ```sh curl -X POST https://app.verifytx.com.et/api/v1/verifications \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"amount": 250, "providerCode": "TELEBIRR", "transactionNumber": "CKH8ABC12D", "externalRef": "order_123"}' ``` ```sh curl -X POST https://app.verifytx.com.et/api/v1/verifications \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" \ -F amount=250 -F providerCode=CBE -F externalRef=order_123 -F receipt=@receipt.jpg ``` ## Responses - `200` with `status` APPROVED, REJECTED or NEEDS_REVIEW: decided inline (stored bank SMS, then the bank API). - `202` with `status: "PENDING"`: a receipt is queued for OCR, or an SMS match is waiting for the SMS. The result arrives by webhook, or poll `GET https://app.verifytx.com.et/api/v1/verifications/:id`. - `200` on an idempotent replay of an `externalRef`. Retrying after a REJECTED with a new txn number needs a new `externalRef` (e.g. `order_123:2`), since the same one replays the rejected verification. Bank checks need the merchant's receiving account for the provider (the Telebirr number or CBE account money is paid into) in the project: dashboard Accounts tab, or MCP `add_receiving_account`. Without one a txn can't be bank-verified (`NO_BANK_ACCOUNT`). --- # What can be verified right now Two of the four flows are only ever confirmed by the bank's SMS arriving on the merchant's phone: the quoted amount (`amount-tag`) and the payer's last digits (`sms-match`). If the merchant has no phone forwarding SMS, or the phone is off, a quoted 250.03 is an amount nobody will ever confirm. Ask first, and build the flow the answer recommends. ```sh curl https://app.verifytx.com.et/api/v1/capabilities -H "Authorization: Bearer $PAYVERIFY_API_KEY" curl "https://app.verifytx.com.et/api/v1/capabilities?provider=TELEBIRR" -H "Authorization: Bearer $PAYVERIFY_API_KEY" ``` ```json { "data": { "object": "capability_list", "livemode": true, "sms": { "connected": true, "phones": 2, "online": 0, "last_delivery_at": "..." }, "banks": [ { "provider": "TELEBIRR", "recommended_method": "transaction", "fallbacks": ["amount_tag", "sms_match", "receipt"], "methods": { "amount_tag": { "available": true, "reason": "no_phone_online", "detail": "..." }, "sms_match": { "available": true, "reason": "no_phone_online", "detail": "..." }, "transaction": { "available": true, "reason": "ok", "detail": null }, "receipt": { "available": true, "reason": "ok", "detail": null } } } ] } } ``` - **`recommended_method`** is the one to build around: the first method that works cleanly, in the order `amount_tag` → `sms_match` → `transaction` → `receipt` (fewest customer actions first). `fallbacks` are the others still worth offering, best first. - **`available: false`** means the method cannot work at all and `POST /verifications` will refuse it (422, see below). - **`available: true` with a `reason` other than `ok`** is the middle ground: it is accepted and will reach a decision, but don't count on an instant one. Keep the transaction-number fallback visible. - **`qr`** on each bank says whether a scannable code can be shown and whether it carries the amount; see `qr`. - **`sms`** is the honest state of the forwarding phones: `connected` that any are set up, `online` how many have reached us recently. "Online" means the phone reaches PayVerify, not that bank SMS are arriving — any authenticated delivery counts. Liveness is refreshed every few minutes, so cache the answer for about a minute, per bank. | reason | method | means | |---|---|---| | ok | any | nothing in the way | | bank_unsupported | amount_tag, sms_match | this bank can't be matched that way (only Telebirr can today) | | matching_disabled | amount_tag, sms_match | the project has SMS matching off | | tags_disabled | amount_tag | quoted amounts are off for the project | | tolerance_conflict | amount_tag | the project's amount tolerance isn't 0, so a santim can't identify a payment | | no_phone_connected | amount_tag, sms_match | nothing forwards bank SMS; the method is refused | | no_phone_online | amount_tag, sms_match | phones are set up but none has reached us lately; still served | | no_receiving_account | transaction | no account for this bank, so a txn goes to review | | bank_unreachable | transaction | the bank's API can't be reached from here right now | | ocr_unavailable | receipt | receipt reading isn't configured, so receipts go to review | | simulated | amount_tag, sms_match | test mode: the simulator stands in for the phone | A `pk_test_` key answers `livemode: false` and never refuses an SMS method — the sandbox approves from simulated SMS (`test-mode`), so `reason` is `simulated` where a live key would have said `no_phone_connected`. The `sms` block still reports the real phones, so you can tell a merchant they have none. When a method is impossible, the refusal says the same thing in `details`, so a client that didn't ask first can still recover: ```json { "error": { "code": "amount_tag_unavailable", "message": "No phone is forwarding bank SMS, so a quoted amount could never be confirmed — send a transactionNumber instead", "request_id": "...", "details": { "reason": "no_phone_connected", "method": "amount_tag", "provider": "TELEBIRR", "fallbacks": ["transaction", "receipt"] } } } ``` To hear about changes instead of polling, handle the `sms_availability.changed` webhook (`webhooks`). --- # Instant verify by SMS (Telebirr) The merchant's receiving phone forwards the Telebirr "you have received" SMS (sender `127`) to PayVerify (dashboard: Bank SMS → Setup → Add phone). A project can have several phones (e.g. one per bank or SIM), each forwarding one of two ways, and all feed the same matching: - **SMSWire** (recommended): the SMSWire app on the phone; PayVerify configures it from an agent token. - **Custom webhook**: any SMS forwarder app, Tasker/MacroDroid, a GSM modem or the merchant's own code POSTs each SMS to `/api/integrations/sms/` with that phone's key: `Authorization: Bearer pv_sms_…` (or `?key=pv_sms_…`). Body JSON or form: `{"from": "127", "body": "", "received_at": ""}`; common aliases (sender/phoneNumber, text/message, timestamp) are accepted. The customer pays and enters only the **last 4 digits** of the phone they paid from: ```sh curl -X POST https://app.verifytx.com.et/api/v1/verifications \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"amount": 250, "providerCode": "TELEBIRR", "payerLast4": "1234", "externalRef": "order_123"}' ``` - SMS already arrived with that payer and amount: `200 APPROVED`, `decision.source = "SMS"`. - Not yet: `202 PENDING` with `sms_deadline_at` (the project's wait, 60 s by default). The SMS approves it the moment it arrives: you get `verification.approved` by webhook, or see it by polling `GET https://app.verifytx.com.et/api/v1/verifications/:id`. - After `sms_deadline_at`, ask the customer for the transaction number: ```sh curl -X POST https://app.verifytx.com.et/api/v1/verifications/$ID/transaction \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"transactionNumber": "CKH8ABC12D"}' ``` Same 200/202 semantics as create. A late SMS can still approve a pending verification; the txn ledger stops any payment being used twice. - Only a unique match approves: if two pending payments share last-4 and amount, the SMS is marked ambiguous and `SMS_AMBIGUOUS` is added to `decision.reasons`. - To ask the customer for nothing at all, see `amount-tag`: PayVerify quotes a unique amount and the payment identifies itself. - `422 sms_match_unavailable`: SMS matching is off for the project, no phone forwards bank SMS at all (add one via SMSWire or a custom webhook in the dashboard: Bank SMS → Setup), or the provider isn't Telebirr. `error.details` carries `reason` (`matching_disabled`, `no_phone_connected`, `bank_unsupported`) and `fallbacks` — the methods to use instead. Ask `GET https://app.verifytx.com.et/api/v1/capabilities` first to avoid the round trip. - A phone that is set up but has gone quiet does **not** refuse the claim; it is served as usual and `capabilities` reports `no_phone_online`, so keep the txn-number fallback in reach. - `409 invalid_state` on /transaction: the verification already has a txn or is decided. --- # Verify with nothing typed (amount tags) The last-4 digits exist to tell two customers paying the same amount apart. Quote a different amount instead and the payment identifies itself: ask for **250.03** rather than 250.00, and the Telebirr SMS for exactly 250.03 approves that order and no other. Needs SMS matching on (`sms-match`), amount tags enabled, and the project's amount tolerance at 0. Not every bank can be paid this way: it takes a bank whose app lets the payer enter the fraction and whose SMS prints it back, which each bank declares for itself. Telebirr does today; `get_api_schema` and a `422 amount_tag_unavailable` naming the bank will tell you about any other. A bank with no quoted-amount support still has the `payerLast4` flow, if it has SMS matching at all. Create the claim when the customer commits to paying — not on page load, since the quote is only payable for a while: ```sh curl -X POST https://app.verifytx.com.et/api/v1/verifications \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"amount": 250, "providerCode": "TELEBIRR", "amountTag": true, "externalRef": "order_123"}' ``` ```json { "status": "PENDING", "amount": 250, "pay_amount": 250.03, "amount_tag": 0.03, "pay_window_ends_at": "...", "sms_deadline_at": "..." } ``` - Where the bank can be scanned, show the code on the claim (`qr`) and the customer never types the amount at all — see `qr`. - Show **`pay_amount`** verbatim, santim included. Rounding it, or showing `amount`, makes the payment unidentifiable — and the santim is also what the customer's bank app must be told. - `amount` stays the price you asked for. You receive `pay_amount`; the difference is at most the merchant's configured maximum (0.99 ETB by default). - The SMS approves it the moment it arrives: `verification.approved` by webhook, `decision.source = "SMS"`, with `AMOUNT_TAG_MATCHED` in `decision.reasons`. - **Expiry.** After `pay_window_ends_at` the quote stops matching. Posting the same `externalRef` again then quotes a fresh `pay_amount` and returns `202` — so a customer coming back to the order is simply re-quoted. Before it expires, the same `externalRef` replays unchanged (`200`), which is what a reloaded checkout should see. - **If they pay the plain amount** (250.00), the claim goes to `NEEDS_REVIEW` with `UNTAGGED_PAYMENT` and the SMS attached, for the merchant to approve in the dashboard. Treat it like any other review: wait for the webhook. - The transaction-number fallback still works at any time: `POST /verifications/:id/transaction`. - `422 amount_tag_unavailable`: not enabled for the project, the project's amount tolerance isn't 0, this bank can't be paid a quoted amount, or nothing forwards its SMS (the message says which, and `error.details` carries `reason` and `fallbacks`). `422 sms_match_unavailable` when SMS matching itself is off. `503 amount_tag_unavailable`: every amount near that price is spoken for right now — fall back to `payerLast4` or a transaction number. - `GET https://app.verifytx.com.et/api/v1/capabilities` answers all of that before you quote anything, and `no_phone_online` there is the warning that the quote may not be confirmed quickly even though it is accepted. - One caveat worth knowing: an unrelated payment of exactly the quoted amount into the same Telebirr number within the window approves that order, since nothing else distinguishes it. --- # Scan to pay A quoted amount still has to reach the customer's bank app. Typing 250.03 by hand is where that goes wrong — so where the bank supports it, PayVerify hands you a code carrying the amount already. The customer scans, confirms, and types nothing at all. The code is not a verification method: the payment is still matched by the bank's SMS exactly as in `amount-tag` and `sms-match`. It only changes how the amount gets there. ## It comes with the claim Every verification and payment request carries `qr`, or `null` when there is nothing to show: ```json { "pay_amount": 250.03, "qr": { "payload": "hQVDUFYwMWFQTwLwUg0xNzk1NDQ5MjM4MDMxVxYlGXlxcoDSYREBUJ8kBjI1MC4wMw==", "image_url": "https://app.verifytx.com.et/qr/v1.v.ver_7h2.m4k1s.0f3a…svg", "amount_embedded": true, "expires_at": "2026-11-23T19:05:00Z" } } ``` - **`image_url`** needs no API key and is unguessable, so it goes straight into your checkout: `Scan to pay`. It is signed and expires with the quote. - **`payload`** is the same code as text, for a native app or your own renderer. - **`amount_embedded: false`** means the code gets the customer to your account but carries no amount — keep showing `pay_amount` for them to type. Always render the amount next to the code anyway; it costs nothing and covers this case. - The image is drawn when it is fetched, so a re-quoted claim (see `amount-tag`) serves its new amount at the same URL. Don't cache or copy it. Once the verification settles the URL stops working, so a customer can't pay a quote nobody is waiting for. ## Before it appears `qr` is `null` until three things hold, and `GET https://app.verifytx.com.et/api/v1/capabilities` says which one is missing: ```json { "provider": "TELEBIRR", "qr": { "available": true, "amount_embedded": true, "reason": "ok", "detail": null } } ``` | reason | means | |---|---| | bank_unsupported | this bank has no code of its own (only Telebirr does today) | | no_receiving_account | the project has no account for that bank to be paid into | | not_verified | the merchant hasn't yet confirmed a code scans — dashboard, Settings → Accounts | | simulated | test mode: the payload is a sandbox marker, not payable | That last-but-one is deliberate. The payload format is read off real codes rather than a published specification, so a merchant scans one themselves once before any customer is shown one. It takes a few seconds and it is the dashboard that asks. A `pk_test_` key always returns a code, and it always reads `PAYVERIFY-TEST:…`. Build and screenshot the screen with it; scanning it in a bank app does nothing, which is the point. ## What the customer sees Show the code, the amount, and the account it pays. Telebirr's own screen is the model: the amount large, the code below it, the receiving name underneath. Keep the transaction-number fallback (`sms-match`) in reach for a customer whose camera won't cooperate. --- # Checkout UX PayVerify is called **from your server** only. The browser talks to your backend; your backend calls PayVerify with the secret key and stores the verification id on the order. Pick the flow from `GET https://app.verifytx.com.et/api/v1/capabilities` (`capabilities`) rather than hard-coding one: `recommended_method` tells you which of the screens below to show for a given bank, and its `fallbacks` which to keep behind "I've paid but it's not confirmed". ## Quoted amount (Telebirr), nothing to type 1. Backend: `POST /verifications` with `amount`, `providerCode: "TELEBIRR"`, `amountTag: true`, `externalRef: ` — when the customer picks Telebirr, not on page load. 2. Show `qr.image_url` when the claim carries one — the customer scans it and the amount is already in it (`qr`) — and the merchant's Telebirr number with `pay_amount` **exactly as returned** (250.03, not 250) for everyone else: a copy button helps, and say "pay this exact amount, santim included". 3. Show "Waiting for your payment…" and poll your backend every 2-3 s. There is nothing to ask the customer for. 4. `APPROVED`: success. `NEEDS_REVIEW` with `UNTAGGED_PAYMENT`: they paid the round amount — "We're checking your payment". 5. Offer "I've paid but it's not confirmed" at any point, which reveals the transaction-number input (`POST /verifications/:id/transaction`). 6. After `pay_window_ends_at`, POST the same `externalRef` again to get a fresh quote, and show the new amount. ## SMS match (Telebirr), last 4 digits 1. Show the amount and the merchant's Telebirr number, and ask the customer to pay it. 2. Ask: "Last 4 digits of the phone you paid from" (4-digit numeric input). 3. Backend: `POST /verifications` with `amount`, `providerCode: "TELEBIRR"`, `payerLast4`, `externalRef: `. 4. `200 APPROVED`: show success. `202 PENDING`: show "Confirming your payment…" with a countdown to `sms_deadline_at`, and poll your backend every 2-3 s (your backend reads its DB updated by the webhook, or calls `GET /verifications/:id`). 5. When the countdown ends and it's still PENDING, reveal a "Transaction number" input; submit it to `POST /verifications/:id/transaction`. Keep polling while the SMS can still arrive. 6. `REJECTED`: show what went wrong from `decision.reasons` (e.g. AMOUNT_MISMATCH, DUPLICATE_TRANSACTION) and let them try again with a new `externalRef`. `NEEDS_REVIEW`: "We're checking your payment, you'll be notified": a person decides in the dashboard and you get a webhook. ## Transaction number One input for the txn/reference from the customer's bank SMS or app, plus the amount and provider. Usually decided inline (200). Validate 3-64 characters client side and trim spaces. ## Receipt upload A file input (image or PDF ≤10 MB) sent as multipart from your backend. Expect `202 PENDING`; show "We're verifying your receipt" and wait for the webhook. ## Fulfilment rules - Fulfil only on the server, only for `status: "APPROVED"`, only when `livemode` matches your environment, and only once per order (webhooks can be retried). - Store `verification.id` on the order; reconcile with `GET /verifications/:id` if a webhook was missed. - Use `externalRef` = order id so a double-clicked Pay button or a retried request doesn't create two verifications. --- # Payment requests (optional) Create one when you ask a customer to pay. Its creation time anchors the project's `REQUEST_TIME` receipt-date window, and verifications can reference it with `paymentRequestId`. ```sh curl -X POST https://app.verifytx.com.et/api/v1/payment-requests \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"expectedAmount": 250, "providerCode": "TELEBIRR", "externalRef": "order_123"}' ``` Fields: `expectedAmount` (required), `currency` (default ETB), `providerCode`, `externalRef` (idempotent: the same value returns the first, 200), `metadata`. Returns `201` with a `payment_request` (`status` OPEN, FULFILLED, EXPIRED or CANCELED). `GET https://app.verifytx.com.et/api/v1/payment-requests/:id` reads one. --- # Look up a transaction `POST https://app.verifytx.com.et/api/v1/transactions/lookup` reads a transaction from the provider: no matching, nothing stored. ```sh curl -X POST https://app.verifytx.com.et/api/v1/transactions/lookup \ -H "Authorization: Bearer $PAYVERIFY_API_KEY" -H "Content-Type: application/json" \ -d '{"provider": "TELEBIRR", "transactionNumber": "CKH8ABC12D"}' ``` A 12-character CBE reference needs the receiving account's last 8 digits: pass `accountSuffix`, or leave it out to use the project's CBE receiving account. Returns `200` with a `transaction` (payer, recipient, amount, date), `404 not_found` when the provider has no such transaction, `422 validation_error` with `details: { field: "accountSuffix", digits: 8 }` when a CBE reference needs the account digits and none are known, `502 provider_unreachable` when the provider or relay is down. --- # Statuses and decisions - `APPROVED`: verified by bank SMS, the bank API, or OCR plus rules. - `NEEDS_REVIEW`: unclear; a person decides in the dashboard (or Telegram). You get a webhook either way. - `REJECTED`: a duplicate or a clear mismatch. - `PENDING`: still processing (receipt OCR, or waiting for the SMS). `decision.source`: `SMS`, `BANK_API`, `GEMINI` (receipt OCR) or `MANUAL`. `decision.reasons[]` holds machine-readable codes: | code | meaning | |---|---| | BANK_VERIFIED | the bank confirmed it | | SMS_MATCHED | a trusted bank SMS confirmed it | | SMS_AMBIGUOUS | more than one pending payment fits the SMS | | DUPLICATE_TRANSACTION | this txn already paid another verification | | AMOUNT_MISMATCH / AMOUNT_GROSSLY_OFF | paid amount differs from `amount` | | RECIPIENT_MISMATCH | paid to someone else | | OUTSIDE_WINDOW | receipt date outside the project's window | | LOW_VALIDITY_SCORE / OCR_UNREADABLE | receipt looks wrong or can't be read | | TRANSACTION_NOT_FOUND | the bank has no such txn | | PROXY_UNREACHABLE | the bank couldn't be reached | | NO_BANK_ACCOUNT | no receiving account configured for the provider | | UNTRUSTED_SENDER | the SMS didn't come from the bank's sender | Each project sets a receipt-date window (minutes, `TODAY` or `REQUEST_TIME`, past only or both ways); a receipt dated outside it goes to review instead of approving. --- # Webhooks Set the project's webhook URL (dashboard Settings, or MCP `set_webhook`). PayVerify POSTs JSON when a verification settles: | event | when | |---|---| | verification.approved | approved (SMS, bank, OCR or manual) | | verification.rejected | rejected | | verification.needs_review | sent to human review | | webhook.test | a test from the dashboard or MCP `send_test_webhook`; reply 2xx and ignore | | sms_availability.changed | instant verification from bank SMS started or stopped working for the project | Body: `{ "event": "...", "data": , "created_at": "..." }`, where `data` is the verification for the `verification.*` events and an `sms_availability` object for `sms_availability.changed`: ```json { "event": "sms_availability.changed", "created_at": "...", "data": { "object": "sms_availability", "livemode": true, "state": "degraded", "previous_state": "live", "connected": true, "phones": 2, "online": 0, "last_delivery_at": "...", "affected_methods": ["amount_tag", "sms_match"], "changed_at": "..." } } ``` `state` is `live` (a phone is alive), `degraded` (phones set up, none reachable) or `off` (none set up); switch the checkout to a transaction number while it isn't `live`, and see `capabilities` for the per-bank detail. Trouble is sent at once, a recovery only once it has held for ten minutes, and it is never sent for test mode. Headers: `X-PayVerify-Event`, `X-PayVerify-Delivery` (the same id across retries: dedupe on it), and `X-PayVerify-Signature: t=,v1=` when the project has a webhook secret. Reply 2xx within 15 s. Anything else is retried with exponential backoff (6 attempts). Handle events idempotently: an order can see the same event twice. ## Verify the signature `v1` is HMAC-SHA256 with the webhook secret over `"."`. Use the **raw** body bytes (not re-serialized JSON), reject old timestamps, and compare in constant time. Node: ```js import crypto from "node:crypto"; export function verifyPayVerifySignature(rawBody, header, secret, toleranceSec = 300) { if (!header) return false; const parts = Object.fromEntries(header.split(",").map((p) => p.trim().split("=", 2))); const t = Number(parts.t); if (!parts.v1 || !Number.isFinite(t)) return false; if (Math.abs(Date.now() / 1000 - t) > toleranceSec) return false; const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest(); const given = Buffer.from(parts.v1, "hex"); return given.length === expected.length && crypto.timingSafeEqual(given, expected); } ``` Next.js App Router route: ```ts export async function POST(req: Request) { const raw = await req.text(); if (!verifyPayVerifySignature(raw, req.headers.get("x-payverify-signature"), process.env.PAYVERIFY_WEBHOOK_SECRET!)) { return new Response("bad signature", { status: 400 }); } const { event, data } = JSON.parse(raw); if (event === "verification.approved" && data.livemode === (process.env.NODE_ENV === "production")) { // mark the order with externalRef = data.external_ref as paid (once) } return new Response("ok"); } ``` Express: mount the route with `express.raw({ type: "application/json" })` and pass `req.body.toString("utf8")`. Python: ```py import hashlib, hmac, time def verify_payverify_signature(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool: parts = dict(p.strip().split("=", 1) for p in (header or "").split(",") if "=" in p) try: t = int(parts["t"]) except (KeyError, ValueError): return False if abs(time.time() - t) > tolerance: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, parts.get("v1", "")) ``` --- # Errors Every non-2xx response is `{ "error": { "code", "message", "request_id", "details"? } }`. Branch on `code`; quote `request_id` in support. | code | status | meaning | |---|---|---| | unauthorized | 401 | no API key | | invalid_api_key | 401 | wrong, revoked or expired key | | validation_error | 422 | bad or missing fields (`details`: [{ path, message }]) | | sms_match_unavailable | 422 | SMS matching off for the project, no phone forwarding SMS, or the bank can't be matched (`details`: { reason, method, provider, fallbacks }) | | amount_tag_unavailable | 422 / 503 | quoted amounts off, tolerance not 0, bank or phones can't support it (same `details`) / no unique amount free right now | | unsupported_media_type | 415 | use JSON or multipart | | not_found | 404 | not in this project (or the other mode) | | invalid_state | 409 | the verification already has a txn or is decided | | external_ref_conflict | 409 | externalRef already used in the other mode | | quota_exceeded | 402 | plan's monthly limit reached | | plan_limit_reached | 402 | more projects/keys/phones than the plan allows | | plan_feature_unavailable | 402 | the plan doesn't include this method | | account_suspended / project_suspended | 403 | suspended by PayVerify | | rate_limited | 429 | wait `retry-after` seconds | | provider_unreachable | 502 | bank or relay down; retry later | | internal | 500 | retry with backoff; contact support with request_id | Retry 429, 502 and 500 with backoff; resend the same `externalRef` so a retry can't double-create. The two `*_unavailable` codes mean the method cannot work for this project right now, not that the request was malformed: read `details.fallbacks` and submit again with one of those methods, and ask `GET https://app.verifytx.com.et/api/v1/capabilities` up front to choose correctly (`capabilities`). --- # AI agents (MCP) PayVerify has an MCP server at `https://app.verifytx.com.et/mcp` (Streamable HTTP). Make an agent token in the dashboard (AI agents page), then: ```sh claude mcp add --transport http payverify https://app.verifytx.com.et/mcp \ --header "Authorization: Bearer pv_agent_…" ``` Cursor (`~/.cursor/mcp.json`) or VS Code (`mcp.json`): a server with `url: https://app.verifytx.com.et/mcp` and header `Authorization: Bearer pv_agent_…`. Token access: **Sandbox** (default) sets up projects, test keys, webhooks and runs sandbox payments; **Full** adds live keys and live data; **Read only** changes nothing. ## Tools - Learn: `get_integration_guide`, `get_api_schema`. - Setup: `get_account`, `list_projects`, `get_project`, `get_capabilities`, `create_project`, `create_api_key`, `set_webhook`, `get_webhook_secret`, `send_test_webhook`, `list_webhook_deliveries`, `update_sms_match`, `add_receiving_account`. - Sandbox: `create_test_payment_request`, `create_test_verification`, `simulate_bank_sms`, `attach_test_transaction`, `lookup_transaction`. - Read: `get_verification`, `list_verifications`, `get_payment_qr`. The `integrate_payverify` prompt (`/mcp__payverify__integrate_payverify` in Claude Code) walks the agent through a full integration and a sandbox payment. No MCP? Give your assistant `https://app.verifytx.com.et/llms-full.txt`.