Payment Verifier developer guide

Customers pay your designated bank account or wallet directly. Your Node.js backend accepts a Telebirr or CBE identifier, official receipt link, or SMS, then checks the official receipt against your authorized order. A VERIFIED result records a receipt claim in your shared store at the applicable transaction commit.

Your application owns the database, orders, ledger and fulfillment. The SDK writes verification records through your configured adapter. See who owns each responsibility.

For the published 0.3.0 SDK, start with the offline example or build a persistent checkout. Common questions and the API reference cover individual tasks.

An inconclusive result does not show that the customer failed to pay. Recover without asking for another payment.

Upgrade guide · 0.2.0 · 0.1.1 · 0.1.0

Common questions

QuestionShort answer
Where does the customer's money go?Directly to the merchant's designated account or wallet. The SDK checks receipt evidence and records verification state. Responsibilities
Which evidence can I accept?Telebirr and CBE identifiers, official receipt URLs and SMS with supported locators. Formats and examples
Can I reuse my database or schema?Reuse your database and supported client. Use the documented schema for a ready-made adapter or implement the storage contract over your own schema. Storage and custom adapters
What does VERIFIED establish?The official receipt passed the required checks and the claim became durable at the applicable transaction commit. Guarantees and result fields
Can the same transfer verify two orders?One shared store admits a single claim for a provider transaction. Independent stores cannot coordinate duplicate claims. Duplicate scope
What do I tell a customer after a timeout?Keep the order pending. Say the receipt could not be checked yet and avoid asking for another payment. Recovery and messaging
Which idempotency key should I reuse?Use the original key for uncertain completion. Use a fresh key only for a deliberate new observation after a known outcome. Idempotency
Does the amount have to be exact?Yes by default. The host can configure bounded underpayment or overpayment allowances. Amount policies
How can I learn or test without paying?Run the offline comparison, then exercise real storage with a synthetic provider. Quickstart · Testing modes
Where can I run it?Use a supported Node ESM backend, with outbound provider connectivity and sandboxed Chromium for CBE. Deployment
Can I upgrade an existing store?A valid 0.2.0 store can be retained, with all readers and writers upgraded together. Active 0.1.1 stores require a tested claim-preserving cutover. Upgrade and rollback
Where are the exact imports and types?Find each published entry point and declaration in the API reference.
View guide source

Getting started

Use the published ESM SDK with Node ^24.22.3 or ^26.13.1. Start with the offline example, then follow the persistent checkout in your Node backend.

Offline learning example

In a new directory, install the core package.

npm install --save-exact @1hubengineering/verifier@0.3.0

Save compare-receipt.mjs and run node compare-receipt.mjs.

import assert from 'node:assert/strict';
import {
  compareReceipt,
  createPaymentExpectation,
  parseEtbAmount,
} from '@1hubengineering/verifier';

const amountMinor = parseEtbAmount('500.00');
const expectation = createPaymentExpectation({
  tenantId: 'demo-shop',
  paymentId: 'demo-order',
  provider: 'telebirr',
  currency: 'ETB',
  amountMinor,
  recipientName: 'Demo Shop',
  recipientAccountLast4: '1234',
  reference: 'ORDER_1234',
  validFrom: 1700000000000,
  validUntil: 1700000060000,
});

const result = compareReceipt(expectation, {
  provider: 'telebirr',
  currency: 'ETB',
  transactionId: 'SYNTH1234',
  status: 'SUCCESSFUL',
  amountMinor,
  recipientName: 'Demo Shop',
  recipientAccountLast4: '1234',
  reference: 'ORDER_1234',
  transactionAt: 1700000030000,
  paymentType: null,
  ambiguousFields: [],
});

assert.equal(result.status, 'MATCH');
console.log(result.status);

Expect MATCH. This pure function compares supplied evidence, with no provider connection, authenticity check, database, or receipt claim. A definite failed check returns MISMATCH. Missing, invalid or ambiguous required evidence without a definite failed check returns INCOMPLETE. The @1hubengineering/verifier/comparison and @1hubengineering/verifier/input subpaths also work in a browser.

Complete persistent checkout

Follow the checkout walkthrough for package selection, provider wiring, database migration, trusted expectations, verification and repeat-safe application updates. Review security and privacy before exposing a receipt submission endpoint. Use recovery when a result is inconclusive or the submission response is lost.

View guide source

Persistent checkout

This walkthrough uses the npm 0.3.0 public interfaces from a Node.js ESM backend. The runnable example uses real SQLite and an injected offline provider. Follow the live wiring below for official lookups on your own deployment.

1. Select and install packages

Use Node ^24.22.3 or ^26.13.1. In a new working directory install the core, one store adapter and its tested driver. For the local example run:

npm install --save-exact @1hubengineering/verifier@0.3.0 @1hubengineering/storage-sql@0.3.0 better-sqlite3@13.2.0

For PostgreSQL or MySQL, or an existing Drizzle or Prisma client, choose an adapter from the storage guide. The database client runs in your backend.

2. Configure a provider

For Telebirr use import { retrieveTelebirr } from '@1hubengineering/verifier/providers' and set providers: { telebirr: { retrieve: retrieveTelebirr } }. For CBE install @1hubengineering/provider-cbe@0.3.0 and playwright@1.65.1, run npx playwright install chromium, and set providers.cbe = createCbeProvider({ maxConcurrency: 1 }), importing that factory from @1hubengineering/provider-cbe. The built-in receipt lookup adapters take no merchant API credentials. Your merchant must provide an authorized receiving account and a way for the payer to enter the expected receipt note if you require one. The backend needs provider egress and, for CBE, the browser dependencies and OS sandbox. Use your app's configuration system for paths, limits and credentials for infrastructure you operate. Telebirr · CBE · Deployment

The example registers telebirrFixture in place of the live adapter. Use synthetic locators only with fixtures. Security and privacy

3. Provision and initialize storage

