Demo starter for the NPM package @creofam/verifier, a TypeScript SDK for payment receipt verification, built on top of the open-source Verifier API: https://github.com/Vixen878/verifier-api
NPM: https://www.npmjs.com/package/@creofam/verifier
This starter shows how to integrate provider-side receipt verification in a modern Next.js app with strict type safety. Users select a package, enter a provider reference number, and the server verifies it against the Verifier API SDK, then credits tokens atomically on success.
Supported providers:
- Telebirr
- Commercial Bank of Ethiopia (CBE)
- Bank of Abyssinia
- Next.js 15 (App Router) + Tailwind CSS v4
- tRPC v11 with end-to-end types
- Prisma ORM (MySQL) with
User,Receipt, andUserConfigmodels - NextAuth with a Prisma adapter
@creofam/verifierSDK integration- Developer-friendly logs in
purchase.verifyAndCreditfor tracing verification flows - Safe verification rules:
- Duplicate receipt guard
- Package price amount check
- Telebirr masked account matching (prefix/suffix)
- CBE & Abyssinia suffix-based verification with amount match (name mismatches tolerated)
- Atomic crediting of tokens with receipt persistence
- A working reference implementation that verifies receipts and credits tokens.
- Strong TypeScript typing and zod validation at the API boundary.
- Realistic provider handling: masking, suffix lookups, and operational logs.
- A clean foundation to build your own product around payment verification.
This is a demo; it’s not a complete product. You should harden error handling, and observability.
- Node.js 18+
- PNPM
- MySQL database (set via
DATABASE_URL) - OAuth app credentials for NextAuth
- Clone this repository
git clone https://github.com/Vixen878/verifier-starter-nextjs.git- Install dependencies
pnpm install- Configure environment variables (see “Environment” below) and create the schema
pnpm db:push- Start the dev server
pnpm devOptional: open Prisma Studio to inspect data
pnpm db:studioServer-side (required unless noted):
AUTH_SECRET— required in production, optional in developmentAUTH_DISCORD_ID— Discord OAuth client IDAUTH_DISCORD_SECRET— Discord OAuth client secretDATABASE_URL— MySQL connection stringVERIFIER_API_KEY— API key for@creofam/verifierSDKPLATFORM_OWNER_FULLNAME— fallback name for Telebirr receiver validationCBE_ACCOUNT_SUFFIX— 8-digit suffix used by CBE verificationABYSSINIA_ACCOUNT_SUFFIX— 5-digit suffix used by Abyssinia verification
Client-side (validated at build; used as UI fallbacks):
NEXT_PUBLIC_TELEBIRR_NUMBER— Telebirr number (digits, e.g.,2519xxxxxxxx)NEXT_PUBLIC_CBE_ACCOUNT_NUMBER— CBE account number (e.g., 13 digits)NEXT_PUBLIC_ABYSSINIA_ACCOUNT_NUMBER— Abyssinia account number
Notes:
- Environment values act as fallbacks. When present, database
UserConfigoverrides them. - To bypass build-time env validation temporarily, set
SKIP_ENV_VALIDATION=1(not recommended long-term).
- Verification mutation:
src/server/api/routers/purchase.ts(verifyAndCredit) - Public verification router (raw lookups):
src/server/api/routers/verify.ts
High-level flow in purchase.verifyAndCredit:
- Prevent duplicates: refuse previously used
(provider, reference)pairs. - Resolve configuration in order:
input.config → user’s DB config → environment. - Verify via SDK:
- Telebirr:
verifyTelebirr({ reference }) - CBE:
verifyCBE({ reference, accountSuffix }) - Abyssinia:
verifyAbyssinia({ reference, suffix })
- Telebirr:
- Validate amount equals the selected package price.
- Destination validation:
- Telebirr: enforce normalized receiver name equals expected owner; masked receiver account must match user’s configured number (prefix/suffix).
- CBE & Abyssinia: rely on suffix + amount.
- On success: atomically write
Receiptand increment usertokens.
The demo uses three packages (as of now):
- 50 ETB → 50 tokens
- 200 ETB → 200 tokens
- 500 ETB → 500 tokens
These are configured in the server (PACKAGES) and used to validate receipts and grant tokens.
The demo persists per-user payment configuration in the UserConfig table:
platformOwnerFullNametelebirrNumbercbeAccountNumber,cbeAccountSuffixabyssiniaAccountNumber,abyssiniaAccountSuffix
Verification emits structured console logs for tracing:
- Start, amount checks, name checks
- Provider requests and parsed responses
- Masked account matching (with a
matchesflag) - Transaction commit and success
- Duplicate/race conditions (
P2002) and reasoned failures
Run the app and inspect the terminal output during purchases to understand where a verification fails.
- Add new providers in
@creofam/verifierand implement a branch inpurchase.ts. - Replace Discord auth or add more NextAuth providers.
- Add rate limits and audit trails if you expect high volume.
- Verifier API (server): https://github.com/Vixen878/verifier-api
- SDK (client): https://www.npmjs.com/package/@creofam/verifier
- T3 Stack: Next.js, tRPC, Prisma, NextAuth
This starter is provided as a demo reference. Review and adapt the verification policy, authentication, and data model for your own production needs.