Logo Lanfrica

Neurotech-HQ/snippe-js-sdk

Domain:

digital infrastructure

Record type:

software
Creator:
Neu
Host:
Official JavaScript / TypeScript SDK for Snippe — the Tanzania payment platform (mobile money, cards, QR, and payouts). # @snippe/sdk Official JavaScript / TypeScript SDK for Snippe — the Tanzania payment platform (mobile money, cards, and payouts). - API version: `2026-01-25` - Works in Node.js 18+ (uses built-in `fetch`) - Fully typed, ESM + CJS, zero runtime dependencies > **Migrating from v0.2.x?** The v1.0 release is breaking — channel-namespaced methods (`payments.mobile.create` instead of `payments.create({ payment_type: "mobile" })`) and camelCase fields throughout. See MIGRATION.md. ## Install ```bash npm install @snippe/sdk ``` ## Charge a customer in 5 minutes The full happy path for mobile money — the most common flow. ### 1. Initialise the client ```ts import { Snippe } from "@snippe/sdk"; const snippe = new Snippe({ apiKey: process.env.SNIPPE_API_KEY!, // snp_... webhookUrl: "example.com", }); ``` ### 2. Create the payment ```ts const payment = await snippe.payments.mobile.create({ amount: 500, // TZS, integer (minimum 500) phoneNumber: "0781000000", // any TZ format works — auto-normalised customer: { firstName: "Jane", lastName: "Doe", email: "jane@example.com", }, }); console.log(payment.reference, payment.status); // "9015c155-…", "pending" ``` The customer's phone now has a USSD prompt. They enter their PIN. ### 3. Learn the result — webhooks Listen for `payment.completed` / `payment.failed` events at `webhookUrl`. The SDK ships `verifyWebhook` for HMAC verification — see the Webhooks section. If you genuinely can't receive webhooks (no public URL, scheduled reconciliation job), see the polling example for the `payments.get`-in-a-loop pattern. The SDK auto-generates a short `Idempotency-Key` (≤30 chars) for every `POST`. Pass your own via the request options: ```ts await snippe.payments.mobile.create(input, { idempotencyKey: "ord-12345-t1" }); ``` ## Resources ### Payments Each payment channel has its own typed method — no string discriminators: ```ts await snippe.payments.mobile.create({ amount, phoneNumber, customer …