Provision a fresh verifier store on your infrastructure. With local SQLite, open a writable file with new Database(path) from better-sqlite3, pass it to sqliteStorage(database) from @1hubengineering/storage-sql/sqlite, and run await storage.migrate() explicitly. Pass the adapter and provider map to createReceiptVerifier({ storage, providers }), then run await verifier.initialize(). Keep the host connection open while serving requests and close it on shutdown. Use the same claim store for all workers handling the merchant's receipts. Migrations and store ownership

4. Register the order and submit evidence

Authenticate the customer and authorize access to the requested order using your host's existing authentication and data access. The server looks up the tenant, order ID, configured provider, price, receiving account name and suffix, merchant note and acceptance window. It passes that snapshot through createPaymentExpectation and verifier.registerExpectation. Keep this snapshot stable across retries. Capture the host invoice number in reference only if that value belongs in the provider's receipt note.

The request body can contain the locator and a submission key. The server gets tenantId and paymentId from the authorized order and calls verifier.submit({ tenantId, paymentId, idempotencyKey, receiptLocator }). Before the first request, preserve the original key and locator together, or a secure reference to them, if recovery needs to survive page navigation or a client restart. Use the host's authorized request tracking for a persistent copy, limit sensitive data, and avoid storing a raw SMS when its canonical identifier is sufficient. Apply admission and request-size limits before accepting evidence. Evidence formats · Expectation fields

5. Apply the committed result and recover safely

Branch on the returned status and handle rejected operation errors by code. Leave the order pending on a timeout. Recover a dropped response with the original evidence and key. Use a fresh key for a deliberate new observation only when the known result and order state allow one. A duplicate claim calls for merchant review. Result and error handling · Recovery

Apply a committed VERIFIED result in a host transaction. In the example a guarded order update and one fulfillment request commit together. The fulfillment request has a unique order key. A worker delivering goods or calling another service must also make that effect repeat-safe, for example by passing a stable fulfillment key to a service that honors it. An SDK commit and a separate host transaction can fail independently. The example recovers the gap by replaying the original request. An application can also consume the SDK outbox and acknowledge an event after its own commit. For a shared transaction, use prepare and complete with the actual active transaction. Transactions and outbox

Run the persistent synthetic checkout

Save persistent-checkout.mjs with the installed packages and pass it a new, empty directory.

node persistent-checkout.mjs "$(mktemp -d)"

The script checks timeout replay, a fresh observation, an amount mismatch, invalid evidence, duplicate claims, bound-key conflicts and order authorization. It simulates losing a successful response, processes the recovered result twice and checks that only one fulfillment request exists. The scratch directory contains orders.sqlite and verifier.sqlite for inspection. This command-line walkthrough simulates an authenticated request and records only a fulfillment intent. The Fastify example shows where to connect real host authentication and order callbacks.

View guide source

Evidence and identifiers

A receipt submission supplies a lookup identifier. Load the amount, merchant account, provider, receipt note and validity window from the authorized server-side order. Screenshots, SMS claims of success, and browser responses carry no authority to mark an order paid.

ProviderIdentifierOfficial URL shapeSynthetic SMS example
Telebirr6–32 ASCII letters or digits. Canonicalized to uppercase.https://transactioninfo.ethiotelecom.et/receipt/DEMOABC123Transaction ID: DEMOABC123 or a message containing the official receipt link
CBEv2- and 1–512 ASCII letters, digits, underscores or hyphens. Preserve case, including the prefix as submitted.https://mbreciept.cbe.com.et/v2-DeMo_A1Receipt: https://mbreciept.cbe.com.et/v2-DeMo_A1 or a message containing a recognizable v2- token

The examples illustrate syntax only. Keep all synthetic locators offline. detectPaymentInput from @1hubengineering/verifier/input recognizes these formats without I/O. Inputs are limited to 4,096 characters. Conflicting locators fail as ambiguous. A standalone URL must match the official HTTPS host and path, without a query, fragment, credentials or custom port. The backend repeats recognition, enforces the expectation's provider and builds the lookup URL from a fixed endpoint and the canonical identifier. The configured adapter retrieves it using its transport policy. Security and privacy

The application order maps to paymentId. The merchant's intended receipt text maps to reference. Set it to the invoice number only when that number is entered as Telebirr Customer Note or CBE Reason / Type of service. The provider transaction ID identifies the transfer at the provider. Telebirr compares the lookup ID to the official transaction ID. For CBE, the case-sensitive lookup token locates the receipt and the transaction ID extracted from that receipt is used for the claim.

The recipient check compares a normalized name and the last four digits of the account. A matching name and suffix cannot distinguish two accounts with those same values. A recognized identifier only means a lookup is possible. A pure comparison can report MATCH. Backend VERIFIED requires provider retrieval, all required checks, and claim persistence. Result guarantees

View guide source

Results and operation errors

Use createReceiptVerifier({ storage, providers }) after migrating the store. Call initialize() to check or establish its record format. The provider map can contain telebirr, cbe, or both. An optional now clock returns integer epoch milliseconds. Supply a fixed clock only when your test requires one.

Expected-payment fields

Build the snapshot with createPaymentExpectation(input) and register it with registerExpectation(expectation). A repeat of the identical expectation is safe. Changes to registered values require a new application-owned payment identity. Use cancelExpectation({ tenantId, paymentId }) to close an open expectation.

FieldValue from the application
tenantId, paymentIdAuthorized tenant and payment scope. Use stable nonempty strings up to 128 characters without surrounding whitespace or ASCII control characters.
provider, currencytelebirr or cbe, and ETB.
amountMinor, amountPolicyPositive safe integer ETB minor units from parseEtbAmount and the optional exact or tolerance policy. See amounts.
recipientName, recipientAccountLast4Merchant's account name (nonblank, up to 256 characters) and exactly four digits as a string.
reference, referenceRequiredCase-sensitive provider receipt note, up to 255 characters. An empty string requires referenceRequired: false and matches only a blank or absent note. A nonempty reference still has to match with that flag. Whitespace-only expectations are rejected.
validFrom, validUntilInclusive bounds in integer epoch milliseconds, from zero to 8.64e15, in chronological order. With a new attempt, the SDK clock must also be in the window before retrieval and when completing it.

