@alexasomba/better-auth-paystack 2.1.0 → 2.4.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 +84 -14
- package/dist/client.d.mts +136 -155
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +101 -74
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +394 -2
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +447 -206
- package/dist/index.mjs.map +1 -1
- package/dist/types-CNI2ur0p.d.mts +271 -0
- package/dist/types-CNI2ur0p.d.mts.map +1 -0
- package/dist/version-C_50YiuM.mjs +6 -0
- package/dist/version-C_50YiuM.mjs.map +1 -0
- package/package.json +21 -22
- package/dist/index-Dwbeddkr.d.mts +0 -711
- package/dist/index-Dwbeddkr.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -21,9 +21,10 @@ A TypeScript-first plugin that integrates Paystack into [Better Auth](https://ww
|
|
|
21
21
|
- [x] **Auto Customer Creation**: Optional Paystack customer creation on user sign up or organization creation.
|
|
22
22
|
- [x] **Trial Management**: Configurable trial periods with built-in abuse prevention logic.
|
|
23
23
|
- [x] **Organization Billing**: Associate subscriptions with organizations and authorize access via roles.
|
|
24
|
+
- [x] **Subscription Channel Controls**: Restrict subscription checkout to specific Paystack payment channels such as card-only.
|
|
24
25
|
- [x] **Enforced Limits & Seats**: Automatic enforcement of member seat upgrades and resource limits (teams).
|
|
25
26
|
- [x] **Scheduled Changes**: Defer subscription updates or cancellations to the end of the billing cycle.
|
|
26
|
-
- [x] **Proration**: Immediate mid-cycle prorated
|
|
27
|
+
- [x] **Proration**: Immediate mid-cycle prorated upgrades for local plans, using saved-card charges when possible and checkout fallback when interactive payment is required.
|
|
27
28
|
- [x] **Popup Modal Flow**: Optional support for Paystack's inline checkout experience via `@alexasomba/paystack-inline`.
|
|
28
29
|
- [x] **Webhook Security**: Pre-configured signature verification (HMAC-SHA512) and optional IP whitelisting.
|
|
29
30
|
- [x] **Transaction History**: Built-in support for listing and viewing local transaction records.
|
|
@@ -64,6 +65,7 @@ BETTER_AUTH_URL=http://localhost:8787
|
|
|
64
65
|
import { betterAuth } from "better-auth";
|
|
65
66
|
import { paystack } from "@alexasomba/better-auth-paystack";
|
|
66
67
|
import { createPaystack } from "@alexasomba/paystack-node";
|
|
68
|
+
import { admin } from "better-auth/plugins";
|
|
67
69
|
|
|
68
70
|
const paystackClient = createPaystack({
|
|
69
71
|
secretKey: process.env.PAYSTACK_SECRET_KEY!,
|
|
@@ -71,12 +73,14 @@ const paystackClient = createPaystack({
|
|
|
71
73
|
|
|
72
74
|
export const auth = betterAuth({
|
|
73
75
|
plugins: [
|
|
76
|
+
admin(),
|
|
74
77
|
paystack({
|
|
75
78
|
paystackClient,
|
|
76
79
|
webhook: { secret: process.env.PAYSTACK_WEBHOOK_SECRET! },
|
|
77
80
|
createCustomerOnSignUp: true,
|
|
78
81
|
subscription: {
|
|
79
82
|
enabled: true,
|
|
83
|
+
allowedPaymentChannels: ["card"], // Optional: enforce card-only subscriptions
|
|
80
84
|
plans: [
|
|
81
85
|
{
|
|
82
86
|
name: "pro",
|
|
@@ -100,14 +104,18 @@ export const auth = betterAuth({
|
|
|
100
104
|
});
|
|
101
105
|
```
|
|
102
106
|
|
|
107
|
+
`webhook.secret` is the preferred webhook-signing config.
|
|
108
|
+
If you still have older code using top-level `paystackWebhookSecret`, it is treated as a deprecated alias and falls back to the same signature check.
|
|
109
|
+
|
|
103
110
|
### 4. Configure Client Plugin
|
|
104
111
|
|
|
105
112
|
```ts title="client.ts"
|
|
106
113
|
import { createAuthClient } from "better-auth/client";
|
|
107
114
|
import { paystackClient } from "@alexasomba/better-auth-paystack/client";
|
|
115
|
+
import { adminClient } from "better-auth/client/plugins";
|
|
108
116
|
|
|
109
117
|
export const client = createAuthClient({
|
|
110
|
-
plugins: [paystackClient({ subscription: true })],
|
|
118
|
+
plugins: [adminClient(), paystackClient({ subscription: true })],
|
|
111
119
|
});
|
|
112
120
|
```
|
|
113
121
|
|
|
@@ -153,6 +161,8 @@ import {
|
|
|
153
161
|
chargeSubscriptionRenewal,
|
|
154
162
|
syncPaystackPlans,
|
|
155
163
|
syncPaystackProducts,
|
|
164
|
+
type ChargeRecurringSubscriptionResult,
|
|
165
|
+
type PaystackSyncResult,
|
|
156
166
|
} from "@alexasomba/better-auth-paystack";
|
|
157
167
|
|
|
158
168
|
const ctx = { context: await auth.$context } as any;
|
|
@@ -283,21 +293,44 @@ if (data?.accessCode) {
|
|
|
283
293
|
Defer changes to the end of the current billing cycle:
|
|
284
294
|
|
|
285
295
|
- **Upgrades**: Pass `scheduleAtPeriodEnd: true` in `initializeTransaction()`.
|
|
286
|
-
- **Cancellations**: Use `authClient.subscription.cancel({ atPeriodEnd: true })` to keep the subscription active until the period ends.
|
|
296
|
+
- **Cancellations**: Use `authClient.subscription.cancel({ subscriptionCode, atPeriodEnd: true })` to keep the subscription active until the period ends.
|
|
287
297
|
|
|
288
298
|
### Mid-Cycle Proration (`prorateAndCharge`)
|
|
289
299
|
|
|
290
300
|
The plugin can dynamically calculate the cost difference for immediate mid-cycle upgrades (like adding more seats).
|
|
291
|
-
|
|
301
|
+
For locally managed plans:
|
|
302
|
+
|
|
303
|
+
- If the subscription already has a reusable Paystack authorization code, the plugin charges the prorated delta off-session, records a local `paystackTransaction`, and immediately updates the subscription.
|
|
304
|
+
- If there is no reusable authorization code available (for example, transfer-based payments), the plugin initializes a new checkout for the prorated delta instead of silently upgrading without payment.
|
|
305
|
+
- If the prorated amount is below Paystack's minimum charge for the currency, the request is rejected so you can schedule the change for period end instead of undercharging.
|
|
292
306
|
|
|
293
307
|
```ts
|
|
294
308
|
await authClient.paystack.transaction.initialize({
|
|
295
309
|
plan: "pro",
|
|
296
310
|
quantity: 5, // Upgrading seats
|
|
297
|
-
prorateAndCharge: true, //
|
|
311
|
+
prorateAndCharge: true, // Charges saved authorization or returns a checkout redirect for the delta
|
|
298
312
|
});
|
|
299
313
|
```
|
|
300
314
|
|
|
315
|
+
When the flow falls back to checkout, verify the returned transaction reference after payment. The plugin uses the stored proration metadata to apply the pending plan/seat change only after successful verification.
|
|
316
|
+
|
|
317
|
+
### Restricting Subscription Payment Channels
|
|
318
|
+
|
|
319
|
+
Use `subscription.allowedPaymentChannels` to constrain which Paystack checkout channels can be used for subscription flows.
|
|
320
|
+
This applies to standard subscription checkout, trial authorization flows, and interactive proration checkout fallbacks.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
paystack({
|
|
324
|
+
subscription: {
|
|
325
|
+
enabled: true,
|
|
326
|
+
allowedPaymentChannels: ["card"],
|
|
327
|
+
plans: [{ name: "starter", amount: 50000, currency: "NGN", interval: "monthly" }],
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
If a subscription payment is later verified with a disallowed channel, the plugin rejects activation instead of silently creating the subscription.
|
|
333
|
+
|
|
301
334
|
### Webhook Security
|
|
302
335
|
|
|
303
336
|
The plugin automatically verifies the `x-paystack-signature` header to ensure events are authentic. For an extra layer of security, you can enable **IP Whitelisting** to restrict processing to Paystack's official servers.
|
|
@@ -312,6 +345,9 @@ paystack({
|
|
|
312
345
|
});
|
|
313
346
|
```
|
|
314
347
|
|
|
348
|
+
Resolution order for webhook signature verification is:
|
|
349
|
+
`webhook.secret` -> `paystackWebhookSecret` (deprecated) -> `secretKey`.
|
|
350
|
+
|
|
315
351
|
### Trial Abuse Prevention
|
|
316
352
|
|
|
317
353
|
The plugin checks the `referenceId` history. If a trial was ever used (active, expired, or trialing), it will not be granted again, preventing resubscribe-abuse.
|
|
@@ -392,7 +428,16 @@ paystack({
|
|
|
392
428
|
|
|
393
429
|
## Client SDK Reference
|
|
394
430
|
|
|
395
|
-
The client plugin exposes fully typed methods under `authClient.paystack` and `authClient.subscription`.
|
|
431
|
+
The client plugin exposes fully typed canonical methods under `authClient.paystack`, `authClient.transaction`, and `authClient.subscription`.
|
|
432
|
+
|
|
433
|
+
- `authClient.transaction.initialize`, `verify`, `list`
|
|
434
|
+
- `authClient.subscription.create`, `upgrade`, `cancel`, `restore`, `list`, `billingPortal`
|
|
435
|
+
- `authClient.paystack.config`, `listProducts`, `listPlans`, plus the transaction/subscription helpers above
|
|
436
|
+
|
|
437
|
+
Deprecated compatibility aliases remain available in `2.x` and are planned for removal in the clean `3.0.0` release:
|
|
438
|
+
|
|
439
|
+
- `authClient.subscription.disable(...)` -> use `authClient.subscription.cancel(...)`
|
|
440
|
+
- `authClient.subscription.enable(...)` -> use `authClient.subscription.restore(...)`
|
|
396
441
|
|
|
397
442
|
### `authClient.subscription.upgrade` / `create`
|
|
398
443
|
|
|
@@ -423,7 +468,7 @@ type upgradeSubscription = {
|
|
|
423
468
|
/**
|
|
424
469
|
* Additional metadata to store with the transaction.
|
|
425
470
|
*/
|
|
426
|
-
metadata?: Record<string,
|
|
471
|
+
metadata?: Record<string, unknown>;
|
|
427
472
|
/**
|
|
428
473
|
* Reference ID for the subscription owner (User ID or Org ID).
|
|
429
474
|
* Defaults to the current user's ID.
|
|
@@ -454,13 +499,18 @@ type initializeTransaction = {
|
|
|
454
499
|
* Amount to charge (if sending raw amount).
|
|
455
500
|
*/
|
|
456
501
|
amount?: number;
|
|
502
|
+
/**
|
|
503
|
+
* For existing locally managed subscriptions, calculate a mid-cycle delta and either
|
|
504
|
+
* charge the saved authorization or return a checkout redirect for interactive payment.
|
|
505
|
+
*/
|
|
506
|
+
prorateAndCharge?: boolean;
|
|
457
507
|
// ... same as upgradeSubscription
|
|
458
508
|
};
|
|
459
509
|
```
|
|
460
510
|
|
|
461
511
|
### `authClient.subscription.list`
|
|
462
512
|
|
|
463
|
-
List subscriptions for a user or organization.
|
|
513
|
+
List subscriptions for a user or organization. Organization-scoped billing actions require an owner/admin membership by default. To allow other roles or custom resources, configure `subscription.authorizeReference`.
|
|
464
514
|
|
|
465
515
|
```ts
|
|
466
516
|
type listSubscriptions = {
|
|
@@ -482,6 +532,10 @@ Cancel or restore a subscription.
|
|
|
482
532
|
|
|
483
533
|
```ts
|
|
484
534
|
type cancelSubscription = {
|
|
535
|
+
/**
|
|
536
|
+
* Optional reference owner (user ID or org ID) when managing another billing entity.
|
|
537
|
+
*/
|
|
538
|
+
referenceId?: string;
|
|
485
539
|
/**
|
|
486
540
|
* The Paystack subscription code (e.g. SUB_...)
|
|
487
541
|
*/
|
|
@@ -491,6 +545,10 @@ type cancelSubscription = {
|
|
|
491
545
|
* Optional: The server will try to fetch it if omitted.
|
|
492
546
|
*/
|
|
493
547
|
emailToken?: string;
|
|
548
|
+
/**
|
|
549
|
+
* When true, keep the subscription active until the current period ends.
|
|
550
|
+
*/
|
|
551
|
+
atPeriodEnd?: boolean;
|
|
494
552
|
};
|
|
495
553
|
```
|
|
496
554
|
|
|
@@ -583,22 +641,34 @@ The following fields are indexed:
|
|
|
583
641
|
- **`user` & `organization`**: `paystackCustomerCode`.
|
|
584
642
|
- **`paystackProduct`**: `slug` (unique), `paystackId` (unique).
|
|
585
643
|
|
|
644
|
+
Proration upgrades and trusted renewal charges also persist `paystackTransaction` rows, so local transaction history stays aligned with successful off-session charges.
|
|
645
|
+
|
|
586
646
|
### Syncing Products
|
|
587
647
|
|
|
588
|
-
The plugin provides two ways to keep your product inventory
|
|
648
|
+
The plugin provides two ways to keep your product inventory aligned with Paystack:
|
|
589
649
|
|
|
590
|
-
#### 1. Automated Inventory Sync
|
|
650
|
+
#### 1. Automated Inventory Sync
|
|
591
651
|
|
|
592
652
|
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.
|
|
593
653
|
|
|
594
|
-
#### 2. Manual Bulk Sync
|
|
654
|
+
#### 2. Trusted Manual Bulk Sync
|
|
595
655
|
|
|
596
|
-
|
|
656
|
+
The public `/paystack/sync-products` endpoint was removed in `2.0.0`.
|
|
657
|
+
Run the trusted server operation from backend code instead:
|
|
597
658
|
|
|
598
|
-
```
|
|
599
|
-
|
|
659
|
+
```ts
|
|
660
|
+
import { syncPaystackProducts } from "@alexasomba/better-auth-paystack";
|
|
661
|
+
|
|
662
|
+
const ctx = { context: await auth.$context } as any;
|
|
663
|
+
|
|
664
|
+
await syncPaystackProducts(ctx, paystackOptions);
|
|
600
665
|
```
|
|
601
666
|
|
|
667
|
+
### SDK Compatibility Note
|
|
668
|
+
|
|
669
|
+
The plugin now targets the official `@alexasomba/paystack-node` grouped client surface directly.
|
|
670
|
+
If you inject a custom client, it should match the real SDK methods used by the plugin such as `transaction.initialize`, `transaction.verify`, `transaction.chargeAuthorization`, `subscription.create`, `subscription.disable`, and `subscription.enable`.
|
|
671
|
+
|
|
602
672
|
---
|
|
603
673
|
|
|
604
674
|
## 🏗️ Development & Contributing
|
package/dist/client.d.mts
CHANGED
|
@@ -1,164 +1,145 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as Subscription, l as PaystackTransaction, o as PaystackPlan, s as PaystackProduct, u as PaystackTransactionResponse } from "./types-CNI2ur0p.mjs";
|
|
2
2
|
import { BetterFetch, BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
|
|
3
|
+
import { BetterAuthClientPlugin } from "better-auth/client";
|
|
3
4
|
|
|
4
5
|
//#region src/client.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
subscriptionCode: string;
|
|
98
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
99
|
-
link: string;
|
|
100
|
-
}>>;
|
|
101
|
-
manageLink: (data: {
|
|
102
|
-
subscriptionCode: string;
|
|
103
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
104
|
-
link: string;
|
|
105
|
-
}>>;
|
|
106
|
-
disable: (data: {
|
|
107
|
-
subscriptionCode: string;
|
|
108
|
-
emailToken?: string;
|
|
109
|
-
atPeriodEnd?: boolean;
|
|
110
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
111
|
-
status: string;
|
|
112
|
-
}>>;
|
|
113
|
-
enable: (data: {
|
|
114
|
-
subscriptionCode: string;
|
|
115
|
-
emailToken?: string;
|
|
116
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
117
|
-
status: string;
|
|
118
|
-
}>>;
|
|
119
|
-
};
|
|
120
|
-
initializeTransaction: (data: Record<string, unknown> & {
|
|
121
|
-
callbackUrl?: string;
|
|
122
|
-
callbackURL?: string;
|
|
123
|
-
product?: string;
|
|
124
|
-
referenceId?: string;
|
|
125
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
126
|
-
url: string;
|
|
127
|
-
reference: string;
|
|
128
|
-
accessCode: string;
|
|
129
|
-
redirect: boolean;
|
|
130
|
-
}>>;
|
|
131
|
-
verifyTransaction: (data: {
|
|
132
|
-
reference: string;
|
|
133
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
6
|
+
/**
|
|
7
|
+
* Helper type to handle the conditional return type based on 'throw' option.
|
|
8
|
+
*/
|
|
9
|
+
type FetchResult<T, O extends BetterFetchOption | undefined> = O extends {
|
|
10
|
+
throw: true;
|
|
11
|
+
} ? T : BetterFetchResponse<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Paystack Client Action Definitions
|
|
14
|
+
*/
|
|
15
|
+
interface PaystackActions {
|
|
16
|
+
/**
|
|
17
|
+
* Initialize a transaction.
|
|
18
|
+
*/
|
|
19
|
+
initializeTransaction: <O extends BetterFetchOption | undefined = undefined>(data: Record<string, unknown> & {
|
|
20
|
+
callbackUrl?: string;
|
|
21
|
+
callbackURL?: string;
|
|
22
|
+
product?: string;
|
|
23
|
+
referenceId?: string;
|
|
24
|
+
}, options?: O) => Promise<FetchResult<{
|
|
25
|
+
url: string;
|
|
26
|
+
reference: string;
|
|
27
|
+
accessCode: string;
|
|
28
|
+
redirect: boolean;
|
|
29
|
+
}, O>>;
|
|
30
|
+
/**
|
|
31
|
+
* Verify a transaction by reference.
|
|
32
|
+
*/
|
|
33
|
+
verifyTransaction: <O extends BetterFetchOption | undefined = undefined>(data: {
|
|
34
|
+
reference: string;
|
|
35
|
+
}, options?: O) => Promise<FetchResult<{
|
|
36
|
+
status: string;
|
|
37
|
+
reference: string;
|
|
38
|
+
data: PaystackTransactionResponse;
|
|
39
|
+
}, O>>;
|
|
40
|
+
/**
|
|
41
|
+
* List transactions for the current user/reference.
|
|
42
|
+
*/
|
|
43
|
+
listTransactions: <O extends BetterFetchOption | undefined = undefined>(data?: {
|
|
44
|
+
query?: Record<string, unknown>;
|
|
45
|
+
}, options?: O) => Promise<FetchResult<{
|
|
46
|
+
transactions: PaystackTransaction[];
|
|
47
|
+
}, O>>;
|
|
48
|
+
/**
|
|
49
|
+
* List subscriptions for the current user/reference.
|
|
50
|
+
*/
|
|
51
|
+
listSubscriptions: <O extends BetterFetchOption | undefined = undefined>(data?: {
|
|
52
|
+
query?: Record<string, unknown>;
|
|
53
|
+
}, options?: O) => Promise<FetchResult<{
|
|
54
|
+
subscriptions: Subscription[];
|
|
55
|
+
}, O>>;
|
|
56
|
+
/**
|
|
57
|
+
* Get a manage link/billing portal link for a subscription.
|
|
58
|
+
*/
|
|
59
|
+
getSubscriptionManageLink: <O extends BetterFetchOption | undefined = undefined>(data: {
|
|
60
|
+
subscriptionCode: string;
|
|
61
|
+
}, options?: O) => Promise<FetchResult<{
|
|
62
|
+
link: string;
|
|
63
|
+
}, O>>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the plugin configuration (plans and products).
|
|
66
|
+
*/
|
|
67
|
+
config: () => Promise<BetterFetchResponse<Record<string, unknown>>>;
|
|
68
|
+
/**
|
|
69
|
+
* List available products.
|
|
70
|
+
*/
|
|
71
|
+
listProducts: <O extends BetterFetchOption | undefined = undefined>(options?: O) => Promise<FetchResult<{
|
|
72
|
+
products: PaystackProduct[];
|
|
73
|
+
}, O>>;
|
|
74
|
+
/**
|
|
75
|
+
* List available plans.
|
|
76
|
+
*/
|
|
77
|
+
listPlans: <O extends BetterFetchOption | undefined = undefined>(options?: O) => Promise<FetchResult<{
|
|
78
|
+
plans: PaystackPlan[];
|
|
79
|
+
}, O>>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Paystack Client Plugin Actions including namespaces
|
|
83
|
+
*/
|
|
84
|
+
interface PaystackClientActions extends PaystackActions {
|
|
85
|
+
transaction: {
|
|
86
|
+
initialize: PaystackActions["initializeTransaction"];
|
|
87
|
+
verify: PaystackActions["verifyTransaction"];
|
|
88
|
+
list: PaystackActions["listTransactions"];
|
|
89
|
+
};
|
|
90
|
+
subscription: {
|
|
91
|
+
upgrade: PaystackActions["initializeTransaction"];
|
|
92
|
+
create: PaystackActions["initializeTransaction"];
|
|
93
|
+
cancel: <O extends BetterFetchOption | undefined = undefined>(data: {
|
|
94
|
+
subscriptionCode: string;
|
|
95
|
+
emailToken?: string;
|
|
96
|
+
atPeriodEnd?: boolean;
|
|
97
|
+
}, options?: O) => Promise<FetchResult<{
|
|
134
98
|
status: string;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}>>;
|
|
138
|
-
listTransactions: (data?: {
|
|
139
|
-
query?: Record<string, unknown>;
|
|
140
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
141
|
-
transactions: PaystackTransaction[];
|
|
142
|
-
}>>;
|
|
143
|
-
listSubscriptions: (data?: {
|
|
144
|
-
query?: Record<string, unknown>;
|
|
145
|
-
}, options?: BetterFetchOption) => Promise<BetterFetchResponse<{
|
|
146
|
-
subscriptions: Subscription[];
|
|
147
|
-
}>>;
|
|
148
|
-
getSubscriptionManageLink: (data: {
|
|
99
|
+
}, O>>;
|
|
100
|
+
restore: <O extends BetterFetchOption | undefined = undefined>(data: {
|
|
149
101
|
subscriptionCode: string;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
102
|
+
emailToken?: string;
|
|
103
|
+
}, options?: O) => Promise<FetchResult<{
|
|
104
|
+
status: string;
|
|
105
|
+
}, O>>;
|
|
106
|
+
list: PaystackActions["listSubscriptions"];
|
|
107
|
+
billingPortal: PaystackActions["getSubscriptionManageLink"];
|
|
108
|
+
manageLink: PaystackActions["getSubscriptionManageLink"];
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated Use `subscription.cancel` instead.
|
|
111
|
+
*/
|
|
112
|
+
disable: PaystackClientActions["subscription"]["cancel"];
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `subscription.restore` instead.
|
|
115
|
+
*/
|
|
116
|
+
enable: PaystackClientActions["subscription"]["restore"];
|
|
160
117
|
};
|
|
118
|
+
paystack: PaystackClientActions;
|
|
119
|
+
}
|
|
120
|
+
declare module "better-auth/client" {
|
|
121
|
+
interface BetterAuthClient {
|
|
122
|
+
paystack: PaystackClientActions;
|
|
123
|
+
subscription: PaystackClientActions["subscription"];
|
|
124
|
+
transaction: PaystackClientActions["transaction"];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
declare module "better-auth" {
|
|
128
|
+
interface BetterAuthClientPlugins {
|
|
129
|
+
paystack: ReturnType<typeof paystackClient>;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Better Auth Paystack Client Plugin
|
|
134
|
+
*/
|
|
135
|
+
declare const paystackClient: <O extends {
|
|
136
|
+
subscription?: boolean;
|
|
137
|
+
} = {
|
|
138
|
+
subscription?: boolean;
|
|
139
|
+
}>(_options?: O) => BetterAuthClientPlugin & {
|
|
140
|
+
getActions: ($fetch: BetterFetch, $store: unknown, options: unknown) => PaystackClientActions;
|
|
161
141
|
};
|
|
142
|
+
declare const paystack: typeof paystackClient;
|
|
162
143
|
//#endregion
|
|
163
|
-
export { paystackClient };
|
|
144
|
+
export { FetchResult, PaystackActions, PaystackClientActions, paystack, paystackClient };
|
|
164
145
|
//# sourceMappingURL=client.d.mts.map
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":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