@alexasomba/better-auth-paystack 1.2.0 → 2.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.
@@ -0,0 +1,711 @@
1
+ import { AuthContext, BetterAuthPluginDBSchema, GenericEndpointContext, MiddlewareInputContext, MiddlewareOptions, RawError, Session, StrictEndpoint, User, ZodBoolean, ZodNumber, ZodObject, ZodOptional, ZodRecord, ZodString, ZodUnknown } from "better-auth";
2
+ import { PaystackResponse as PaystackResponse$1, PaystackWebhookEvent, components } from "@alexasomba/paystack-node";
3
+ import { $strip } from "zod/v4/core";
4
+
5
+ //#region src/types.d.ts
6
+ /**
7
+ * Custom models for Paystack Plugin
8
+ * These align with the database schema in src/schema.ts
9
+ */
10
+ interface PaystackTransaction {
11
+ id: string;
12
+ reference: string;
13
+ paystackId?: string;
14
+ referenceId: string;
15
+ userId: string;
16
+ amount: number;
17
+ currency: string;
18
+ status: string;
19
+ plan?: string | null;
20
+ product?: string | null;
21
+ metadata?: string | null;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ }
25
+ interface PaystackProduct {
26
+ id?: string;
27
+ name: string;
28
+ description?: string;
29
+ price: number;
30
+ currency: string;
31
+ quantity?: number;
32
+ unlimited?: boolean;
33
+ paystackId?: string;
34
+ slug?: string;
35
+ metadata?: string | null;
36
+ createdAt: Date;
37
+ updatedAt: Date;
38
+ }
39
+ interface PaystackPlan {
40
+ id?: string;
41
+ name: string;
42
+ description?: string;
43
+ amount?: number;
44
+ currency?: string;
45
+ interval?: string;
46
+ planCode?: string;
47
+ paystackId?: string;
48
+ seatAmount?: number;
49
+ seatPlanCode?: string;
50
+ invoiceLimit?: number;
51
+ freeTrial?: {
52
+ days?: number;
53
+ onTrialStart?: (subscription: Subscription) => Promise<void>;
54
+ };
55
+ limits?: Record<string, unknown>;
56
+ features?: string[];
57
+ metadata?: string | null;
58
+ createdAt?: Date;
59
+ updatedAt?: Date;
60
+ }
61
+ /**
62
+ * Paystack Webhook Payload structure
63
+ */
64
+ type PaystackWebhookPayload = PaystackWebhookEvent;
65
+ /**
66
+ * Paystack SDK Result types
67
+ */
68
+ type PaystackTransactionResponse = components["schemas"]["VerifyResponse"]["data"];
69
+ interface SubscriptionOptions {
70
+ /**
71
+ * Enable subscriptions
72
+ */
73
+ enabled?: boolean;
74
+ /**
75
+ * Plans configuration
76
+ */
77
+ plans: PaystackPlan[] | (() => Promise<PaystackPlan[]>);
78
+ /**
79
+ * Automatically sync quantity from local DB to Paystack (if seats are used)
80
+ */
81
+ autoSyncQuantity?: boolean;
82
+ /**
83
+ * Handling of subscription cancellation
84
+ * @default "at_period_end"
85
+ */
86
+ cancelBehavior?: "at_period_end" | "immediately";
87
+ /**
88
+ * Handlers for subscription events
89
+ */
90
+ onSubscriptionComplete?: (data: {
91
+ event: PaystackWebhookPayload;
92
+ subscription: Subscription;
93
+ plan: PaystackPlan;
94
+ }, ctx: GenericEndpointContext) => Promise<void>;
95
+ onSubscriptionCreated?: (data: {
96
+ event: PaystackWebhookPayload;
97
+ subscription: Subscription;
98
+ plan: PaystackPlan;
99
+ }, ctx: GenericEndpointContext) => Promise<void>;
100
+ onSubscriptionCancel?: (data: {
101
+ event: PaystackWebhookPayload;
102
+ subscription: Subscription;
103
+ }, ctx: GenericEndpointContext) => Promise<void>;
104
+ /**
105
+ * Authorization handler for reference checks
106
+ */
107
+ authorizeReference?: (data: {
108
+ user: User;
109
+ session: Session;
110
+ referenceId: string;
111
+ action: string;
112
+ }, ctx: GenericEndpointContext) => Promise<boolean>;
113
+ /**
114
+ * Require email verification before subscription
115
+ */
116
+ requireEmailVerification?: boolean;
117
+ }
118
+ interface PaystackOptions<TPaystackClient extends PaystackClientLike = PaystackClientLike> {
119
+ /**
120
+ * Paystack Secret Key
121
+ */
122
+ secretKey: string;
123
+ /**
124
+ * Paystack Client Instance
125
+ * If provided, will be used instead of creating a new one with secretKey
126
+ */
127
+ paystackClient?: TPaystackClient;
128
+ /**
129
+ * Webhook configuration
130
+ */
131
+ webhook?: {
132
+ /**
133
+ * Webhook secret for signature verification
134
+ */
135
+ secret?: string;
136
+ /**
137
+ * Whether to verify the request origin IP address
138
+ * @default false
139
+ */
140
+ verifyIP?: boolean;
141
+ /**
142
+ * List of trusted IP addresses for webhooks.
143
+ * Defaults to official Paystack IPs if verifyIP is true and this is empty.
144
+ */
145
+ trustedIPs?: string[];
146
+ };
147
+ /**
148
+ * Subscription configuration
149
+ */
150
+ subscription?: SubscriptionOptions;
151
+ /**
152
+ * Billing pattern
153
+ * @default "native"
154
+ */
155
+ billingPattern?: "native" | "local";
156
+ /**
157
+ * Global event handler
158
+ */
159
+ onEvent?: (event: PaystackWebhookEvent) => Promise<void>;
160
+ /**
161
+ * Organization billing configuration
162
+ */
163
+ organization?: {
164
+ enabled?: boolean;
165
+ getCustomerCreateParams?: (org: {
166
+ id: string;
167
+ name: string;
168
+ email?: string | null;
169
+ }, ctx: GenericEndpointContext) => Promise<Record<string, unknown>>;
170
+ onCustomerCreate?: (data: {
171
+ paystackCustomer: Record<string, unknown>;
172
+ organization: unknown;
173
+ }, ctx: GenericEndpointContext) => Promise<void>;
174
+ };
175
+ /**
176
+ * Products configuration
177
+ */
178
+ products?: {
179
+ products?: PaystackProduct[] | (() => Promise<PaystackProduct[]>);
180
+ };
181
+ createCustomerOnSignUp?: boolean;
182
+ onCustomerCreate?: (data: {
183
+ paystackCustomer: Record<string, unknown>;
184
+ user: unknown;
185
+ }, ctx: GenericEndpointContext) => Promise<void>;
186
+ /**
187
+ * Custom database schema / model names
188
+ */
189
+ schema?: Record<string, {
190
+ modelName?: string;
191
+ fields?: Record<string, string>;
192
+ }>;
193
+ }
194
+ interface Subscription {
195
+ id: string;
196
+ userId: string;
197
+ organizationId?: string;
198
+ plan: string;
199
+ pendingPlan?: string | null;
200
+ paystackSubscriptionCode?: string;
201
+ paystackCustomerCode?: string;
202
+ paystackPlanCode?: string;
203
+ paystackAuthorizationCode?: string;
204
+ paystackTransactionReference?: string;
205
+ paystackEmailToken?: string;
206
+ status: string;
207
+ seats: number;
208
+ referenceId: string;
209
+ periodStart?: Date | null;
210
+ periodEnd?: Date | null;
211
+ cancelAtPeriodEnd: boolean;
212
+ trialStart?: Date | null;
213
+ trialEnd?: Date | null;
214
+ groupId?: string | null;
215
+ createdAt: Date;
216
+ updatedAt: Date;
217
+ }
218
+ interface ChargeRecurringSubscriptionInput {
219
+ subscriptionId: string;
220
+ amount?: number;
221
+ }
222
+ interface ChargeRecurringSubscriptionResult {
223
+ status: "success" | "failed";
224
+ data: PaystackTransactionResponse;
225
+ }
226
+ interface PaystackSyncResult {
227
+ status: "success";
228
+ count: number;
229
+ }
230
+ type AnyPaystackOptions = PaystackOptions<PaystackClientLike>;
231
+ /**
232
+ * A stricter PaystackClient interface based on the grouped SDK structure
233
+ */
234
+ interface PaystackClientLike {
235
+ transaction?: {
236
+ initialize: (init: {
237
+ body: Record<string, unknown>;
238
+ }) => Promise<PaystackResponse$1<Record<string, unknown>>>;
239
+ verify: (reference: string, init?: Record<string, unknown>) => Promise<PaystackResponse$1<components["schemas"]["VerifyResponse"]["data"]>>;
240
+ chargeAuthorization: (init: {
241
+ body: Record<string, unknown>;
242
+ }) => Promise<PaystackResponse$1<components["schemas"]["ChargeAuthorizationResponse"]["data"]>>;
243
+ };
244
+ customer?: {
245
+ create: (init: {
246
+ body: Record<string, unknown>;
247
+ }) => Promise<PaystackResponse$1<components["schemas"]["ChargeAuthorizationResponse"]["data"]["customer"]>>;
248
+ update: (email_or_code: string, init: {
249
+ body: Record<string, unknown>;
250
+ }) => Promise<PaystackResponse$1<components["schemas"]["ChargeAuthorizationResponse"]["data"]["customer"]>>;
251
+ fetch: (email_or_code: string, init?: Record<string, unknown>) => Promise<PaystackResponse$1<components["schemas"]["ChargeAuthorizationResponse"]["data"]["customer"]>>;
252
+ };
253
+ subscription?: {
254
+ create: (init: {
255
+ body: Record<string, unknown>;
256
+ }) => Promise<PaystackResponse$1<components["schemas"]["SubscriptionListResponseArray"]>>;
257
+ update: (code: string, init: {
258
+ body: Record<string, unknown>;
259
+ }) => Promise<PaystackResponse$1<components["schemas"]["SubscriptionListResponseArray"]>>;
260
+ fetch: (id_or_code: string, init?: Record<string, unknown>) => Promise<PaystackResponse$1<components["schemas"]["SubscriptionListResponseArray"]>>;
261
+ disable: (init: {
262
+ body: {
263
+ code: string;
264
+ token: string;
265
+ };
266
+ }) => Promise<PaystackResponse$1<Record<string, unknown>>>;
267
+ enable: (init: {
268
+ body: {
269
+ code: string;
270
+ token: string;
271
+ };
272
+ }) => Promise<PaystackResponse$1<Record<string, unknown>>>;
273
+ manageLink: (code: string, init?: Record<string, unknown>) => Promise<PaystackResponse$1<{
274
+ link: string;
275
+ }>>;
276
+ };
277
+ product?: {
278
+ fetch: (id_or_code: string, init?: Record<string, unknown>) => Promise<PaystackResponse$1<components["schemas"]["ProductListsResponseArray"]>>;
279
+ list: (init?: {
280
+ query?: Record<string, unknown>;
281
+ }) => Promise<PaystackResponse$1<components["schemas"]["ProductListsResponseArray"][]>>;
282
+ };
283
+ plan?: {
284
+ list: (init?: {
285
+ query?: Record<string, unknown>;
286
+ }) => Promise<PaystackResponse$1<components["schemas"]["PlanListResponseArray"][]>>;
287
+ create: (init: {
288
+ body: Record<string, unknown>;
289
+ }) => Promise<PaystackResponse$1<components["schemas"]["PlanListResponseArray"]>>;
290
+ };
291
+ }
292
+ //#endregion
293
+ //#region src/operations.d.ts
294
+ declare function syncPaystackProducts(ctx: GenericEndpointContext, options: AnyPaystackOptions): Promise<PaystackSyncResult>;
295
+ declare function syncPaystackPlans(ctx: GenericEndpointContext, options: AnyPaystackOptions): Promise<PaystackSyncResult>;
296
+ declare function chargeSubscriptionRenewal(ctx: GenericEndpointContext, options: AnyPaystackOptions, input: ChargeRecurringSubscriptionInput): Promise<ChargeRecurringSubscriptionResult>;
297
+ //#endregion
298
+ //#region src/index.d.ts
299
+ declare module "@better-auth/core" {
300
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
301
+ paystack: {
302
+ creator: typeof paystack;
303
+ };
304
+ }
305
+ }
306
+ declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackClientLike, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>>(options: O) => {
307
+ id: "paystack";
308
+ endpoints: {
309
+ initializeTransaction: StrictEndpoint<"/paystack/initialize-transaction", {
310
+ method: "POST";
311
+ body: ZodObject<{
312
+ plan: ZodOptional<ZodString>;
313
+ product: ZodOptional<ZodString>;
314
+ amount: ZodOptional<ZodNumber>;
315
+ currency: ZodOptional<ZodString>;
316
+ email: ZodOptional<ZodString>;
317
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
318
+ referenceId: ZodOptional<ZodString>;
319
+ callbackURL: ZodOptional<ZodString>;
320
+ quantity: ZodOptional<ZodNumber>;
321
+ scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
322
+ cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
323
+ prorateAndCharge: ZodOptional<ZodBoolean>;
324
+ }, $strip>;
325
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
326
+ }, {
327
+ status: string;
328
+ message: string;
329
+ scheduled: boolean;
330
+ } | {
331
+ status: string;
332
+ message: string;
333
+ prorated: boolean;
334
+ } | {
335
+ url: string;
336
+ reference: string;
337
+ accessCode: string;
338
+ redirect: boolean;
339
+ } | undefined>;
340
+ verifyTransaction: StrictEndpoint<"/paystack/verify-transaction", {
341
+ method: "POST";
342
+ body: ZodObject<{
343
+ reference: ZodString;
344
+ }, $strip>;
345
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
346
+ }, {
347
+ status: string;
348
+ reference: string;
349
+ data: {
350
+ id: number;
351
+ domain: string;
352
+ status: string;
353
+ reference: string;
354
+ receipt_number: string | null;
355
+ amount: number;
356
+ message: string | null;
357
+ gateway_response: string;
358
+ channel: string;
359
+ currency: string;
360
+ ip_address: string | null;
361
+ metadata: (string | Record<string, never> | number) | null;
362
+ log: {
363
+ start_time: number;
364
+ time_spent: number;
365
+ attempts: number;
366
+ errors: number;
367
+ success: boolean;
368
+ mobile: boolean;
369
+ input: unknown[];
370
+ history: {
371
+ type: string;
372
+ message: string;
373
+ time: number;
374
+ }[];
375
+ } | null;
376
+ fees: number | null;
377
+ fees_split: unknown;
378
+ authorization: {
379
+ authorization_code?: string;
380
+ bin?: string | null;
381
+ last4?: string;
382
+ exp_month?: string;
383
+ exp_year?: string;
384
+ channel?: string;
385
+ card_type?: string;
386
+ bank?: string;
387
+ country_code?: string;
388
+ brand?: string;
389
+ reusable?: boolean;
390
+ signature?: string;
391
+ account_name?: string | null;
392
+ receiver_bank_account_number?: string | null;
393
+ receiver_bank?: string | null;
394
+ };
395
+ customer: {
396
+ id: number;
397
+ first_name: string | null;
398
+ last_name: string | null;
399
+ email: string;
400
+ customer_code: string;
401
+ phone: string | null;
402
+ metadata: Record<string, never> | null;
403
+ risk_action: string;
404
+ international_format_phone?: string | null;
405
+ };
406
+ plan: (string | Record<string, never>) | null;
407
+ split: Record<string, never> | null;
408
+ order_id: unknown;
409
+ paidAt: string | null;
410
+ createdAt: string;
411
+ requested_amount: number;
412
+ pos_transaction_data: unknown;
413
+ source: unknown;
414
+ fees_breakdown: unknown;
415
+ connect: unknown;
416
+ transaction_date: string;
417
+ plan_object: {
418
+ id?: number;
419
+ name?: string;
420
+ plan_code?: string;
421
+ description?: unknown;
422
+ amount?: number;
423
+ interval?: string;
424
+ send_invoices?: boolean;
425
+ send_sms?: boolean;
426
+ currency?: string;
427
+ };
428
+ subaccount: Record<string, never> | null;
429
+ };
430
+ }>;
431
+ listSubscriptions: StrictEndpoint<"/paystack/list-subscriptions", {
432
+ method: "GET";
433
+ query: ZodObject<{
434
+ referenceId: ZodOptional<ZodString>;
435
+ }, $strip>;
436
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
437
+ }, {
438
+ subscriptions: Subscription[];
439
+ }>;
440
+ paystackWebhook: StrictEndpoint<"/paystack/webhook", {
441
+ method: "POST";
442
+ metadata: {
443
+ openapi: {
444
+ operationId: string;
445
+ };
446
+ scope: "server";
447
+ };
448
+ cloneRequest: true;
449
+ disableBody: true;
450
+ }, {
451
+ received: boolean;
452
+ }>;
453
+ listTransactions: StrictEndpoint<"/paystack/list-transactions", {
454
+ method: "GET";
455
+ query: ZodObject<{
456
+ referenceId: ZodOptional<ZodString>;
457
+ }, $strip>;
458
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
459
+ }, {
460
+ transactions: PaystackTransaction[];
461
+ }>;
462
+ getConfig: StrictEndpoint<"/paystack/config", {
463
+ method: "GET";
464
+ metadata: {
465
+ openapi: {
466
+ operationId: string;
467
+ };
468
+ };
469
+ }, {
470
+ plans: PaystackPlan[];
471
+ products: PaystackProduct[];
472
+ }>;
473
+ disableSubscription: StrictEndpoint<"/paystack/disable-subscription", {
474
+ method: "POST";
475
+ body: ZodObject<{
476
+ referenceId: ZodOptional<ZodString>;
477
+ subscriptionCode: ZodString;
478
+ emailToken: ZodOptional<ZodString>;
479
+ atPeriodEnd: ZodOptional<ZodBoolean>;
480
+ }, $strip>;
481
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
482
+ }, {
483
+ status: string;
484
+ }>;
485
+ enableSubscription: StrictEndpoint<"/paystack/enable-subscription", {
486
+ method: "POST";
487
+ body: ZodObject<{
488
+ referenceId: ZodOptional<ZodString>;
489
+ subscriptionCode: ZodString;
490
+ emailToken: ZodOptional<ZodString>;
491
+ atPeriodEnd: ZodOptional<ZodBoolean>;
492
+ }, $strip>;
493
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
494
+ }, {
495
+ status: string;
496
+ }>;
497
+ getSubscriptionManageLink: StrictEndpoint<"/paystack/subscription-manage-link", {
498
+ method: "GET";
499
+ query: ZodObject<{
500
+ subscriptionCode: ZodString;
501
+ }, $strip>;
502
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
503
+ }, {
504
+ link: string | null;
505
+ }>;
506
+ subscriptionManageLink: StrictEndpoint<"/paystack/subscription/manage-link", {
507
+ method: "GET";
508
+ query: ZodObject<{
509
+ subscriptionCode: ZodString;
510
+ }, $strip>;
511
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
512
+ }, {
513
+ link: string | null;
514
+ }>;
515
+ createSubscription: StrictEndpoint<"/paystack/create-subscription", {
516
+ method: "POST";
517
+ body: ZodObject<{
518
+ plan: ZodOptional<ZodString>;
519
+ product: ZodOptional<ZodString>;
520
+ amount: ZodOptional<ZodNumber>;
521
+ currency: ZodOptional<ZodString>;
522
+ email: ZodOptional<ZodString>;
523
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
524
+ referenceId: ZodOptional<ZodString>;
525
+ callbackURL: ZodOptional<ZodString>;
526
+ quantity: ZodOptional<ZodNumber>;
527
+ scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
528
+ cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
529
+ prorateAndCharge: ZodOptional<ZodBoolean>;
530
+ }, $strip>;
531
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
532
+ }, {
533
+ status: string;
534
+ message: string;
535
+ scheduled: boolean;
536
+ } | {
537
+ status: string;
538
+ message: string;
539
+ prorated: boolean;
540
+ } | {
541
+ url: string;
542
+ reference: string;
543
+ accessCode: string;
544
+ redirect: boolean;
545
+ } | undefined>;
546
+ upgradeSubscription: StrictEndpoint<"/paystack/upgrade-subscription", {
547
+ method: "POST";
548
+ body: ZodObject<{
549
+ plan: ZodOptional<ZodString>;
550
+ product: ZodOptional<ZodString>;
551
+ amount: ZodOptional<ZodNumber>;
552
+ currency: ZodOptional<ZodString>;
553
+ email: ZodOptional<ZodString>;
554
+ metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
555
+ referenceId: ZodOptional<ZodString>;
556
+ callbackURL: ZodOptional<ZodString>;
557
+ quantity: ZodOptional<ZodNumber>;
558
+ scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
559
+ cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
560
+ prorateAndCharge: ZodOptional<ZodBoolean>;
561
+ }, $strip>;
562
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
563
+ }, {
564
+ status: string;
565
+ message: string;
566
+ scheduled: boolean;
567
+ } | {
568
+ status: string;
569
+ message: string;
570
+ prorated: boolean;
571
+ } | {
572
+ url: string;
573
+ reference: string;
574
+ accessCode: string;
575
+ redirect: boolean;
576
+ } | undefined>;
577
+ cancelSubscription: StrictEndpoint<"/paystack/cancel-subscription", {
578
+ method: "POST";
579
+ body: ZodObject<{
580
+ referenceId: ZodOptional<ZodString>;
581
+ subscriptionCode: ZodString;
582
+ emailToken: ZodOptional<ZodString>;
583
+ atPeriodEnd: ZodOptional<ZodBoolean>;
584
+ }, $strip>;
585
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
586
+ }, {
587
+ status: string;
588
+ }>;
589
+ restoreSubscription: StrictEndpoint<"/paystack/restore-subscription", {
590
+ method: "POST";
591
+ body: ZodObject<{
592
+ referenceId: ZodOptional<ZodString>;
593
+ subscriptionCode: ZodString;
594
+ emailToken: ZodOptional<ZodString>;
595
+ atPeriodEnd: ZodOptional<ZodBoolean>;
596
+ }, $strip>;
597
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
598
+ }, {
599
+ status: string;
600
+ }>;
601
+ listProducts: StrictEndpoint<"/paystack/list-products", {
602
+ method: "GET";
603
+ metadata: {
604
+ openapi: {
605
+ operationId: string;
606
+ };
607
+ };
608
+ }, {
609
+ products: PaystackProduct[];
610
+ }>;
611
+ listPlans: StrictEndpoint<"/paystack/list-plans", {
612
+ method: "GET";
613
+ metadata: {
614
+ scope: "server";
615
+ };
616
+ use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
617
+ session: {
618
+ session: Record<string, unknown> & {
619
+ id: string;
620
+ createdAt: Date;
621
+ updatedAt: Date;
622
+ userId: string;
623
+ expiresAt: Date;
624
+ token: string;
625
+ ipAddress?: string | null | undefined;
626
+ userAgent?: string | null | undefined;
627
+ };
628
+ user: Record<string, unknown> & {
629
+ id: string;
630
+ createdAt: Date;
631
+ updatedAt: Date;
632
+ email: string;
633
+ emailVerified: boolean;
634
+ name: string;
635
+ image?: string | null | undefined;
636
+ };
637
+ };
638
+ }>)[];
639
+ }, {
640
+ plans: PaystackPlan[];
641
+ }>;
642
+ };
643
+ schema: BetterAuthPluginDBSchema;
644
+ init: (ctx: AuthContext) => {
645
+ options: {
646
+ databaseHooks: {
647
+ user: {
648
+ create: {
649
+ after(user: {
650
+ id: string;
651
+ email?: string | null;
652
+ name?: string | null;
653
+ }, hookCtx?: GenericEndpointContext | null): Promise<void>;
654
+ };
655
+ };
656
+ organization: {
657
+ create: {
658
+ after(org: {
659
+ id: string;
660
+ name: string;
661
+ email?: string | null;
662
+ }, hookCtx: GenericEndpointContext | null): Promise<void>;
663
+ };
664
+ } | undefined;
665
+ };
666
+ member: {
667
+ create: {
668
+ before: (member: {
669
+ organizationId: string;
670
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
671
+ after: (member: {
672
+ organizationId: string | undefined;
673
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
674
+ };
675
+ delete: {
676
+ after: (member: {
677
+ organizationId: string | undefined;
678
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
679
+ };
680
+ };
681
+ invitation: {
682
+ create: {
683
+ before: (invitation: {
684
+ organizationId: string;
685
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
686
+ after: (invitation: {
687
+ organizationId: string | undefined;
688
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
689
+ };
690
+ delete: {
691
+ after: (invitation: {
692
+ organizationId: string | undefined;
693
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
694
+ };
695
+ };
696
+ team: {
697
+ create: {
698
+ before: (team: {
699
+ organizationId: string;
700
+ }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
701
+ };
702
+ };
703
+ };
704
+ };
705
+ $ERROR_CODES: Record<string, RawError<string>>;
706
+ options: NoInfer<O>;
707
+ };
708
+ type PaystackPlugin<TPaystackClient extends PaystackClientLike = PaystackClientLike, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>> = ReturnType<typeof paystack<TPaystackClient, O>>;
709
+ //#endregion
710
+ export { syncPaystackProducts as a, PaystackOptions as c, PaystackTransaction as d, Subscription as f, syncPaystackPlans as i, PaystackPlan as l, paystack as n, AnyPaystackOptions as o, SubscriptionOptions as p, chargeSubscriptionRenewal as r, PaystackClientLike as s, PaystackPlugin as t, PaystackProduct as u };
711
+ //# sourceMappingURL=index-Dwbeddkr.d.mts.map