submit({ tenantId, paymentId, idempotencyKey, receiptLocator }, options?) accepts the customer's locator with the host's authorized scope. Use a stable, nonempty key up to 128 characters without surrounding whitespace or ASCII control characters. The optional retrieval options include signal, timeoutMs (default 15 seconds, up to 60 seconds for HTTP transport) and maxBytes (up to 2,000,000). Provider options and browser bounds have separate settings. Evidence · Checkout example

Results and claim guarantees

statusTrigger and stageApplication handling
VERIFIEDPAYMENT_VERIFIED at completion. Required checks passed and the receipt claim, attempt and event were written. verified is true, retryable is false, and receipt and source are present.Wait for the outer commit if composing in a caller-owned transaction. Apply the committed outcome with a repeat-safe host update.
MISMATCHAt comparison, at least one definite check failed. For example, AMOUNT_UNDERPAID or MULTIPLE_MISMATCHES. Receipt, source and findings are present.Review differences. Retry a pending receipt only if the adapter explicitly recommends retry, pending status is the only issue, and the order permits a fresh attempt.
NOT_FOUNDRECEIPT_NOT_FOUND at receipt_retrieval when an adapter recognizes a provider-confirmed absence. No receipt or source. Retryability is adapter-supplied and defaults to false.Check the identifier or review manually. An unexplained 404 from the built-in transport is UNAVAILABLE.
UNAVAILABLEAt receipt_retrieval, receipt_rendering, receipt_parsing or comparison. Examples include PROVIDER_TIMEOUT, browser startup failure and REQUIRED_FIELD_MISSING. Transport/renderer/parser failures have no receipt or source. Incomplete comparisons include their snapshot, findings and source and set retryable: false.Keep the order pending. For a known completed attempt with retryable: true, start a bounded fresh attempt if appropriate. Review nonretryable evidence and configuration problems.
INVALID_INPUTAt input_parsing for malformed or unsupported input, or input_validation for a different provider, such as PROVIDER_MISMATCH. A synchronous rejection has no attempt ID. A durable rejected admission can have a verification ID. Neither has a receipt or source. retryable is false.Ask the buyer to correct the evidence. An already bound key with invalid or changed evidence instead raises IDEMPOTENCY_CONFLICT.

Every result includes status, code, verified, stage, retryable, tenantId, paymentId, expectedProvider, verificationId, input, message, checks, details, receipt and source. Invalid input can have a recognized input when the provider differs. Diagnostic fields are bounded and can still contain sensitive data. Return selected customer-safe fields and use structured codes in application logic. Recovery · Safe logging

The comparison checks provider, successful status, the actual ETB transfer principal and currency, normalized recipient name, account suffix, exact note, and provider transaction time. Telebirr also compares the official transaction ID with the lookup ID. CBE requires a valid official transaction ID distinct from its lookup token and type A2A. Missing, ambiguous or invalid fields prevent verification. Definite failed checks produce MISMATCH even if other fields are incomplete. At completion the SDK rechecks expectation state and atomically claims the provider transaction ID once in the shared store. The observation describes that receipt and retrieval time. It cannot establish irreversible funds, permanent account credit, or events after retrieval. Additional reconciliation or release-of-goods checks are application policy.

Operation errors

A rejected operation can raise VerificationOperationError. Read its code, stage, retryable and details. Its toJSON() returns those fields with type: 'VERIFICATION_OPERATION_ERROR' and message. Error causes stay out of that representation. Business-facing responses should be selected by the host. Retryability defaults to false. In particular, STORAGE_OUTCOME_UNKNOWN calls for original-key recovery even with that flag.

CodeStage and causeResponse
INVALID_REQUESTrequest for invalid method inputs, scope, clock or use of a scoped store for preparation. Job-specific parameter checks can use queue. Provider locator/transport validation can also fail at adapter.Correct the call or configuration before retrying.
INVALID_AMOUNT_POLICYexpectation, invalid or out-of-range trusted tolerance.Correct the order policy.
INVALID_EXPECTATIONexpectation, invalid trusted fields.Fix server-side order mapping.
EXPECTATION_NOT_FOUNDexpectation, no registered snapshot.Verify authorization and registration.
EXPECTATION_CONFLICTexpectation, different snapshot for the same scope.Keep the existing snapshot or use the host's new-payment workflow.
EXPECTATION_CANCELLEDexpectation, closed by the merchant.Resolve against the order's state.
EXPECTATION_EXPIREDexpectation, SDK time is after the window.Review the order and any reported transfer. Preserve claims and history.
EXPECTATION_NOT_YET_VALIDexpectation, SDK time is before the window.Check the window and clock before trying again.
EXPECTATION_CHANGEDexpectation, snapshot changed between retrieval/preparation and writing.Reload authorized state and investigate.
IDEMPOTENCY_CONFLICTidempotency for synchronous operations, or queue during job admission. The key is bound to another payment or the incoming evidence does not match the binding. A synchronous submission with malformed evidence on a bound key raises this error. Durable admission can replay a matching rejection fingerprint.Resume with the original request. Correct the host's key handling.
RECEIPT_ALREADY_CLAIMEDcompletion, the payment already has a claim or the same provider transaction is claimed in the store. Can occur before retrieval for an already claimed payment.Recover the original key on a lost response. Escalate conflicting ownership for private merchant review.
PROVIDER_NOT_CONFIGUREDprovider_configuration, expected provider absent from the map.Fix backend wiring.
INVALID_ADAPTER_RESULTadapter, configured provider violated its outcome contract.Inspect the adapter and normalized response using redacted fixtures.
INVALID_PREPARATIONcompletion, token was not prepared by this verifier.Prepare again before starting the write transaction.
OPERATION_CANCELLEDrequest, signal aborted.Resume only if the host still authorizes the attempt. Use original-key recovery if the client did not observe the actual operation outcome.
STORAGE_FAILUREstorage, storage read/write fails. A transaction conflict can set retryable: true.Inspect database health. Retry scoped conflicts by rolling back and retrying the entire caller transaction.
STORAGE_OUTCOME_UNKNOWNstorage, work reached the owned commit boundary and success was not observed.Recover with the original approved submission and key.
CORRUPT_STATEstorage for invalid persisted data. The queue stage can report invalid job records.Stop affected work and investigate format, migrations, or corruption without clearing claims.
INCOMPATIBLE_STOREstorage, incompatible SDK record format. An incompatible job record can use queue.Use the supported version or a claim-preserving migration.
INTERNAL_ERRORadapter on an unexpected provider exception. The queue stage can record an unexpected worker error.Inspect operational telemetry privately. Leave the order unresolved.
JOB_NOT_FOUNDqueue, no job in the supplied scope.Check authorization, scope and job identity.
JOB_IN_PROGRESSidempotency, synchronous key belongs to a pending durable job.Check its authorized job status.
QUEUE_CAPACITYqueue, admission, retention or alias bound was reached.Apply backpressure and check admission or maintenance before retrying.
QUEUE_CONFIGURATIONqueue, invalid or inconsistent policy or encryption key.Correct the deployment and keep all workers consistent.
QUEUE_ATTEMPTS_EXHAUSTEDqueue, execution budget used without a completed observation.Escalate. Keep the order unresolved.

