A typed Node.js and TypeScript client for the [PayTech](
paytech.sn) payment gateway used across Senegal, Cote d'Ivoire, Mali, and Benin. It covers checkout requests, IPN signature verification, transfers, refunds, and SMS, with zero runtime dependencies.
# paytech-sn
A typed Node.js and TypeScript client for the PayTech payment gateway used across Senegal, Cote d'Ivoire, Mali, and Benin. It covers checkout requests, IPN signature verification, transfers, refunds, and SMS, with zero runtime dependencies.
Built around the official PayTech API:
docs.intech.sn
The SDK itself is framework-agnostic: it is plain TypeScript built on the native `fetch` and `node:crypto` APIs, with no dependency on Next.js or any other framework. It works the same way in a Next.js Route Handler, an Express, Fastify, or NestJS server, a serverless function, or a bare Node.js script. The Next.js example below is one usage pattern, not a requirement.
## Features
- Framework-agnostic: works in Next.js, Express, Fastify, NestJS, or a plain Node.js script
- Checkout requests with optional autofill for a single payment method
- IPN verification for both payment and transfer events, each with its correct HMAC formula
- Constant-time signature comparison to avoid timing attacks
- Strict input validation that fails fast on bad parameters instead of a confusing API error
- Per-request timeout with `AbortController`
- Fully typed requests and responses, published as dual ESM and CommonJS with bundled `.d.ts` files
## Installation
```bash
npm install paytech-sn
```
Requires Node.js 20 or later (the test toolchain requires it; the SDK runtime itself only needs the global `fetch` and `crypto` APIs available since Node 18).
## Quick start
```ts
import { PaytechService } from "paytech-sn";
const paytech = new PaytechService({
apiKey: process.env.PAYTECH_API_KEY!,
apiSecret: process.env.PAYTECH_API_SECRET!,
env: "test", // defaults to "test"; set to "prod" explicitly when you are ready
});
const payment = await paytech.requestPayment({
itemName: "Premium plan",
itemPrice: 5000,
refCommand: "ORDER-1234",
commandName: "Subscription renewal",
ipnUrl: "
example.com",
successUrl: "
example.com …