An open API service indexing awesome lists of open source software.

https://github.com/bakissation/fastify-satim

Fastify plugin for SATIM (SATIM-IPAY) payments โ€” typed decorator, multi-tenant, built-in routes. CIB & Edahabia.
https://github.com/bakissation/fastify-satim

algeria cib edahabia fastify fastify-plugin fintech multi-tenant npm-package payment-gateway payments satim satim-ipay typescript

Last synced: about 1 month ago
JSON representation

Fastify plugin for SATIM (SATIM-IPAY) payments โ€” typed decorator, multi-tenant, built-in routes. CIB & Edahabia.

Awesome Lists containing this project

README

          

# @bakissation/fastify-satim

A **Fastify plugin** for the [SATIM (SATIM-IPAY)](https://github.com/bakissation/satim-ts) payment gateway โ€” drop SATIM **CIB & Edahabia** payments into any Fastify app with a typed `fastify.satim` decorator, optional built-in routes, schema validation, and multi-tenant support. Works with **Fastify v4 and v5**.

[![npm](https://img.shields.io/npm/v/@bakissation/fastify-satim?label=npm&color=cb3837)](https://www.npmjs.com/package/@bakissation/fastify-satim)
[![CI](https://github.com/bakissation/fastify-satim/actions/workflows/ci.yml/badge.svg)](https://github.com/bakissation/fastify-satim/actions/workflows/ci.yml)
[![license](https://img.shields.io/npm/l/@bakissation/fastify-satim?color=blue)](./LICENSE)

- ๐Ÿงฉ **Typed decorator** โ€” `fastify.satim` exposes the full SATIM client (`register`, `getOrderStatus`, `confirm`, `refund`) across all scopes.
- ๐Ÿข **Multi-tenant** โ€” resolve credentials per request via `getClient(request)`, or stay single-tenant with env vars / a config object / a pre-built client.
- ๐Ÿ›ฃ๏ธ **Built-in routes (opt-in)** โ€” `/register`, `/status`, `/confirm`, `/refund` with JSON-schema validation and per-route hooks โ€” or wire your own.
- ๐Ÿ”’ **Secure by default** โ€” centralized error mapping that never leaks credentials, POST-only by default, no secret logging.

> ๐Ÿ“– **[Read the case study โ†’](https://berkati.xyz/case-studies/fastify-satim-plugin/)** โ€” how this plugin cuts SATIM integration from hundreds of lines of boilerplate per project to a single `register()` call.

## Install

```bash
npm install @bakissation/fastify-satim
```

Requires **Node.js โ‰ฅ 18** and **Fastify v4 or v5**. The core SDK [`@bakissation/satim`](https://github.com/bakissation/satim-ts) is included.

## Quick start

```typescript
import Fastify from 'fastify';
import fastifySatim, { interpretOrderStatus } from '@bakissation/fastify-satim';

const fastify = Fastify();
await fastify.register(fastifySatim, { fromEnv: true });

fastify.post('/checkout', async (request, reply) => {
const order = await fastify.satim.register({
orderNumber: 'ORD001',
amount: 5000, // 5000 DZD
returnUrl: 'https://yoursite.com/payment/success',
udf1: 'INV001',
});
if (order.isSuccessful()) return { redirectUrl: order.formUrl };
return reply.status(400).send({ error: 'Failed to create order' });
});

fastify.post('/payment/callback', async (request) => {
const { orderId } = request.body as { orderId: string };
const status = await fastify.satim.getOrderStatus(orderId);
return status.isPaid() ? { status: 'paid' } : { status: interpretOrderStatus(status.orderStatus) };
});

await fastify.listen({ port: 3000 });
```

There are four ways to configure the client (multi-tenant, env, object, pre-built) โ†’ **[docs/configuration](./docs/configuration.md)**.

## Documentation

Full docs live in **[`docs/`](./docs/)**:

| | |
|---|---|
| [Overview & concepts](./docs/overview.md) | What the plugin is, when to use it vs the raw SDK, design notes |
| [Getting started](./docs/getting-started.md) | Install, register, first payment, environments |
| [Configuration](./docs/configuration.md) | The four config modes (multi-tenant, env, object, client) |
| [Built-in routes](./docs/routes.md) | `/register` ยท `/status` ยท `/confirm` ยท `/refund` โ€” paths, hooks, bodies |
| [Security](./docs/security.md) | Auth, CSRF, error mapping, best practices |
| [Architecture](./docs/architecture.md) | Module map, plugin lifecycle, routes, error handling |

For the SATIM gateway API, environments, and certification, see the [core SDK docs](https://github.com/bakissation/satim-ts/tree/main/docs).

## Contributing

Issues and PRs welcome โ€” read [CONTRIBUTING.md](./CONTRIBUTING.md) and the [Code of Conduct](./CODE_OF_CONDUCT.md). Releases are automated from [Conventional Commits](https://www.conventionalcommits.org/) via semantic-release; **don't bump the version or edit the changelog by hand**.

## Credits

Built and maintained by **Abdelbaki Berkati** โ€” [berkati.xyz](https://berkati.xyz) ยท [@bakissation](https://github.com/bakissation).
๐Ÿ“– [Read the case study โ†’](https://berkati.xyz/case-studies/fastify-satim-plugin/)

## License

[MIT](./LICENSE)