The persistent example exercises a success, a timeout, a mismatch, invalid input, conflicting keys and duplicate claims. The troubleshooting guide maps provider failure codes to operational checks. For declarations of all result and error codes, use the public API reference.

View guide source

Recovery and idempotency

An inconclusive verification does not prove that the customer failed to pay. A timeout alone must not trigger a request for another payment.

Keep the order in an application-owned pending or review state. Show the customer the progress your system actually knows. For a timeout, use “We could not check your receipt yet. Please do not pay again for this order.” For a technical problem, offer your merchant's existing support channel. Only say that a retry was scheduled, an order was saved, or a notification will arrive when your application has actually arranged it. Results and operation errors · Troubleshooting

Idempotency

SituationAction
Response lost or commit uncertainAuthorize the same order again and submit the original evidence with the original key, or repeat durable admission with that key. A lost outer-transaction response also requires checking the host's own transaction outcome.
Completed attempt replayedThe same canonical locator, scope and key return the stored result or terminal job outcome. The retrieval time and result reflect the original observation.
Known completed result and another lookup is appropriateCreate a fresh attempt with a fresh key on the same authorized payment while the expectation is open. Follow the outcome's retry recommendation and the host's attempt budget.
Bound key with changed or malformed evidenceExpect IDEMPOTENCY_CONFLICT. Equivalent presentations of the same canonical locator, such as supported SMS and plain ID, can replay. Reserve new keys for deliberate observations after a known outcome.
Repeated delivery of a verified resultApply the order update and any fulfillment intent with their own stable unique keys. SDK idempotency protects SDK writes.

Keys are scoped by tenant and bind to a payment and canonical locator. Keep the key and original logical submission available before the first request when recovery must survive a client restart. Durable admission also remembers invalid input by a protected fingerprint and can replay the same rejected admission. A changed fingerprint conflicts. Concurrent synchronous submissions can perform separate retrievals before the first commit. The store serializes completion. A scoped transaction conflict requires rollback and a whole-transaction retry. See the checkout example and storage boundaries.

Choose an execution model

  • Synchronous submission fits interactive work within the request deadline. The app handles retries and backpressure. Use short, bounded attempts and exponential backoff with jitter for transient failures. Respect provider delay hints and the expectation window. Avoid tight retry loops.
  • SDK durable jobs persist acceptance, retries, leases and terminal outcomes in the verifier store. Use them when work must survive request deadlines and process restarts. Your app runs the workers and exposes authorized progress. Use a shared 32-byte encryption key and consistent policy across all instances.
  • Existing application queue can call the SDK with its normal submission and recovery model. Persist the original scope and key securely. Decide which layer schedules a fresh observation so two retry loops do not multiply the work.

With createDurableVerifier from @1hubengineering/verifier/jobs, call initialize(), enqueue(submission) and poll status({ tenantId, paymentId }, jobId) after authorizing that scope. Run runOnce({ signal }) from a supervised host worker. The queue tracks QUEUED, RUNNING, RETRY_WAIT, COMPLETED and FAILED. These are job states. COMPLETED includes a verification result, and FAILED a serialized operation error. The queue bounds pending jobs, retained jobs, aliases, concurrency and attempts. It reclaims expired leases and fences stale workers. It schedules eligible retries within its time and attempt budgets. Acknowledge outbox events only after their repeat-safe host processing, then prune eligible terminal jobs using pruneCompleted(before, limit?). Replay bindings survive. Durable-job configuration and defaults

When retries exhaust or evidence stays incomplete, stop automated attempts. Use merchant records or the merchant's provider support to reconcile privately. Keep order state and retry visibility in your application. The queue handles verification work. The host handles customer notifications and escalation. Security and privacy

View guide source

Troubleshooting

Start with the result or operation error and its stage. Keep inconclusive payments pending and follow original-key recovery when the submission or commit outcome is uncertain.

