@alexasomba/better-auth-paystack 1.0.0 → 1.1.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.md +101 -39
- package/dist/client.d.mts +5 -1
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +3 -0
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +48 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +742 -321
- package/dist/index.mjs.map +1 -1
- package/dist/{types-Du5udJ7X.d.mts → types-BVSLYZGY.d.mts} +94 -29
- package/dist/types-BVSLYZGY.d.mts.map +1 -0
- package/package.json +10 -9
- package/dist/types-Du5udJ7X.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -167,6 +167,21 @@ The plugin natively checks the `teams` limit if using the Better Auth Organizati
|
|
|
167
167
|
|
|
168
168
|
---
|
|
169
169
|
|
|
170
|
+
## Currency Support
|
|
171
|
+
|
|
172
|
+
The plugin supports the following currencies with automatic minimum transaction amount validation:
|
|
173
|
+
|
|
174
|
+
| Currency | Name | Minimum Amount |
|
|
175
|
+
| -------- | ---------------------- | -------------- |
|
|
176
|
+
| **NGN** | Nigerian Naira | ₦50.00 |
|
|
177
|
+
| **GHS** | Ghanaian Cedi | ₵0.10 |
|
|
178
|
+
| **ZAR** | South African Rand | R1.00 |
|
|
179
|
+
| **KES** | Kenyan Shilling | KSh 3.00 |
|
|
180
|
+
| **USD** | United States Dollar | $2.00 |
|
|
181
|
+
| **XOF** | West African CFA Franc | CFA 100 |
|
|
182
|
+
|
|
183
|
+
Transactions below these thresholds will be rejected with a `BAD_REQUEST` error.
|
|
184
|
+
|
|
170
185
|
## Advanced Usage
|
|
171
186
|
|
|
172
187
|
### Organization Billing
|
|
@@ -338,6 +353,9 @@ type listSubscriptions = {
|
|
|
338
353
|
|
|
339
354
|
Cancel or restore a subscription.
|
|
340
355
|
|
|
356
|
+
- **Cancel**: Sets `cancelAtPeriodEnd: true`. The subscription remains `active` until the end of the current billing period, after which it moves to `canceled`.
|
|
357
|
+
- **Restore**: Reactivates a subscription that is scheduled to cancel.
|
|
358
|
+
|
|
341
359
|
```ts
|
|
342
360
|
type cancelSubscription = {
|
|
343
361
|
/**
|
|
@@ -358,47 +376,67 @@ The plugin extends your database with the following fields and tables.
|
|
|
358
376
|
|
|
359
377
|
### `user`
|
|
360
378
|
|
|
361
|
-
| Field | Type | Description |
|
|
362
|
-
| :--------------------- | :------- | :-------------------------------------------- |
|
|
363
|
-
| `paystackCustomerCode` | `string` | The unique customer identifier from Paystack. |
|
|
379
|
+
| Field | Type | Required | Description |
|
|
380
|
+
| :--------------------- | :------- | :------- | :-------------------------------------------- |
|
|
381
|
+
| `paystackCustomerCode` | `string` | No | The unique customer identifier from Paystack. |
|
|
364
382
|
|
|
365
383
|
### `organization`
|
|
366
384
|
|
|
367
|
-
| Field | Type | Description |
|
|
368
|
-
| :--------------------- | :------- | :----------------------------------------------------------------------------------------- |
|
|
369
|
-
| `paystackCustomerCode` | `string` | The unique customer identifier for the organization. |
|
|
370
|
-
| `email` | `string` | The billing email for the organization. fallsback to organization owner's email if absent. |
|
|
385
|
+
| Field | Type | Required | Description |
|
|
386
|
+
| :--------------------- | :------- | :------- | :----------------------------------------------------------------------------------------- |
|
|
387
|
+
| `paystackCustomerCode` | `string` | No | The unique customer identifier for the organization. |
|
|
388
|
+
| `email` | `string` | No | The billing email for the organization. fallsback to organization owner's email if absent. |
|
|
371
389
|
|
|
372
390
|
### `subscription`
|
|
373
391
|
|
|
374
|
-
| Field | Type | Description
|
|
375
|
-
| :----------------------------- | :-------- |
|
|
376
|
-
| `plan` | `string` | Lowercased name of the active plan.
|
|
377
|
-
| `referenceId` | `string` | Associated User ID or Organization ID.
|
|
378
|
-
| `paystackCustomerCode` | `string` | The Paystack customer code for this subscription.
|
|
379
|
-
| `paystackSubscriptionCode` | `string` | The unique code for the subscription (e.g., `SUB_...`).
|
|
380
|
-
| `paystackTransactionReference` | `string` | The reference of the transaction that started the subscription.
|
|
381
|
-
| `
|
|
382
|
-
| `
|
|
383
|
-
| `
|
|
384
|
-
| `
|
|
385
|
-
| `
|
|
386
|
-
| `
|
|
387
|
-
| `
|
|
392
|
+
| Field | Type | Required | Description |
|
|
393
|
+
| :----------------------------- | :-------- | :------- | :------------------------------------------------------------------- |
|
|
394
|
+
| `plan` | `string` | Yes | Lowercased name of the active plan. |
|
|
395
|
+
| `referenceId` | `string` | Yes | Associated User ID or Organization ID. |
|
|
396
|
+
| `paystackCustomerCode` | `string` | No | The Paystack customer code for this subscription. |
|
|
397
|
+
| `paystackSubscriptionCode` | `string` | No | The unique code for the subscription (e.g., `SUB_...` or `LOC_...`). |
|
|
398
|
+
| `paystackTransactionReference` | `string` | No | The reference of the transaction that started the subscription. |
|
|
399
|
+
| `paystackAuthorizationCode` | `string` | No | Stored card authorization code for recurring charges (local plans). |
|
|
400
|
+
| `status` | `string` | Yes | `active`, `trialing`, `canceled`, `incomplete`. |
|
|
401
|
+
| `periodStart` | `Date` | No | Start date of the current billing period. |
|
|
402
|
+
| `periodEnd` | `Date` | No | End date of the current billing period. |
|
|
403
|
+
| `trialStart` | `Date` | No | Start date of the trial period. |
|
|
404
|
+
| `trialEnd` | `Date` | No | End date of the trial period. |
|
|
405
|
+
| `cancelAtPeriodEnd` | `boolean` | No | Whether to cancel at the end of the current period. |
|
|
406
|
+
| `seats` | `number` | No | Purchased seat count for team billing. |
|
|
388
407
|
|
|
389
408
|
### `paystackTransaction`
|
|
390
409
|
|
|
391
|
-
| Field | Type | Description |
|
|
392
|
-
| :------------ | :------- | :------------------------------------------------ |
|
|
393
|
-
| `reference` | `string` | Unique transaction reference. |
|
|
394
|
-
| `referenceId` | `string` | Associated User ID or Organization ID. |
|
|
395
|
-
| `userId` | `string` | The ID of the user who initiated the transaction. |
|
|
396
|
-
| `amount` | `number` | Transaction amount in smallest currency unit. |
|
|
397
|
-
| `currency` | `string` | Currency code (e.g., "NGN"). |
|
|
398
|
-
| `status` | `string` | `success`, `pending`, `failed`, `abandoned`. |
|
|
399
|
-
| `plan` | `string` | Name of the plan associated with the transaction. |
|
|
400
|
-
| `
|
|
401
|
-
| `
|
|
410
|
+
| Field | Type | Required | Description |
|
|
411
|
+
| :------------ | :------- | :------- | :------------------------------------------------ |
|
|
412
|
+
| `reference` | `string` | Yes | Unique transaction reference. |
|
|
413
|
+
| `referenceId` | `string` | Yes | Associated User ID or Organization ID. |
|
|
414
|
+
| `userId` | `string` | Yes | The ID of the user who initiated the transaction. |
|
|
415
|
+
| `amount` | `number` | Yes | Transaction amount in smallest currency unit. |
|
|
416
|
+
| `currency` | `string` | Yes | Currency code (e.g., "NGN"). |
|
|
417
|
+
| `status` | `string` | Yes | `success`, `pending`, `failed`, `abandoned`. |
|
|
418
|
+
| `plan` | `string` | No | Name of the plan associated with the transaction. |
|
|
419
|
+
| `product` | `string` | No | Name of the product associated with the transaction. |
|
|
420
|
+
| `metadata` | `string` | No | JSON string of extra transaction metadata. |
|
|
421
|
+
| `paystackId` | `string` | No | The internal Paystack ID for the transaction. |
|
|
422
|
+
| `createdAt` | `Date` | Yes | Transaction creation timestamp. |
|
|
423
|
+
| `updatedAt` | `Date` | Yes | Transaction last update timestamp. |
|
|
424
|
+
|
|
425
|
+
### `paystackProduct`
|
|
426
|
+
|
|
427
|
+
| Field | Type | Required | Description |
|
|
428
|
+
| :------------ | :-------- | :------- | :------------------------------------------------ |
|
|
429
|
+
| `name` | `string` | Yes | Product name. |
|
|
430
|
+
| `description` | `string` | No | Product description. |
|
|
431
|
+
| `price` | `number` | Yes | Price in smallest currency unit. |
|
|
432
|
+
| `currency` | `string` | Yes | Currency code (e.g., "NGN"). |
|
|
433
|
+
| `quantity` | `number` | No | Available stock quantity. |
|
|
434
|
+
| `unlimited` | `boolean` | No | Whether the product has unlimited stock. |
|
|
435
|
+
| `paystackId` | `string` | No | The internal Paystack Product ID. |
|
|
436
|
+
| `slug` | `string` | Yes | Unique slug for the product. |
|
|
437
|
+
| `metadata` | `string` | No | JSON string of extra product metadata. |
|
|
438
|
+
| `createdAt` | `Date` | Yes | Product creation timestamp. |
|
|
439
|
+
| `updatedAt` | `Date` | Yes | Product last update timestamp. |
|
|
402
440
|
|
|
403
441
|
---
|
|
404
442
|
|
|
@@ -408,7 +446,31 @@ The plugin extends your database with the following fields and tables.
|
|
|
408
446
|
- **Email Verification**: Use `requireEmailVerification: true` to prevent unverified checkouts.
|
|
409
447
|
- **Redirect Failures**: Check your browser console; Paystack often returns 429 errors if you're hitting the test API too frequently.
|
|
410
448
|
- **Reference mismatches**: Ensure `referenceId` is passed correctly for Organization billing.
|
|
411
|
-
- **Authorization Denied**: Verify your `authorizeReference` logic is correctly checking user roles or organization memberships.
|
|
449
|
+
- **Authorization Denied**: Verify your `authorizeReference` logic is correctly checking user roles or organization memberships. Unauthorized attempts to verify transactions now return a `401 Unauthorized` response to prevent data leaks.
|
|
450
|
+
|
|
451
|
+
### Database Indexing
|
|
452
|
+
|
|
453
|
+
The plugin's schema definition includes recommended indexes and uniqueness constraints for performance. When you run `npx better-auth migrate`, these will be automatically applied to your database.
|
|
454
|
+
|
|
455
|
+
The following fields are indexed:
|
|
456
|
+
- **`paystackTransaction`**: `reference` (unique), `userId`, `referenceId`.
|
|
457
|
+
- **`subscription`**: `paystackSubscriptionCode` (unique), `referenceId`, `paystackTransactionReference`, `paystackCustomerCode`, `plan`.
|
|
458
|
+
- **`user` & `organization`**: `paystackCustomerCode`.
|
|
459
|
+
- **`paystackProduct`**: `slug` (unique), `paystackId` (unique).
|
|
460
|
+
|
|
461
|
+
### Syncing Products
|
|
462
|
+
|
|
463
|
+
The plugin provides two ways to keep your product inventory in sync with Paystack:
|
|
464
|
+
|
|
465
|
+
#### 1. Automated Inventory Sync (New)
|
|
466
|
+
Whenever a successful one-time payment is made (via webhook or manual verification), the plugin automatically calls **`syncProductQuantityFromPaystack`**. This fetches the real-time remaining quantity from the Paystack API and updates your local database record, ensuring your inventory is always accurate.
|
|
467
|
+
|
|
468
|
+
#### 2. Manual Bulk Sync
|
|
469
|
+
You can synchronize all products with your local database using the `/paystack/sync-products` endpoint.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
POST /api/auth/paystack/sync-products
|
|
473
|
+
```
|
|
412
474
|
|
|
413
475
|
---
|
|
414
476
|
|
|
@@ -440,14 +502,14 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
440
502
|
|
|
441
503
|
Future features planned for upcoming versions:
|
|
442
504
|
|
|
443
|
-
### v1.1.0 - Manual Recurring Subscriptions
|
|
505
|
+
### v1.1.0 - Manual Recurring Subscriptions (Available Now)
|
|
444
506
|
|
|
445
|
-
- [
|
|
446
|
-
- [
|
|
447
|
-
- [ ] **
|
|
448
|
-
- [ ] **Renewal Scheduler Integration**: Documentation for integrating with Cloudflare Workers Cron, Vercel Cron, etc.
|
|
507
|
+
- [x] **Stored Authorization Codes**: Securely store Paystack authorization codes from verified transactions.
|
|
508
|
+
- [x] **Charge Authorization Endpoint**: Server-side endpoint (`/charge-recurring`) to charge stored cards for renewals.
|
|
509
|
+
- [ ] **Card Management UI**: Let users view/delete saved payment methods (masked card data only) - _Upcoming_
|
|
510
|
+
- [ ] **Renewal Scheduler Integration**: Documentation for integrating with Cloudflare Workers Cron, Vercel Cron, etc. - _Upcoming_
|
|
449
511
|
|
|
450
|
-
> **Note**: For
|
|
512
|
+
> **Note**: For local-managed subscriptions (no `planCode`), the plugin now automatically captures and stores the `authorization_code`. You can trigger renewals using `authClient.paystack.chargeRecurringSubscription({ subscriptionId })`.
|
|
451
513
|
|
|
452
514
|
### Future Considerations
|
|
453
515
|
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as PaystackTransaction, s as Subscription } from "./types-
|
|
1
|
+
import { o as PaystackTransaction, s as Subscription } from "./types-BVSLYZGY.mjs";
|
|
2
2
|
import { paystack } from "./index.mjs";
|
|
3
3
|
import { BetterFetch, BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
|
|
4
4
|
|
|
@@ -268,6 +268,10 @@ declare const paystackClient: <O extends {
|
|
|
268
268
|
link: string;
|
|
269
269
|
}>>;
|
|
270
270
|
getConfig: () => Promise<BetterFetchResponse<Record<string, unknown>>>;
|
|
271
|
+
syncProducts: () => Promise<BetterFetchResponse<{
|
|
272
|
+
status: string;
|
|
273
|
+
count: number;
|
|
274
|
+
}>>;
|
|
271
275
|
};
|
|
272
276
|
};
|
|
273
277
|
};
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;cAOa,cAAA;EAEX,YAAA;AAAA,GAGA,QAAA,GAAW,CAAA;;sBAIe,UAAA,QAAkB,QAAA;uBACvB,WAAA;;MADK;;;;QAGxB,IAAA;QACA,KAAA;QACA,MAAA;QACA,SAAA;QACA,QAAA,GAAW,MAAA;QACX,WAAA;QACA,WAAA;QACA,QAAA;QACA,QAAA;QACA,WAAA;QACA,OAAA;MAAA,GACA,OAAA,GAAY,iBAAA,KAAoB,OAAA,CAAQ,mBAAA;QACxC,GAAA;QACA,SAAA;QACA,UAAA;QACA,QAAA;MAAA;MAsDsF;;;;QArEtF,IAAA;QACA,KAAA;QACA,MAAA;QACA,SAAA;QACA,QAAA,GAAW,MAAA;QACX,WAAA;QACA,WAAA;QACA,QAAA;QACA,QAAA;QACA,WAAA;QACA,OAAA;MAAA,GACA,OAAA,GAAY,iBAAA,KAAoB,OAAA,CAAQ,mBAAA;QACxC,GAAA;QACA,SAAA;QACA,UAAA;QACA,QAAA;MAAA;MAcuE;;;;QAqDvE,gBAAA;QACA,UAAA;MAAA,GACA,OAAA,GAAY,iBAAA,KAAoB,OAAA,CAAQ,mBAAA;QACxC,MAAA;MAAA;MA1EY;;;;QAsFZ,gBAAA;QACA,UAAA;MAAA,GACA,OAAA,GAAY,iBAAA,KAAoB,OAAA,CAAQ,mBAAA;QACx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AA;MAAA;IAAA;EAAA;AAAA"}
|
package/dist/client.mjs
CHANGED
|
@@ -91,6 +91,9 @@ const paystackClient = (_options) => {
|
|
|
91
91
|
getSubscriptionManageLink,
|
|
92
92
|
getConfig: async () => {
|
|
93
93
|
return $fetch("paystack/get-config", { method: "GET" });
|
|
94
|
+
},
|
|
95
|
+
syncProducts: async () => {
|
|
96
|
+
return $fetch("paystack/sync-products", { method: "POST" });
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
};
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth\";\nimport type { BetterFetchResponse, BetterFetchOption, BetterFetch } from \"@better-fetch/fetch\";\n\nimport type { PaystackTransaction, Subscription } from \"./types\";\n\nimport type { paystack } from \"./index\";\n\nexport const paystackClient = <\n\tO extends {\n\t\tsubscription: boolean;\n\t},\n>(\n\t\t_options?: O,\n\t) => {\n\treturn {\n\t\tid: \"paystack\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof paystack>,\n\t\tgetActions: ($fetch: BetterFetch) => {\n\t\t\tconst initializeTransaction = async (data: {\n\t\t\t\tplan?: string;\n\t\t\t\temail?: string;\n\t\t\t\tamount?: number;\n\t\t\t\treference?: string;\n\t\t\t\tmetadata?: Record<string, unknown>;\n\t\t\t\tcallbackUrl?: string;\n\t\t\t\tcallbackURL?: string;\n\t\t\t\tcurrency?: string;\n\t\t\t\tquantity?: number;\n\t\t\t\treferenceId?: string;\n\t\t\t\tproduct?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\turl: string;\n\t\t\t\treference: string;\n\t\t\t\taccessCode: string;\n\t\t\t\tredirect: boolean;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\turl: string;\n\t\t\t\t\treference: string;\n\t\t\t\t\taccessCode: string;\n\t\t\t\t\tredirect: boolean;\n\t\t\t\t}>(\"paystack/initialize-transaction\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst verifyTransaction = async (data: { reference: string }, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t\treference: string;\n\t\t\t\tdata: unknown;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t\treference: string;\n\t\t\t\t\tdata: unknown;\n\t\t\t\t}>(\"paystack/verify-transaction\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst listTransactions = async (data: { query?: Record<string, unknown> } = {}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\ttransactions: PaystackTransaction[];\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\ttransactions: PaystackTransaction[];\n\t\t\t\t}>(\"paystack/list-transactions\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data.query,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst listSubscriptions = async (data: { query?: Record<string, unknown> } = {}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tsubscriptions: Subscription[];\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tsubscriptions: Subscription[];\n\t\t\t\t}>(\"paystack/list-subscriptions\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data.query,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst getSubscriptionManageLink = async (data: { subscriptionCode: string }, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tlink: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tlink: string;\n\t\t\t\t}>(\"paystack/get-subscription-manage-link\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst cancelSubscription = async (data: {\n\t\t\t\tsubscriptionCode: string;\n\t\t\t\temailToken?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t}>(\"paystack/disable-subscription\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst restoreSubscription = async (data: {\n\t\t\t\tsubscriptionCode: string;\n\t\t\t\temailToken?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t}>(\"paystack/enable-subscription\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tsubscription: {\n\t\t\t\t\t/**\n * Initialize a transaction to upgrade or creating a subscription.\n */\n\t\t\t\t\tupgrade: initializeTransaction,\n\t\t\t\t\t/**\n * Initialize a payment to create a subscription.\n */\n\t\t\t\t\tcreate: initializeTransaction,\n\t\t\t\t\t/**\n * Disable a subscription.\n */\n\t\t\t\t\tcancel: cancelSubscription,\n\t\t\t\t\t/**\n * Enable a subscription.\n */\n\t\t\t\t\trestore: restoreSubscription,\n\t\t\t\t\t/**\n * List subscriptions for the user.\n */\n\t\t\t\t\tlist: listSubscriptions,\n\t\t\t\t\t/**\n * Get a link to manage the subscription on Paystack.\n */\n\t\t\t\t\tbillingPortal: getSubscriptionManageLink,\n\t\t\t\t\t/**\n * Aliases for legacy/demo usage.\n */\n\t\t\t\t\tlistLocal: listSubscriptions,\n\t\t\t\t\tmanageLink: getSubscriptionManageLink,\n\t\t\t\t\tdisable: cancelSubscription,\n\t\t\t\t\tenable: restoreSubscription,\n\t\t\t\t},\n\t\t\t\tpaystack: {\n\t\t\t\t\ttransaction: {\n\t\t\t\t\t\tinitialize: initializeTransaction,\n\t\t\t\t\t\tverify: verifyTransaction,\n\t\t\t\t\t\tlist: listTransactions,\n\t\t\t\t\t},\n\t\t\t\t\tsubscription: {\n\t\t\t\t\t\tcreate: initializeTransaction,\n\t\t\t\t\t\tupgrade: initializeTransaction,\n\t\t\t\t\t\tcancel: cancelSubscription,\n\t\t\t\t\t\trestore: restoreSubscription,\n\t\t\t\t\t\tlist: listSubscriptions,\n\t\t\t\t\t\tbillingPortal: getSubscriptionManageLink,\n\t\t\t\t\t\tlistLocal: listSubscriptions,\n\t\t\t\t\t\tmanageLink: getSubscriptionManageLink,\n\t\t\t\t\t\tdisable: cancelSubscription,\n\t\t\t\t\t\tenable: restoreSubscription,\n\t\t\t\t\t},\n\t\t\t\t\tinitializeTransaction,\n\t\t\t\t\tverifyTransaction,\n\t\t\t\t\tlistTransactions,\n\t\t\t\t\tlistSubscriptions,\n\t\t\t\t\tgetSubscriptionManageLink,\n\t\t\t\t\tgetConfig: async (): Promise<BetterFetchResponse<Record<string, unknown>>> => {\n\t\t\t\t\t\treturn $fetch<Record<string, unknown>>(\"paystack/get-config\", {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";AAOA,MAAa,kBAKX,aACI;AACL,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EACtB,aAAa,WAAwB;GACpC,MAAM,wBAAwB,OAAO,MAYlC,YAKI;AACN,WAAO,OAKJ,mCAAm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
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth\";\nimport type { BetterFetchResponse, BetterFetchOption, BetterFetch } from \"@better-fetch/fetch\";\n\nimport type { PaystackTransaction, Subscription } from \"./types\";\n\nimport type { paystack } from \"./index\";\n\nexport const paystackClient = <\n\tO extends {\n\t\tsubscription: boolean;\n\t},\n>(\n\t\t_options?: O,\n\t) => {\n\treturn {\n\t\tid: \"paystack\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof paystack>,\n\t\tgetActions: ($fetch: BetterFetch) => {\n\t\t\tconst initializeTransaction = async (data: {\n\t\t\t\tplan?: string;\n\t\t\t\temail?: string;\n\t\t\t\tamount?: number;\n\t\t\t\treference?: string;\n\t\t\t\tmetadata?: Record<string, unknown>;\n\t\t\t\tcallbackUrl?: string;\n\t\t\t\tcallbackURL?: string;\n\t\t\t\tcurrency?: string;\n\t\t\t\tquantity?: number;\n\t\t\t\treferenceId?: string;\n\t\t\t\tproduct?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\turl: string;\n\t\t\t\treference: string;\n\t\t\t\taccessCode: string;\n\t\t\t\tredirect: boolean;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\turl: string;\n\t\t\t\t\treference: string;\n\t\t\t\t\taccessCode: string;\n\t\t\t\t\tredirect: boolean;\n\t\t\t\t}>(\"paystack/initialize-transaction\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst verifyTransaction = async (data: { reference: string }, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t\treference: string;\n\t\t\t\tdata: unknown;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t\treference: string;\n\t\t\t\t\tdata: unknown;\n\t\t\t\t}>(\"paystack/verify-transaction\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst listTransactions = async (data: { query?: Record<string, unknown> } = {}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\ttransactions: PaystackTransaction[];\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\ttransactions: PaystackTransaction[];\n\t\t\t\t}>(\"paystack/list-transactions\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data.query,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst listSubscriptions = async (data: { query?: Record<string, unknown> } = {}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tsubscriptions: Subscription[];\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tsubscriptions: Subscription[];\n\t\t\t\t}>(\"paystack/list-subscriptions\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data.query,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst getSubscriptionManageLink = async (data: { subscriptionCode: string }, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tlink: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tlink: string;\n\t\t\t\t}>(\"paystack/get-subscription-manage-link\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tquery: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst cancelSubscription = async (data: {\n\t\t\t\tsubscriptionCode: string;\n\t\t\t\temailToken?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t}>(\"paystack/disable-subscription\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tconst restoreSubscription = async (data: {\n\t\t\t\tsubscriptionCode: string;\n\t\t\t\temailToken?: string;\n\t\t\t}, options?: BetterFetchOption): Promise<BetterFetchResponse<{\n\t\t\t\tstatus: string;\n\t\t\t}>> => {\n\t\t\t\treturn $fetch<{\n\t\t\t\t\tstatus: string;\n\t\t\t\t}>(\"paystack/enable-subscription\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tsubscription: {\n\t\t\t\t\t/**\n * Initialize a transaction to upgrade or creating a subscription.\n */\n\t\t\t\t\tupgrade: initializeTransaction,\n\t\t\t\t\t/**\n * Initialize a payment to create a subscription.\n */\n\t\t\t\t\tcreate: initializeTransaction,\n\t\t\t\t\t/**\n * Disable a subscription.\n */\n\t\t\t\t\tcancel: cancelSubscription,\n\t\t\t\t\t/**\n * Enable a subscription.\n */\n\t\t\t\t\trestore: restoreSubscription,\n\t\t\t\t\t/**\n * List subscriptions for the user.\n */\n\t\t\t\t\tlist: listSubscriptions,\n\t\t\t\t\t/**\n * Get a link to manage the subscription on Paystack.\n */\n\t\t\t\t\tbillingPortal: getSubscriptionManageLink,\n\t\t\t\t\t/**\n * Aliases for legacy/demo usage.\n */\n\t\t\t\t\tlistLocal: listSubscriptions,\n\t\t\t\t\tmanageLink: getSubscriptionManageLink,\n\t\t\t\t\tdisable: cancelSubscription,\n\t\t\t\t\tenable: restoreSubscription,\n\t\t\t\t},\n\t\t\t\tpaystack: {\n\t\t\t\t\ttransaction: {\n\t\t\t\t\t\tinitialize: initializeTransaction,\n\t\t\t\t\t\tverify: verifyTransaction,\n\t\t\t\t\t\tlist: listTransactions,\n\t\t\t\t\t},\n\t\t\t\t\tsubscription: {\n\t\t\t\t\t\tcreate: initializeTransaction,\n\t\t\t\t\t\tupgrade: initializeTransaction,\n\t\t\t\t\t\tcancel: cancelSubscription,\n\t\t\t\t\t\trestore: restoreSubscription,\n\t\t\t\t\t\tlist: listSubscriptions,\n\t\t\t\t\t\tbillingPortal: getSubscriptionManageLink,\n\t\t\t\t\t\tlistLocal: listSubscriptions,\n\t\t\t\t\t\tmanageLink: getSubscriptionManageLink,\n\t\t\t\t\t\tdisable: cancelSubscription,\n\t\t\t\t\t\tenable: restoreSubscription,\n\t\t\t\t\t},\n\t\t\t\t\tinitializeTransaction,\n\t\t\t\t\tverifyTransaction,\n\t\t\t\t\tlistTransactions,\n\t\t\t\t\tlistSubscriptions,\n\t\t\t\t\tgetSubscriptionManageLink,\n\t\t\t\t\tgetConfig: async (): Promise<BetterFetchResponse<Record<string, unknown>>> => {\n\t\t\t\t\t\treturn $fetch<Record<string, unknown>>(\"paystack/get-config\", {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tsyncProducts: async (): Promise<BetterFetchResponse<{ status: string; count: number }>> => {\n\t\t\t\t\t\treturn $fetch<{ status: string; count: number }>(\"paystack/sync-products\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";AAOA,MAAa,kBAKX,aACI;AACL,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EACtB,aAAa,WAAwB;GACpC,MAAM,wBAAwB,OAAO,MAYlC,YAKI;AACN,WAAO,OAKJ,mCAAmC;KACrC,QAAQ;KACR,MAAM;KACN,GAAG;KACH,CAAC;;GAGH,MAAM,oBAAoB,OAAO,MAA6B,YAIvD;AACN,WAAO,OAIJ,+BAA+B;KACjC,QAAQ;KACR,MAAM;KACN,GAAG;KACH,CAAC;;GAGH,MAAM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n as PaystackNodeClient, o as PaystackTransaction, r as PaystackOptions, s as Subscription, t as PaystackClientLike } from "./types-
|
|
1
|
+
import { a as PaystackProduct, c as SubscriptionOptions, i as PaystackPlan, n as PaystackNodeClient, o as PaystackTransaction, r as PaystackOptions, s as Subscription, t as PaystackClientLike } from "./types-BVSLYZGY.mjs";
|
|
2
2
|
import * as better_auth0 from "better-auth";
|
|
3
3
|
import { AuthContext, GenericEndpointContext } from "better-auth";
|
|
4
4
|
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
@@ -6,7 +6,7 @@ import * as zod from "zod";
|
|
|
6
6
|
import * as better_call0 from "better-call";
|
|
7
7
|
|
|
8
8
|
//#region src/index.d.ts
|
|
9
|
-
declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNodeClient, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>>(options: O) => {
|
|
9
|
+
declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNodeClient, TMetadata = any, TLimits = any, O extends PaystackOptions<TPaystackClient, TMetadata, TLimits> = PaystackOptions<TPaystackClient, TMetadata, TLimits>>(options: O) => {
|
|
10
10
|
readonly id: "paystack";
|
|
11
11
|
readonly endpoints: {
|
|
12
12
|
readonly initializeTransaction: better_call0.StrictEndpoint<"/paystack/initialize-transaction", {
|
|
@@ -86,7 +86,7 @@ declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNo
|
|
|
86
86
|
}, {
|
|
87
87
|
status: string | undefined;
|
|
88
88
|
reference: string;
|
|
89
|
-
data: unknown
|
|
89
|
+
data: Record<string, unknown>;
|
|
90
90
|
}>;
|
|
91
91
|
readonly listSubscriptions: better_call0.StrictEndpoint<"/paystack/list-subscriptions", {
|
|
92
92
|
method: "GET";
|
|
@@ -175,7 +175,7 @@ declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNo
|
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
177
|
}, {
|
|
178
|
-
plans: PaystackPlan[];
|
|
178
|
+
plans: PaystackPlan<any>[];
|
|
179
179
|
products: PaystackProduct[];
|
|
180
180
|
}>;
|
|
181
181
|
readonly disableSubscription: better_call0.StrictEndpoint<"/paystack/disable-subscription", {
|
|
@@ -439,6 +439,49 @@ declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNo
|
|
|
439
439
|
}, {
|
|
440
440
|
status: string;
|
|
441
441
|
}>;
|
|
442
|
+
readonly chargeRecurringSubscription: better_call0.StrictEndpoint<"/paystack/charge-recurring", {
|
|
443
|
+
method: "POST";
|
|
444
|
+
body: zod.ZodObject<{
|
|
445
|
+
subscriptionId: zod.ZodString;
|
|
446
|
+
amount: zod.ZodOptional<zod.ZodNumber>;
|
|
447
|
+
}, better_auth0.$strip>;
|
|
448
|
+
}, {
|
|
449
|
+
status: string;
|
|
450
|
+
data: Record<string, unknown>;
|
|
451
|
+
}>;
|
|
452
|
+
readonly syncProducts: better_call0.StrictEndpoint<"/paystack/sync-products", {
|
|
453
|
+
method: "POST";
|
|
454
|
+
metadata: {
|
|
455
|
+
scope: "server";
|
|
456
|
+
};
|
|
457
|
+
disableBody: true;
|
|
458
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
459
|
+
session: {
|
|
460
|
+
session: Record<string, any> & {
|
|
461
|
+
id: string;
|
|
462
|
+
createdAt: Date;
|
|
463
|
+
updatedAt: Date;
|
|
464
|
+
userId: string;
|
|
465
|
+
expiresAt: Date;
|
|
466
|
+
token: string;
|
|
467
|
+
ipAddress?: string | null | undefined;
|
|
468
|
+
userAgent?: string | null | undefined;
|
|
469
|
+
};
|
|
470
|
+
user: Record<string, any> & {
|
|
471
|
+
id: string;
|
|
472
|
+
createdAt: Date;
|
|
473
|
+
updatedAt: Date;
|
|
474
|
+
email: string;
|
|
475
|
+
emailVerified: boolean;
|
|
476
|
+
name: string;
|
|
477
|
+
image?: string | null | undefined;
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
}>)[];
|
|
481
|
+
}, {
|
|
482
|
+
status: string;
|
|
483
|
+
count: number;
|
|
484
|
+
}>;
|
|
442
485
|
};
|
|
443
486
|
readonly schema: _better_auth_core_db0.BetterAuthPluginDBSchema;
|
|
444
487
|
readonly init: (ctx: AuthContext) => {
|
|
@@ -497,7 +540,7 @@ declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackNo
|
|
|
497
540
|
readonly EMAIL_VERIFICATION_REQUIRED: "Email verification is required before you can subscribe to a plan";
|
|
498
541
|
};
|
|
499
542
|
};
|
|
500
|
-
type PaystackPlugin<O extends PaystackOptions<PaystackClientLike> = PaystackOptions> = ReturnType<typeof paystack<PaystackClientLike, O>>;
|
|
543
|
+
type PaystackPlugin<O extends PaystackOptions<PaystackClientLike, any, any> = PaystackOptions> = ReturnType<typeof paystack<PaystackClientLike, any, any, O>>;
|
|
501
544
|
//#endregion
|
|
502
545
|
export { type PaystackOptions, type PaystackPlan, PaystackPlugin, type PaystackProduct, type Subscription, type SubscriptionOptions, paystack };
|
|
503
546
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;cA2Ca,QAAA,2BACe,kBAAA,GAAqB,kBAAA,4CAGnC,eAAA,CAAgB,eAAA,EAAiB,SAAA,EAAW,OAAA,IAAW,eAAA,CAAgB,eAAA,EAAiB,SAAA,EAAW,OAAA,GAE/G,OAAA,EAAS,CAAA;EAAA;;;;;8BAAC,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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