better-auth-paystack 3.5.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es-ES.md +52 -919
- package/README.fr-FR.md +114 -0
- package/README.md +53 -918
- package/dist/client.d.mts +17 -16
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +3 -4
- package/dist/client.mjs.map +1 -1
- package/dist/{index-BhxgbWeq.d.mts → index-DE-0F3y6.d.mts} +9 -28
- package/dist/index-DE-0F3y6.d.mts.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +65 -84
- package/dist/index.mjs.map +1 -1
- package/dist/{version-BlEaud3g.mjs → version-BW3EZXTR.mjs} +4 -6
- package/dist/{version-BlEaud3g.mjs.map → version-BW3EZXTR.mjs.map} +1 -1
- package/package.json +20 -23
- package/skills/better-auth-paystack-setup/SKILL.md +15 -138
- package/skills/paystack-billing-flows/SKILL.md +18 -145
- package/skills/paystack-catalog-limits/SKILL.md +16 -176
- package/skills/paystack-client-api/SKILL.md +22 -111
- package/skills/paystack-local-subscriptions/SKILL.md +15 -90
- package/skills/paystack-organization-billing/SKILL.md +15 -153
- package/skills/paystack-schema-migrations/SKILL.md +18 -84
- package/skills/paystack-tanstack-start/SKILL.md +21 -163
- package/skills/paystack-testing-fixtures/SKILL.md +14 -91
- package/skills/paystack-webhooks-events/SKILL.md +18 -97
- package/dist/index-BhxgbWeq.d.mts.map +0 -1
package/README.fr-FR.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
[English](README.md) · [Español](README.es-ES.md) · [Français](README.fr-FR.md)
|
|
2
|
+
|
|
3
|
+
# Better Auth Paystack
|
|
4
|
+
|
|
5
|
+
Acceptez des paiements ponctuels et gérez les abonnements d’utilisateurs ou d’organisations avec Paystack et Better Auth. Utilisez les offres récurrentes de Paystack ou gérez les renouvellements, les places et le prorata dans votre application.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add better-auth better-auth-paystack @alexasomba/paystack-node
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Utilisez Node.js 22+, Better Auth `>=1.4.22 <2` et `@alexasomba/paystack-node` `^1.12.1`.
|
|
14
|
+
|
|
15
|
+
## Configurer Better Auth
|
|
16
|
+
|
|
17
|
+
Placez `PAYSTACK_SECRET_KEY` dans l’environnement du serveur. Enregistrez le plugin avec votre adaptateur de base de données et montez le gestionnaire Better Auth.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createPaystack } from "@alexasomba/paystack-node";
|
|
21
|
+
import { betterAuth } from "better-auth";
|
|
22
|
+
import { paystack } from "better-auth-paystack";
|
|
23
|
+
|
|
24
|
+
const secretKey = process.env.PAYSTACK_SECRET_KEY!;
|
|
25
|
+
|
|
26
|
+
export const auth = betterAuth({
|
|
27
|
+
plugins: [
|
|
28
|
+
paystack({
|
|
29
|
+
secretKey,
|
|
30
|
+
paystackClient: createPaystack({ secretKey }),
|
|
31
|
+
products: {
|
|
32
|
+
products: [{ name: "credits_50", price: 200_000, currency: "NGN" }],
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Générez et appliquez le schéma de votre adaptateur avant d’accepter des paiements. Consultez le [guide de la CLI Better Auth](https://www.better-auth.com/docs/concepts/cli) et le [guide de migration](skills/paystack-schema-migrations/SKILL.md) pour une installation existante.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { paystackClient } from "better-auth-paystack/client";
|
|
43
|
+
import { createAuthClient } from "better-auth/client";
|
|
44
|
+
|
|
45
|
+
export const authClient = createAuthClient({ plugins: [paystackClient()] });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Encaisser un paiement
|
|
49
|
+
|
|
50
|
+
Lancez le paiement dans une session authentifiée. Le serveur détermine le prix en unités monétaires mineures.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const { data, error } = await authClient.transaction.initialize({
|
|
54
|
+
product: "credits_50",
|
|
55
|
+
callbackURL: new URL("/billing/return", window.location.origin).href,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (error) {
|
|
59
|
+
throw new Error(error.message ?? "Could not start Paystack checkout");
|
|
60
|
+
}
|
|
61
|
+
if (data?.kind === "checkout") {
|
|
62
|
+
window.location.assign(data.url);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Au retour, appelez `authClient.transaction.verify({ reference })`. Livrez l’achat côté serveur lorsque le paiement confirmé correspond à la commande, au montant, à la devise et au titulaire. Utilisez la référence comme clé d’idempotence.
|
|
67
|
+
|
|
68
|
+
Enregistrez `https://your-domain.example/api/auth/paystack/webhook` dans Paystack pour le chemin Better Auth par défaut. Le plugin vérifie `x-paystack-signature` avec `PAYSTACK_SECRET_KEY`.
|
|
69
|
+
|
|
70
|
+
## Abonnements et facturation des organisations
|
|
71
|
+
|
|
72
|
+
- Activez `subscription.enabled` et configurez `subscription.plans`. Utilisez `planCode` pour les offres gérées par Paystack. Pour les offres locales, configurez le montant, la devise et l’intervalle et omettez `planCode`. [Parcours de facturation](skills/paystack-billing-flows/SKILL.md) · [Renouvellements locaux](skills/paystack-local-subscriptions/SKILL.md)
|
|
73
|
+
- Activez le plugin d’organisation et `organization.enabled` pour facturer une organisation. Par défaut, les propriétaires et les administrateurs peuvent gérer la facturation. [Facturation des organisations](skills/paystack-organization-billing/SKILL.md)
|
|
74
|
+
- Configurez le catalogue, les essais et les limites côté serveur. [Catalogue et limites](skills/paystack-catalog-limits/SKILL.md) · [API cliente](skills/paystack-client-api/SKILL.md) · [Webhooks](skills/paystack-webhooks-events/SKILL.md)
|
|
75
|
+
|
|
76
|
+
## Starters autonomes
|
|
77
|
+
|
|
78
|
+
Créez un projet avec npm. TanStack Start est le choix par défaut.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npm create better-auth-paystack@latest my-app
|
|
82
|
+
npm create better-auth-paystack@latest my-next-app -- --template nextjs
|
|
83
|
+
npm create better-auth-paystack@latest my-worker -- --template hono
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Configurez l’environnement selon le README généré, puis exécutez `pnpm install --frozen-lockfile` et `pnpm dev`.
|
|
87
|
+
|
|
88
|
+
Téléchargez le starter TanStack autonome dans la prochaine version. L’archive contient le fichier de verrouillage et un modèle d’environnement. Extrayez-la, configurez l’environnement, puis exécutez `pnpm install --frozen-lockfile` et `pnpm dev`. [GitHub Releases](https://github.com/alexasomba/better-auth-paystack/releases)
|
|
89
|
+
|
|
90
|
+
Depuis le dépôt, exportez la démo avec le paquet publié ou une archive locale créée via `vp pack` puis `pnpm pack`.
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
pnpm starter:export tanstack /tmp/paystack-starter
|
|
94
|
+
pnpm starter:export tanstack /tmp/paystack-local --tarball /path/to/better-auth-paystack.tgz
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Paystack fournit également des archives Next.js et Hono. Utilisez `nextjs` ou `hono` comme nom de démo pour les exporter.
|
|
98
|
+
|
|
99
|
+
## Démo et compétences pour agents
|
|
100
|
+
|
|
101
|
+
La [démo TanStack Start](examples/tanstack/README.md) présente la configuration, les écrans de facturation et les commandes de test.
|
|
102
|
+
|
|
103
|
+
Le paquet npm inclut des [compétences pour agents](skills). Avec pnpm 12.11 ou une version ultérieure, exécutez `pnpm approve` après l’installation et approuvez les compétences proposées. TanStack Intent peut répertorier et charger les mêmes fichiers.
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
pnpm dlx @tanstack/intent list
|
|
107
|
+
pnpm dlx @tanstack/intent load better-auth-paystack#better-auth-paystack-setup
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Développement
|
|
111
|
+
|
|
112
|
+
Depuis la racine du dépôt, exécutez `vp install`, `vp check`, `vp test` et `vp pack`. Consultez le [guide de test](skills/paystack-testing-fixtures/SKILL.md) pour valider la démo et le paquet.
|
|
113
|
+
|
|
114
|
+
[Licence MIT](LICENSE)
|