FindingWhat to check
PROVIDER_TIMEOUT, PROVIDER_NETWORK_ERRORCheck outbound routing, provider availability, and deadlines from the actual worker. A timeout alone does not identify an IP or geographic restriction. Compare approved connectivity paths before choosing a deployment route.
PROVIDER_DNS_ERROR, DESTINATION_BLOCKEDCheck the worker resolver and egress policy. The built-in direct transport requires public IPv4 and blocks unsafe destinations.
PROVIDER_TLS_ERRORCheck the backend clock, CA trust, hostname and TLS route. Keep certificate verification enabled.
PROVIDER_HTTP_ERROR, PROVIDER_RATE_LIMITED, PROVIDER_BUSYAn unexplained 404 remains unavailable. Other unexpected responses can indicate provider or transport changes. Honor retryability and delay hints, keep concurrency bounded and investigate recurring errors. A true NOT_FOUND requires recognized provider evidence of absence.
INVALID_PROVIDER_RESPONSE, RECEIPT_TOO_LARGE, UNSUPPORTED_RECEIPT_FORMATCheck headers, response size and parser support with a sanitized fixture. Review provider changes before widening any limits.
RECEIPT_BROWSER_UNAVAILABLECheck the pinned Playwright/Chromium pair, OS dependencies, service user, executable and sandbox support. Run the offline checkCbeBrowser() diagnostic in that runtime.
RECEIPT_RENDER_TIMEOUTCheck CBE worker resource limits, contention and rendering deadline. Escalate if it continues on locally supported fixtures.
REQUIRED_FIELD_MISSING, INVALID_RECEIPT_FIELD, AMBIGUOUS_RECEIPT_FIELD, MULTIPLE_VERIFICATION_ISSUESReview the receipt layout and the configured expected fields. Use merchant review for missing details and derive expectations from trusted records.
STORAGE_FAILURE, STORAGE_OUTCOME_UNKNOWN, CORRUPT_STATE, INCOMPATIBLE_STORECheck database health, active transaction, schema and release. Recover uncertain commits with the original key. Preserve claim records when restoring or migrating.
IDEMPOTENCY_CONFLICTCheck whether the tenant, order and original locator agree with the request saved under that key. Resume the original request.
RECEIPT_ALREADY_CLAIMEDLook up the original authorized attempt and escalate disputes privately. Keep claim details out of responses to other customers.

Deployment and connectivity distinguishes local Chromium checks, TLS-only diagnostics and authorized live receipt checks. The historical deployment report records direct Telebirr timeouts from a VPS and successful retrieval via a workstation tunnel. It establishes that behavior for the tested paths only.

Log a stage, code, internal correlation ID, provider name and coarse timing. Keep raw SMS, receipt URLs, account details, idempotency keys, unfiltered diagnostics and database errors out of routine logs. Security and privacy

View guide source

Storage and transactions

Your application owns and operates the database. The SDK reads and writes the verification records required by its documented workflow through your configured storage adapter.

OwnerResponsibility
Application and merchantPayment accounts, products, prices, customers, orders, invoices, authentication, authorization, financial records, balances, fulfillment, refunds and reconciliation. The merchant receives funds directly.
Database operatorProvisioning, access control, migration, backups, recovery, maintenance, retention policy and connection lifecycle.
SDK through its adapterTrusted expectation snapshot, lookup outcomes, idempotency, claims, outbox and optional durable verification jobs.
Application operationsRun the backend and any workers, apply business changes once, communicate with customers and escalate unresolved payments.

Select an adapter and migrate

Choose Direct SQL for a host driver, Drizzle for a tested Drizzle client, or Prisma for a generated Prisma 7 client. All three cover selected versions of PostgreSQL, MySQL and local SQLite. Use the release matrix for exact pins and the migration guide for the built-in tables.

Initialize a fresh verifier store for a new integration. You can add verifier tables to an existing application database. Fresh verifier records do not require clearing orders or any other application tables. Use one migration owner. For compatible 0.2.0 stores, preserve records and upgrade every process before creating expectations with the expanded reference rules. Active 0.1.1 stores need a claim-preserving cutover that this release has not validated. Release upgrade and rollback instructions

Supplied schema templates are optional when using a compatible custom adapter. Ready-made adapters require their documented schema or supported mappings. Every adapter must preserve the SDK's storage guarantees.

Verification data inventory

RecordFields and purposeWrite and lifecycle
Format metadataSDK record format version (0.3.0 uses payload version 2). Built-in adapters also manage SQL schema version.Introduced by initialization/migration. Preserve with the store.
Expectation (required)Version, immutable PaymentExpectation, state OPEN, CANCELLED or RECEIPT_CLAIMED. Includes payment and tenant IDs, trusted provider, ETB amount, policy, name, account suffix, note and window.Registered by the host. Cancelling or claiming updates state. No SDK expiry deletion.
Attempt and idempotency bindingVersion, canonical fingerprint (payment, provider and identifier), and full VerificationResult. The hashed key includes tenant and idempotency key.Completed observed attempts, including unverified ones, persist with their event. A synchronous INVALID_INPUT on an unbound key has no attempt. No automatic attempt purge.
Receipt and provenance (within result, when available)Normalized provider, transaction ID, status, observed amount, currency, recipient name, last-four account representation, receipt note, transaction time and payment type. Source includes kind, retrieval timestamp, parser version and content hash. The result also includes scope, normalized input, findings and bounded diagnostics.Stored with an observed attempt. Encrypted job admission does not encrypt these later result fields.
Claim (verified only)Hash of provider and official transaction ID, mapped to tenant ID, payment ID and verification ID.Inserted in the same transaction as the expectation state, attempt and event. No public claim delete or expiry.
OutboxEvent key, event type, creation time and result on completion or job ID and serialized error on job failure.Created with the corresponding completion. events(limit?) scans pending records. Call acknowledgeEvent(key) to delete the event. Acknowledgment preserves the claim and attempt.
Durable jobs (optional)Version, job and order scope, provider, state, attempt count, creation/update/next-run times, fingerprint, expectation digest, ciphertext, aliases, lease and expiry, attempt history, event key, and terminal result/error. Supporting records track active jobs, key aliases, terminal replay and queue counters/circuits/policy signature.Admission persists the canonical input and primary key encrypted with AES-256-GCM. Terminal transitions clear ciphertext. Pruning eligible acknowledged jobs frees active capacity and drops attempt history while preserving terminal replay and aliases.

