@alexasomba/better-auth-paystack 2.1.0 → 2.2.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 +76 -12
- package/dist/client.d.mts +130 -155
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +90 -74
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +423 -2
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +278 -98
- package/dist/index.mjs.map +1 -1
- package/dist/types-B5ZnlFrq.d.mts +258 -0
- package/dist/types-B5ZnlFrq.d.mts.map +1 -0
- package/package.json +4 -4
- 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,21 @@ 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: [
|
|
118
|
+
plugins: [
|
|
119
|
+
adminClient(),
|
|
120
|
+
paystackClient({ subscription: true })
|
|
121
|
+
],
|
|
111
122
|
});
|
|
112
123
|
```
|
|
113
124
|
|
|
@@ -153,6 +164,8 @@ import {
|
|
|
153
164
|
chargeSubscriptionRenewal,
|
|
154
165
|
syncPaystackPlans,
|
|
155
166
|
syncPaystackProducts,
|
|
167
|
+
type ChargeRecurringSubscriptionResult,
|
|
168
|
+
type PaystackSyncResult,
|
|
156
169
|
} from "@alexasomba/better-auth-paystack";
|
|
157
170
|
|
|
158
171
|
const ctx = { context: await auth.$context } as any;
|
|
@@ -283,21 +296,44 @@ if (data?.accessCode) {
|
|
|
283
296
|
Defer changes to the end of the current billing cycle:
|
|
284
297
|
|
|
285
298
|
- **Upgrades**: Pass `scheduleAtPeriodEnd: true` in `initializeTransaction()`.
|
|
286
|
-
- **Cancellations**: Use `authClient.subscription.cancel({ atPeriodEnd: true })` to keep the subscription active until the period ends.
|
|
299
|
+
- **Cancellations**: Use `authClient.subscription.cancel({ subscriptionCode, atPeriodEnd: true })` to keep the subscription active until the period ends.
|
|
287
300
|
|
|
288
301
|
### Mid-Cycle Proration (`prorateAndCharge`)
|
|
289
302
|
|
|
290
303
|
The plugin can dynamically calculate the cost difference for immediate mid-cycle upgrades (like adding more seats).
|
|
291
|
-
|
|
304
|
+
For locally managed plans:
|
|
305
|
+
|
|
306
|
+
- 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.
|
|
307
|
+
- 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.
|
|
308
|
+
- 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
309
|
|
|
293
310
|
```ts
|
|
294
311
|
await authClient.paystack.transaction.initialize({
|
|
295
312
|
plan: "pro",
|
|
296
313
|
quantity: 5, // Upgrading seats
|
|
297
|
-
prorateAndCharge: true, //
|
|
314
|
+
prorateAndCharge: true, // Charges saved authorization or returns a checkout redirect for the delta
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
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.
|
|
319
|
+
|
|
320
|
+
### Restricting Subscription Payment Channels
|
|
321
|
+
|
|
322
|
+
Use `subscription.allowedPaymentChannels` to constrain which Paystack checkout channels can be used for subscription flows.
|
|
323
|
+
This applies to standard subscription checkout, trial authorization flows, and interactive proration checkout fallbacks.
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
paystack({
|
|
327
|
+
subscription: {
|
|
328
|
+
enabled: true,
|
|
329
|
+
allowedPaymentChannels: ["card"],
|
|
330
|
+
plans: [{ name: "starter", amount: 50000, currency: "NGN", interval: "monthly" }],
|
|
331
|
+
},
|
|
298
332
|
});
|
|
299
333
|
```
|
|
300
334
|
|
|
335
|
+
If a subscription payment is later verified with a disallowed channel, the plugin rejects activation instead of silently creating the subscription.
|
|
336
|
+
|
|
301
337
|
### Webhook Security
|
|
302
338
|
|
|
303
339
|
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 +348,9 @@ paystack({
|
|
|
312
348
|
});
|
|
313
349
|
```
|
|
314
350
|
|
|
351
|
+
Resolution order for webhook signature verification is:
|
|
352
|
+
`webhook.secret` -> `paystackWebhookSecret` (deprecated) -> `secretKey`.
|
|
353
|
+
|
|
315
354
|
### Trial Abuse Prevention
|
|
316
355
|
|
|
317
356
|
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.
|
|
@@ -423,7 +462,7 @@ type upgradeSubscription = {
|
|
|
423
462
|
/**
|
|
424
463
|
* Additional metadata to store with the transaction.
|
|
425
464
|
*/
|
|
426
|
-
metadata?: Record<string,
|
|
465
|
+
metadata?: Record<string, unknown>;
|
|
427
466
|
/**
|
|
428
467
|
* Reference ID for the subscription owner (User ID or Org ID).
|
|
429
468
|
* Defaults to the current user's ID.
|
|
@@ -454,6 +493,11 @@ type initializeTransaction = {
|
|
|
454
493
|
* Amount to charge (if sending raw amount).
|
|
455
494
|
*/
|
|
456
495
|
amount?: number;
|
|
496
|
+
/**
|
|
497
|
+
* For existing locally managed subscriptions, calculate a mid-cycle delta and either
|
|
498
|
+
* charge the saved authorization or return a checkout redirect for interactive payment.
|
|
499
|
+
*/
|
|
500
|
+
prorateAndCharge?: boolean;
|
|
457
501
|
// ... same as upgradeSubscription
|
|
458
502
|
};
|
|
459
503
|
```
|
|
@@ -482,6 +526,10 @@ Cancel or restore a subscription.
|
|
|
482
526
|
|
|
483
527
|
```ts
|
|
484
528
|
type cancelSubscription = {
|
|
529
|
+
/**
|
|
530
|
+
* Optional reference owner (user ID or org ID) when managing another billing entity.
|
|
531
|
+
*/
|
|
532
|
+
referenceId?: string;
|
|
485
533
|
/**
|
|
486
534
|
* The Paystack subscription code (e.g. SUB_...)
|
|
487
535
|
*/
|
|
@@ -491,6 +539,10 @@ type cancelSubscription = {
|
|
|
491
539
|
* Optional: The server will try to fetch it if omitted.
|
|
492
540
|
*/
|
|
493
541
|
emailToken?: string;
|
|
542
|
+
/**
|
|
543
|
+
* When true, keep the subscription active until the current period ends.
|
|
544
|
+
*/
|
|
545
|
+
atPeriodEnd?: boolean;
|
|
494
546
|
};
|
|
495
547
|
```
|
|
496
548
|
|
|
@@ -583,22 +635,34 @@ The following fields are indexed:
|
|
|
583
635
|
- **`user` & `organization`**: `paystackCustomerCode`.
|
|
584
636
|
- **`paystackProduct`**: `slug` (unique), `paystackId` (unique).
|
|
585
637
|
|
|
638
|
+
Proration upgrades and trusted renewal charges also persist `paystackTransaction` rows, so local transaction history stays aligned with successful off-session charges.
|
|
639
|
+
|
|
586
640
|
### Syncing Products
|
|
587
641
|
|
|
588
|
-
The plugin provides two ways to keep your product inventory
|
|
642
|
+
The plugin provides two ways to keep your product inventory aligned with Paystack:
|
|
589
643
|
|
|
590
|
-
#### 1. Automated Inventory Sync
|
|
644
|
+
#### 1. Automated Inventory Sync
|
|
591
645
|
|
|
592
646
|
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
647
|
|
|
594
|
-
#### 2. Manual Bulk Sync
|
|
648
|
+
#### 2. Trusted Manual Bulk Sync
|
|
595
649
|
|
|
596
|
-
|
|
650
|
+
The public `/paystack/sync-products` endpoint was removed in `2.0.0`.
|
|
651
|
+
Run the trusted server operation from backend code instead:
|
|
597
652
|
|
|
598
|
-
```
|
|
599
|
-
|
|
653
|
+
```ts
|
|
654
|
+
import { syncPaystackProducts } from "@alexasomba/better-auth-paystack";
|
|
655
|
+
|
|
656
|
+
const ctx = { context: await auth.$context } as any;
|
|
657
|
+
|
|
658
|
+
await syncPaystackProducts(ctx, paystackOptions);
|
|
600
659
|
```
|
|
601
660
|
|
|
661
|
+
### SDK Compatibility Note
|
|
662
|
+
|
|
663
|
+
The plugin now targets the official `@alexasomba/paystack-node` grouped client surface directly.
|
|
664
|
+
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`.
|
|
665
|
+
|
|
602
666
|
---
|
|
603
667
|
|
|
604
668
|
## 🏗️ Development & Contributing
|
package/dist/client.d.mts
CHANGED
|
@@ -1,164 +1,139 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as Subscription, l as PaystackTransaction, o as PaystackPlan, s as PaystackProduct, u as PaystackTransactionResponse } from "./types-B5ZnlFrq.mjs";
|
|
2
|
+
import { BetterAuthClientPlugin } from "better-auth";
|
|
2
3
|
import { BetterFetch, BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
|
|
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
|
+
disable: PaystackClientActions["subscription"]["cancel"];
|
|
110
|
+
enable: PaystackClientActions["subscription"]["restore"];
|
|
160
111
|
};
|
|
112
|
+
paystack: PaystackClientActions;
|
|
113
|
+
}
|
|
114
|
+
declare module "better-auth/client" {
|
|
115
|
+
interface BetterAuthClient {
|
|
116
|
+
paystack: PaystackClientActions;
|
|
117
|
+
subscription: PaystackClientActions["subscription"];
|
|
118
|
+
transaction: PaystackClientActions["transaction"];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
declare module "better-auth" {
|
|
122
|
+
interface BetterAuthClientPlugins {
|
|
123
|
+
paystack: ReturnType<typeof paystackClient>;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Better Auth Paystack Client Plugin
|
|
128
|
+
*/
|
|
129
|
+
declare const paystackClient: <O extends {
|
|
130
|
+
subscription?: boolean;
|
|
131
|
+
} = {
|
|
132
|
+
subscription?: boolean;
|
|
133
|
+
}>(_options?: O) => BetterAuthClientPlugin & {
|
|
134
|
+
getActions: ($fetch: BetterFetch, $store: unknown, options: unknown) => PaystackClientActions;
|
|
161
135
|
};
|
|
136
|
+
declare const paystack: typeof paystackClient;
|
|
162
137
|
//#endregion
|
|
163
|
-
export { paystackClient };
|
|
138
|
+
export { FetchResult, PaystackActions, PaystackClientActions, paystack, paystackClient };
|
|
164
139
|
//# 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":[],"sources":["../src/client.ts"],"mappings":"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"}
|