Raw SMS, receipt HTML, balances and full accounts have no default storage field. The result can include the canonical locator, expected and observed notes, the provider transaction ID and receipt recipient name. General record storage is plaintext unless the host adds encryption at rest. A host that uses saved HTML for diagnostics controls those files and their deletion. Normal SDK APIs do not purge results, expectations or claims. Treat any retention change as a migration of the same uniqueness and replay guarantees. Result fields · Security and privacy · Job retention

Transactions and duplicate scope

submit retrieves before opening its short write transaction. It atomically commits expectation state, claim when verified, attempt and outbox. Duplicate protection is shared by all tenants using that one store for a provider transaction, and a payment can have one claim. Independent stores can each claim the same receipt. Idempotency key bindings, by contrast, are tenant-scoped.

For a shared host transaction, call verifier.prepare(submission) before opening it, then pass the actual transaction to the matching scoped adapter and call verifier.complete(prepared, scope) inside. Use Serializable or the documented equivalent. The result is provisional until the outer commit. Roll back on completion failure and retry the entire caller transaction for a retryable conflict. Keep providers, emails and other external effects outside the transaction. Use a repeat-safe host update or event consumer after commit. Persistent checkout and crash recovery

Custom adapter

Implement VerificationStorage with read and transaction(work). Within a transaction, RecordTransaction provides get, unique insert, upsert set, delete and ordered prefix scan(prefix, limit). Return undefined for absent keys. Keep the keys byte-exact. Commit or roll back every write as a unit. Use serializable transactions or equivalent locks with unique inserts and protected reads and scans. Separate clients and processes must coordinate on the same data. Signal known retryable concurrency conflicts with StorageConflict. A callback may repeat. Keep effects outside it. Caller-owned scopes must leave retry, commit and rollback to their owner.

Use the key/scan validators and JSON codecs from @1hubengineering/verifier/storage. The runnable SQLite example uses a custom table, a dedicated connection, serialized access per instance and BEGIN IMMEDIATE to coordinate writers across connections. It reports contention to the caller instead of retrying internally. Use the transaction argument within the callback and keep that scope local. To run the adapter check, install the packages from checkout, save both files side by side and run:

node check-custom-storage.mjs "$(mktemp -d)"

Run the shared contract suite against any adapter before adopting it. The example check covers a subset of that contract and does not implement caller-owned transactions.

View guide source

Direct SQL

Use the direct SQL adapter with a host-owned driver and run its explicit migration before accepting receipts.

Install @1hubengineering/storage-sql@0.3.0 and the selected driver:

SubpathFactoryTested driver
/postgrespostgresStorage(pool)pg@8.23.1
/mysqlmysqlStorage(pool)callback-style mysql2@3.24.6
/sqlitesqliteStorage(database)better-sqlite3@13.2.0, local

Run await storage.migrate() from your deployment's migration process. Pass that storage boundary to the core. Your host owns closing the underlying pool or connection.

For shared transactions use postgresTransaction, mysqlTransaction, or sqliteTransaction on the exact started driver connection. Select Serializable for PostgreSQL/MySQL and keep the enclosing transaction active until completion. See the 0.3.0 migration and transaction examples.

Storage contract · Security and privacy

View guide source

Drizzle

The renamed Drizzle adapter targets Drizzle ORM 1.0.0-rc.5. The archived 0.1.0 adapter requires Drizzle 0.45.4.

Install @1hubengineering/adapter-drizzle@0.3.0, drizzle-orm@1.0.0-rc.5 and the selected driver:

SubpathFactoryTested driver
/postgresdrizzlePostgresStorage(db)pg@8.23.1
/mysqldrizzleMysqlStorage(db)promise mysql2@3.24.6
/sqlitedrizzleSqliteStorage(db)local @libsql/client@0.17.4

Create the host ORM client and pass it to the selected adapter. Run the direct SQL migration before traffic and use one migration owner for those tables. For local SQLite, run migration in a separate process if it uses a different native SQLite implementation.

Call the matching drizzlePostgresTransaction, drizzleMysqlTransaction or drizzleSqliteTransaction inside the ORM callback, passing the callback's actual transaction. The 0.3.0 example shows PostgreSQL Serializable and explains the synchronous SQLite callback limitation.

Storage contract · Security and privacy

View guide source

Prisma

Use a Prisma 7.10.1 client generated with the receipt record model. Your app creates and disconnects the client.

Install @1hubengineering/adapter-prisma@0.3.0, @prisma/client@7.10.1 and the corresponding official driver adapter at 7.10.1: @prisma/adapter-pg, @prisma/adapter-mariadb, or @prisma/adapter-better-sqlite3. Use the Prisma CLI at the same version.

Copy the selected schema/postgres.prisma, schema/mysql.prisma or schema/sqlite.prisma model from the package into your host schema and regenerate. Run the explicit SQL migration before traffic. Then call prismaStorage(hostPrismaClient).

When joining a host write, set the enclosing Prisma interactive transaction to Serializable and pass its callback client to prismaTransaction(tx, { isolationLevel: 'Serializable' }). Do not cast a whole client into a transaction. See the 0.3.0 Prisma transaction example.

Storage contract · Security and privacy

View guide source

Telebirr

Import retrieveTelebirr from @1hubengineering/verifier/providers and register providers: { telebirr: { retrieve: retrieveTelebirr } } on the server. The SDK detects a supported transaction reference, official URL, or SMS and constructs the bounded HTTPS lookup inside the provider transport.

An unexplained HTTP 404 returns UNAVAILABLE with code PROVIDER_HTTP_ERROR. Use parseReceiptHtml with saved synthetic HTML for extraction diagnostics. Receipt claims use the configured retrieval and store. Published provider validation uses synthetic receipts and local transport mocks.

Use Customer Note as the host-owned expected reference. The invoice number and provider transaction ID are separate. Where Telebirr connectivity requires a host-managed SSH tunnel, pass its private Unix socket as telebirrTunnelSocket in the provider retrieval options.

Evidence formats · Deployment · Security and privacy

View guide source

CBE

Install @1hubengineering/provider-cbe@0.3.0 with playwright@1.65.1 and its matching Chromium. Use npx playwright install chromium to install the browser. On the server, pass createCbeProvider({ maxConcurrency: 1 }) as providers.cbe and apply host admission and resource bounds.

The adapter supports legacy receipt HTML and data-backed receipts. Older layouts render offline in sandboxed Chromium. Current layouts use the bounded provider data path, with a browser fallback scoped to the official data endpoint. Run the worker unprivileged, with OS sandboxing and host resource confinement.

Admission exhaustion returns PROVIDER_BUSY, and a renderer deadline returns RECEIPT_RENDER_TIMEOUT. Chromium startup problems return RECEIPT_BROWSER_UNAVAILABLE. Use checkCbeBrowser() to test the browser sandbox with a local fixture. Run checkProviderConnectivity('cbe') from @1hubengineering/verifier/providers when you intend to check TLS to the CBE hosts.

Use the receipt's Reason / Type of service as the expected note. The provider also verifies the official transaction ID, A2A payment and transaction time. See the CBE provider source.

Evidence formats · Deployment · Security and privacy

View guide source

Amount policies

The expected amount comes from the order. Convert canonical decimal text with parseEtbAmount('250.00') to 25,000 minor units. The parser accepts positive ETB with up to two decimal places and rejects whitespace, grouping separators, scientific notation, extra precision and out-of-range amounts. The maximum is Number.MAX_SAFE_INTEGER in minor units. It performs no rounding of input. Compare the transfer principal and use the receipt's observed amount for any financial posting.

Omit amountPolicy when creating the expectation for exact matching, or use { mode: 'exact' }. For tolerance, configure each direction separately on the trusted expectation.

const amountPolicy = {
  mode: 'tolerance',
  underpayment: { type: 'fixed', maxMinor: 100 },
  overpayment: { type: 'percentage', percent: '2.00' },
};

For 250.00 ETB this accepts 249.00 through 255.00 ETB, including both endpoints. An omitted direction allows zero difference. A percentage is decimal text from 0 through 100 with up to two fractional digits. The computed allowance is rounded down to whole minor units. Both directions are capped independently by maxPercent (10% by default). Fixed allowances are nonnegative safe integers and must also fit the cap. Configurations that take the minimum below one minor unit or the maximum above the safe-integer limit are rejected.

comparePaymentAmount(expectedMinor, actualMinor, policy) returns the check without I/O. The backend includes the same check in result.checks, with actual, details.differenceMinor (actual minus expected), both inclusive limits, direction, exactness and whether tolerance was applied. Amounts outside the range fail with AMOUNT_UNDERPAID or AMOUNT_OVERPAID. Do not book the order total as the received amount when using tolerance. Expected-payment fields and result handling

View guide source

Security and privacy

Keep the expected payment on the server. Before accepting or looking up a submission or job, authenticate the caller and authorize the tenant and order. Derive the amount, recipient, currency, provider, note and payment window from trusted records. Accept a bounded locator and a submission key from the customer. Browser recognition is feedback only. Evidence formats · Checkout example

Receipt source and outbound access

The SDK rebuilds a fixed official HTTPS locator from a validated identifier and enforces the registered provider. The built-in Node transport restricts direct DNS answers to public IPv4, checks resolved destinations and the TLS hostname, and refuses redirects and compressed or unexpected responses. These controls protect built-in retrieval against server-side request forgery (SSRF). The optional host-configured Telebirr Unix socket makes the host responsible for providing that trusted route. TLS verification still applies. Preserve egress restrictions and protect the socket. CBE uses a sandboxed browser with a restricted environment and blocks arbitrary browser network requests. Current layout retrieval permits only the provider's scoped data requests. CBE setup · Deployment

Set deadlines, byte limits and host admission bounds. Run CBE as an unprivileged user with its Chromium sandbox and OS confinement for filesystem, CPU, memory and processes. Keep unrelated credentials and files out of the worker. The SDK fails closed when evidence is incomplete or unsupported. A custom provider is part of your trusted backend and must enforce its own transport and authenticity rules. An adapter that fabricates provenance can make supplied fixtures look like observed evidence to the verifier.

Verified TLS connects to the official hostname. The stored content hash identifies the response observed during lookup. It is not a provider signature or evidence of irreversible funds. Account matching is limited to name and suffix, and the receipt describes a point-in-time result. Apply your own reconciliation or release-of-goods policies as appropriate. Result guarantees

Data and business effects

Give backend processes least-privilege access to the shared verifier store. Protect database backups, provider routing, and job encryption secrets via the host's configuration system. Keep secrets out of the browser and source control. Only durable-job input is explicitly encrypted by the SDK. Review the storage inventory for persisted identifiers and receipt fields. Set access and retention policy without deleting keys or claims needed for duplicate protection and replay.

Return a minimal customer response. Log structured codes, stage and internal correlation IDs. Redact SMS, receipt URLs, receipt and account identifiers, notes, idempotency keys and sensitive diagnostics from routine logs. Use sanitized fixtures for parser debugging. Saved receipt HTML is sensitive and should be access-controlled and time-limited if merchant-approved diagnostics require it.

Update orders after the applicable verification commit. Use repeat-safe host transactions and stable fulfillment keys. Keep auth, access checks, updates, notifications and developer diagnostics in the backend. Recovery and messaging · AI integration checklist

View guide source

Testing and deployment

Choose a mode based on what you need to prove. Use synthetic evidence for development and CI. Do not load-test official banking endpoints.

ModeWhat it exercises
Offline comparisonPure comparison of supplied records, without I/O or persistence. Offline example
Mocked integrationTrusted order mapping, storage, claims, retry and application updates with fixtures. Use a real test database when validating transactions. Persistent example
Public synthetic playgroundBrowser-only behavior with mock evidence on GitHub Pages. It is independent of the private VPS. Playground
Private live playgroundProtected, authorized official receipt retrieval against separately trusted order records. The historical VPS report records the tested snapshot and limitations.
Synthetic benchmarkingControlled, synthetic work in a documented environment. Latency and throughput do not describe bank endpoints. Reviewed benchmark report

From a source checkout with Vite+ installed:

vp env install
pnpm install --frozen-lockfile
pnpm setup:browsers
pnpm db:up
pnpm verify
pnpm db:down

The workspace starts disposable PostgreSQL and MySQL test services with Docker Compose, bound to loopback. Tests also use local SQLite files, provider fixtures and browser sandbox checks. For the frozen offline baseline, run pnpm test:reference. For the public site, use pnpm build:site and pnpm docs:smoke. These commands run from the checkout root. Development conventions · Deployment

For your application, cover authorization, missing receipt fields, amount boundaries, duplicate or concurrent claims, dropped responses, provider unavailability and outer rollback. Test that replay preserves the original observation and that retrying a host update cannot repeat fulfillment. Check browser sandbox startup in the actual runtime before enabling CBE. Keep live smoke-test inputs, operator capabilities and benchmark controls behind authorized access. Publish reviewed reports or synthetic demonstrations.

View guide source

Public API

The searchable API index lists every public typed export from the checksum-verified npm 0.3.0 archives. Each declaration links to its release source. Find an export by name or import path. The same records are available via the documentation MCP.

Package or entry pointPublic interface and usage
@1hubengineering/verifierVerifier factory and expectation, submission, result, operation error and storage types. Also exports comparison and money helpers. Expected fields and outcomes · Persistent checkout
@1hubengineering/verifier/comparisonBrowser-safe expectation, comparison, amount policy and ETB APIs. Offline example · Amount policy
@1hubengineering/verifier/inputBrowser-safe detectPaymentInput, input result and error types, and input size limit. Evidence formats
@1hubengineering/verifier/providersTelebirr retrieval, bounded HTTPS, receipt locators, parser, connectivity diagnostics, and provider result and retrieval types. Telebirr · Deployment
@1hubengineering/verifier/storageTransaction and storage contracts, validators, codecs and storage errors. Custom adapter example
@1hubengineering/verifier/jobsDurable verifier factory, policy, job status and lifecycle methods. Recovery and workers
@1hubengineering/storage-sqlSQL storage types and protocol, plus /postgres, /mysql and /sqlite factories and scoped transactions. Direct SQL setup
@1hubengineering/adapter-drizzle/postgres, /mysql and /sqlite storage factories, scoped transactions and schema exports. Drizzle setup
@1hubengineering/adapter-prismaPrisma storage and scoped transaction adapters, with schema snippets in the package. Prisma setup
@1hubengineering/provider-cbeCBE provider factory, configuration and browser diagnostics. CBE setup

The CLI, worker process, Fastify checkout and playground are repository examples. Build your own service using the published interfaces. Version and compatibility

View guide source

AI integration guide

Start with the host application's code and its installed package versions. Record what it already uses for authentication, order authorization, database access, merchant configuration and fulfillment. Reuse those workflows.

Integration checklist

  1. Confirm the installed SDK version, ESM runtime and exact client/engine combination. Select the matching release and adapter. Pin the SDK packages at the same version.
  2. Confirm the store format, migration owner, shared claim boundary and connection ownership. Provision a fresh verifier store for a new install. Preserve existing claims on upgrades.
  3. Configure the official provider from the checkout guide. Use fixture adapters for tests. Check deployment, egress, browser requirements and security.
  4. Authenticate the buyer, authorize the host order, then register its server-owned amount, provider, account name and suffix, expected note and time window. Compare the fields against the API.
  5. Submit the bounded customer locator with the authorized scope and original idempotency key. Treat browser recognition as syntactic feedback.
  6. Cover all results and operation errors. Use original-key recovery after uncertain completion. Use a new key only for a fresh observation after a known result.
  7. Wait for the applicable commit. Keep order changes and fulfillment independently repeat-safe. Follow the checkout example.
  8. Run synthetic checks for authorized success, invalid or mismatched evidence, timeout, replay, duplicate claim and storage failure. Record missing SDK capabilities and unresolved host decisions.

Use real published APIs and examples. Do not invent methods, duplicate the provider verification logic, create parallel wallets or ledgers, treat offline MATCH as backend verification, trust a client-supplied amount, assume duplicate protection across separate stores, or assume a durable job sends notifications.

Skills

Install the setup skill when connecting Payment Verifier to an app. Use the troubleshooting skill for provider, retry or storage problems.

From your application directory, after the skills are available in the repository:

npx skills@1.9.0 add 1hubengineering/payment_verifier --skill payment-verifier-setup --skill payment-verifier-troubleshoot

For a local checkout, pass its absolute path instead of the GitHub slug. Select your client, reload its skills, and invoke $payment-verifier-setup or $payment-verifier-troubleshoot in Codex. npx skills@1.9.0 list shows installed skills.

Connect the documentation server

Clone the Payment Verifier repository, install the pinned Node runtime and workspace dependencies, then generate the 0.3.0 catalog:

vp env install
pnpm install --frozen-lockfile
pnpm docs:prepare
codex mcp add payment-verifier-docs -- node "$PWD/scripts/docs-mcp.mjs"
codex mcp list

Run those commands from the Payment Verifier repository root. If your client cannot find Node, use the absolute path from command -v node. For another MCP client, configure node with the absolute path to scripts/docs-mcp.mjs as its only argument, using stdio transport. GitHub Pages hosts the website, not the MCP process.

Reload the client and ask it to use search_docs for drizzlePostgresTransaction, then get_doc with the returned ID. The response includes the 0.3.0 declaration and source link pinned to the release tag. Use pnpm docs:smoke to test the same connection locally. If the corpus is missing or stale, rerun pnpm docs:prepare and restart the client. The server only reads the prepared catalog and does not use credentials or execute examples.

View guide source