@alexasomba/better-auth-paystack 2.2.0 → 2.4.1

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/dist/index.d.mts CHANGED
@@ -1,422 +1,393 @@
1
- import { a as PaystackOptions, c as PaystackSyncResult, d as Subscription, f as SubscriptionOptions, i as PaystackClientLike, l as PaystackTransaction, n as ChargeRecurringSubscriptionInput, o as PaystackPlan, r as ChargeRecurringSubscriptionResult, s as PaystackProduct, t as AnyPaystackOptions } from "./types-B5ZnlFrq.mjs";
2
- import { AuthContext, BetterAuthPluginDBSchema, GenericEndpointContext, MiddlewareInputContext, MiddlewareOptions, RawError, StrictEndpoint, ZodBoolean, ZodNumber, ZodObject, ZodOptional, ZodRecord, ZodString, ZodUnknown } from "better-auth";
3
- import { $strip } from "zod/v4/core";
1
+ import { a as PaystackOptions, c as PaystackSyncResult, d as Subscription, f as SubscriptionOptions, i as PaystackClientLike, l as PaystackTransaction, n as ChargeRecurringSubscriptionInput, o as PaystackPlan, p as getSchema, r as ChargeRecurringSubscriptionResult, s as PaystackProduct, t as AnyPaystackOptions } from "./types-CNI2ur0p.mjs";
2
+ import { AuthContext, BetterAuthPlugin, GenericEndpointContext, MiddlewareInputContext, MiddlewareOptions, StrictEndpoint, defineErrorCodes } from "better-auth";
3
+ import { z } from "zod";
4
4
 
5
+ //#region src/routes.d.ts
6
+ declare const paystackWebhook: <P extends string = "/webhook">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
7
+ method: "POST";
8
+ metadata: {
9
+ openapi: {
10
+ operationId: string;
11
+ };
12
+ scope: "server";
13
+ };
14
+ cloneRequest: true;
15
+ disableBody: true;
16
+ }, {
17
+ received: boolean;
18
+ }>;
19
+ declare const initializeTransaction: <P extends string = "/initialize-transaction">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
20
+ method: "POST";
21
+ body: z.ZodObject<{
22
+ plan: z.ZodOptional<z.ZodString>;
23
+ product: z.ZodOptional<z.ZodString>;
24
+ amount: z.ZodOptional<z.ZodNumber>;
25
+ currency: z.ZodOptional<z.ZodString>;
26
+ email: z.ZodOptional<z.ZodString>;
27
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
+ referenceId: z.ZodOptional<z.ZodString>;
29
+ callbackURL: z.ZodOptional<z.ZodString>;
30
+ quantity: z.ZodOptional<z.ZodNumber>;
31
+ scheduleAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
32
+ cancelAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
33
+ prorateAndCharge: z.ZodOptional<z.ZodBoolean>;
34
+ }, z.core.$strip>;
35
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
36
+ }, {
37
+ status: string;
38
+ message: string;
39
+ scheduled: boolean;
40
+ } | {
41
+ status: string;
42
+ message: string;
43
+ prorated: boolean;
44
+ } | {
45
+ url: string;
46
+ reference: string;
47
+ accessCode: string;
48
+ redirect: boolean;
49
+ } | undefined>;
50
+ declare const createSubscription: <P extends string = "/create-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
51
+ method: "POST";
52
+ body: z.ZodObject<{
53
+ plan: z.ZodOptional<z.ZodString>;
54
+ product: z.ZodOptional<z.ZodString>;
55
+ amount: z.ZodOptional<z.ZodNumber>;
56
+ currency: z.ZodOptional<z.ZodString>;
57
+ email: z.ZodOptional<z.ZodString>;
58
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
59
+ referenceId: z.ZodOptional<z.ZodString>;
60
+ callbackURL: z.ZodOptional<z.ZodString>;
61
+ quantity: z.ZodOptional<z.ZodNumber>;
62
+ scheduleAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
63
+ cancelAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
64
+ prorateAndCharge: z.ZodOptional<z.ZodBoolean>;
65
+ }, z.core.$strip>;
66
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
67
+ }, {
68
+ status: string;
69
+ message: string;
70
+ scheduled: boolean;
71
+ } | {
72
+ status: string;
73
+ message: string;
74
+ prorated: boolean;
75
+ } | {
76
+ url: string;
77
+ reference: string;
78
+ accessCode: string;
79
+ redirect: boolean;
80
+ } | undefined>;
81
+ declare const upgradeSubscription: <P extends string = "/upgrade-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
82
+ method: "POST";
83
+ body: z.ZodObject<{
84
+ plan: z.ZodOptional<z.ZodString>;
85
+ product: z.ZodOptional<z.ZodString>;
86
+ amount: z.ZodOptional<z.ZodNumber>;
87
+ currency: z.ZodOptional<z.ZodString>;
88
+ email: z.ZodOptional<z.ZodString>;
89
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
90
+ referenceId: z.ZodOptional<z.ZodString>;
91
+ callbackURL: z.ZodOptional<z.ZodString>;
92
+ quantity: z.ZodOptional<z.ZodNumber>;
93
+ scheduleAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
94
+ cancelAtPeriodEnd: z.ZodOptional<z.ZodBoolean>;
95
+ prorateAndCharge: z.ZodOptional<z.ZodBoolean>;
96
+ }, z.core.$strip>;
97
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
98
+ }, {
99
+ status: string;
100
+ message: string;
101
+ scheduled: boolean;
102
+ } | {
103
+ status: string;
104
+ message: string;
105
+ prorated: boolean;
106
+ } | {
107
+ url: string;
108
+ reference: string;
109
+ accessCode: string;
110
+ redirect: boolean;
111
+ } | undefined>;
112
+ declare const cancelSubscription: <P extends string = "/cancel-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
113
+ method: "POST";
114
+ body: z.ZodObject<{
115
+ referenceId: z.ZodOptional<z.ZodString>;
116
+ subscriptionCode: z.ZodString;
117
+ emailToken: z.ZodOptional<z.ZodString>;
118
+ atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
119
+ }, z.core.$strip>;
120
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
121
+ }, {
122
+ status: string;
123
+ }>;
124
+ declare const restoreSubscription: <P extends string = "/restore-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
125
+ method: "POST";
126
+ body: z.ZodObject<{
127
+ referenceId: z.ZodOptional<z.ZodString>;
128
+ subscriptionCode: z.ZodString;
129
+ emailToken: z.ZodOptional<z.ZodString>;
130
+ atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
131
+ }, z.core.$strip>;
132
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
133
+ }, {
134
+ status: string;
135
+ }>;
136
+ declare const verifyTransaction: <P extends string = "/verify-transaction">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
137
+ method: "POST";
138
+ body: z.ZodObject<{
139
+ reference: z.ZodString;
140
+ }, z.core.$strip>;
141
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
142
+ }, {
143
+ status: string;
144
+ reference: string;
145
+ data: {
146
+ id: number;
147
+ domain: string;
148
+ status: string;
149
+ reference: string;
150
+ receipt_number: string | null;
151
+ amount: number;
152
+ message: string | null;
153
+ gateway_response: string;
154
+ channel: string;
155
+ currency: string;
156
+ ip_address: string | null;
157
+ metadata: (string | Record<string, never> | number) | null;
158
+ log: {
159
+ start_time: number;
160
+ time_spent: number;
161
+ attempts: number;
162
+ errors: number;
163
+ success: boolean;
164
+ mobile: boolean;
165
+ input: unknown[];
166
+ history: {
167
+ type: string;
168
+ message: string;
169
+ time: number;
170
+ }[];
171
+ } | null;
172
+ fees: number | null;
173
+ fees_split: unknown;
174
+ authorization: {
175
+ authorization_code?: string;
176
+ bin?: string | null;
177
+ last4?: string;
178
+ exp_month?: string;
179
+ exp_year?: string;
180
+ channel?: string;
181
+ card_type?: string;
182
+ bank?: string;
183
+ country_code?: string;
184
+ brand?: string;
185
+ reusable?: boolean;
186
+ signature?: string;
187
+ account_name?: string | null;
188
+ receiver_bank_account_number?: string | null;
189
+ receiver_bank?: string | null;
190
+ };
191
+ customer: {
192
+ id: number;
193
+ first_name: string | null;
194
+ last_name: string | null;
195
+ email: string;
196
+ customer_code: string;
197
+ phone: string | null;
198
+ metadata: Record<string, never> | null;
199
+ risk_action: string;
200
+ international_format_phone?: string | null;
201
+ };
202
+ plan: (string | Record<string, never>) | null;
203
+ split: Record<string, never> | null;
204
+ order_id: unknown;
205
+ paidAt: string | null;
206
+ createdAt: string;
207
+ requested_amount: number;
208
+ pos_transaction_data: unknown;
209
+ source: unknown;
210
+ fees_breakdown: unknown;
211
+ connect: unknown;
212
+ transaction_date: string;
213
+ plan_object: {
214
+ id?: number;
215
+ name?: string;
216
+ plan_code?: string;
217
+ description?: unknown;
218
+ amount?: number;
219
+ interval?: string;
220
+ send_invoices?: boolean;
221
+ send_sms?: boolean;
222
+ currency?: string;
223
+ };
224
+ subaccount: Record<string, never> | null;
225
+ };
226
+ }>;
227
+ declare const listSubscriptions: <P extends string = "/list-subscriptions">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
228
+ method: "GET";
229
+ query: z.ZodObject<{
230
+ referenceId: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$strip>;
232
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
233
+ }, {
234
+ subscriptions: Subscription[];
235
+ }>;
236
+ declare const listTransactions: <P extends string = "/list-transactions">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
237
+ method: "GET";
238
+ query: z.ZodObject<{
239
+ referenceId: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strip>;
241
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
242
+ }, {
243
+ transactions: PaystackTransaction[];
244
+ }>;
245
+ declare const disablePaystackSubscription: <P extends string = "/disable-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
246
+ method: "POST";
247
+ body: z.ZodObject<{
248
+ referenceId: z.ZodOptional<z.ZodString>;
249
+ subscriptionCode: z.ZodString;
250
+ emailToken: z.ZodOptional<z.ZodString>;
251
+ atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
252
+ }, z.core.$strip>;
253
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
254
+ }, {
255
+ status: string;
256
+ }>;
257
+ declare const enablePaystackSubscription: <P extends string = "/enable-subscription">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
258
+ method: "POST";
259
+ body: z.ZodObject<{
260
+ referenceId: z.ZodOptional<z.ZodString>;
261
+ subscriptionCode: z.ZodString;
262
+ emailToken: z.ZodOptional<z.ZodString>;
263
+ atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
264
+ }, z.core.$strip>;
265
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
266
+ }, {
267
+ status: string;
268
+ }>;
269
+ declare const getSubscriptionManageLink: <P extends string = "/subscription-manage-link">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
270
+ method: "GET";
271
+ query: z.ZodObject<{
272
+ subscriptionCode: z.ZodString;
273
+ }, z.core.$strip>;
274
+ use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
275
+ }, {
276
+ link: string | null;
277
+ }>;
278
+ declare const listProducts: <P extends string = "/list-products">(_options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
279
+ method: "GET";
280
+ metadata: {
281
+ openapi: {
282
+ operationId: string;
283
+ };
284
+ };
285
+ }, {
286
+ products: PaystackProduct[];
287
+ }>;
288
+ declare const listPlans: <P extends string = "/list-plans">(_options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
289
+ method: "GET";
290
+ metadata: {
291
+ scope: "server";
292
+ };
293
+ use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
294
+ session: {
295
+ session: Record<string, unknown> & {
296
+ id: string;
297
+ createdAt: Date;
298
+ updatedAt: Date;
299
+ userId: string;
300
+ expiresAt: Date;
301
+ token: string;
302
+ ipAddress?: string | null | undefined;
303
+ userAgent?: string | null | undefined;
304
+ };
305
+ user: Record<string, unknown> & {
306
+ id: string;
307
+ createdAt: Date;
308
+ updatedAt: Date;
309
+ email: string;
310
+ emailVerified: boolean;
311
+ name: string;
312
+ image?: string | null | undefined;
313
+ };
314
+ };
315
+ }>)[];
316
+ }, {
317
+ plans: PaystackPlan[];
318
+ }>;
319
+ declare const getConfig: <P extends string = "/get-config">(options: AnyPaystackOptions, path?: P) => StrictEndpoint<P, {
320
+ method: "GET";
321
+ metadata: {
322
+ openapi: {
323
+ operationId: string;
324
+ };
325
+ };
326
+ }, {
327
+ plans: PaystackPlan[];
328
+ products: PaystackProduct[];
329
+ }>;
330
+ //#endregion
331
+ //#region src/version.d.ts
332
+ declare const PACKAGE_VERSION = "2.4.1";
333
+ //#endregion
5
334
  //#region src/operations.d.ts
6
335
  declare function syncPaystackProducts(ctx: GenericEndpointContext, options: AnyPaystackOptions): Promise<PaystackSyncResult>;
7
336
  declare function syncPaystackPlans(ctx: GenericEndpointContext, options: AnyPaystackOptions): Promise<PaystackSyncResult>;
8
337
  declare function chargeSubscriptionRenewal(ctx: GenericEndpointContext, options: AnyPaystackOptions, input: ChargeRecurringSubscriptionInput): Promise<ChargeRecurringSubscriptionResult>;
9
338
  //#endregion
10
339
  //#region src/index.d.ts
11
- declare module "@better-auth/core" {
340
+ declare module "better-auth" {
12
341
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
13
342
  paystack: {
14
343
  creator: typeof paystack;
15
344
  };
16
345
  }
17
346
  }
18
- declare const paystack: <TPaystackClient extends PaystackClientLike = PaystackClientLike, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>>(options: O) => {
19
- id: "paystack";
20
- endpoints: {
21
- initializeTransaction: StrictEndpoint<"/paystack/initialize-transaction", {
22
- method: "POST";
23
- body: ZodObject<{
24
- plan: ZodOptional<ZodString>;
25
- product: ZodOptional<ZodString>;
26
- amount: ZodOptional<ZodNumber>;
27
- currency: ZodOptional<ZodString>;
28
- email: ZodOptional<ZodString>;
29
- metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
30
- referenceId: ZodOptional<ZodString>;
31
- callbackURL: ZodOptional<ZodString>;
32
- quantity: ZodOptional<ZodNumber>;
33
- scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
34
- cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
35
- prorateAndCharge: ZodOptional<ZodBoolean>;
36
- }, $strip>;
37
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
38
- }, {
39
- status: string;
40
- message: string;
41
- scheduled: boolean;
42
- } | {
43
- status: string;
44
- message: string;
45
- prorated: boolean;
46
- } | {
47
- url: string;
48
- reference: string;
49
- accessCode: string;
50
- redirect: boolean;
51
- } | undefined>;
52
- verifyTransaction: StrictEndpoint<"/paystack/verify-transaction", {
53
- method: "POST";
54
- body: ZodObject<{
55
- reference: ZodString;
56
- }, $strip>;
57
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
58
- }, {
59
- status: string;
60
- reference: string;
61
- data: {
62
- id: number;
63
- domain: string;
64
- status: string;
65
- reference: string;
66
- receipt_number: string | null;
67
- amount: number;
68
- message: string | null;
69
- gateway_response: string;
70
- channel: string;
71
- currency: string;
72
- ip_address: string | null;
73
- metadata: (string | Record<string, never> | number) | null;
74
- log: {
75
- start_time: number;
76
- time_spent: number;
77
- attempts: number;
78
- errors: number;
79
- success: boolean;
80
- mobile: boolean;
81
- input: unknown[];
82
- history: {
83
- type: string;
84
- message: string;
85
- time: number;
86
- }[];
87
- } | null;
88
- fees: number | null;
89
- fees_split: unknown;
90
- authorization: {
91
- authorization_code?: string;
92
- bin?: string | null;
93
- last4?: string;
94
- exp_month?: string;
95
- exp_year?: string;
96
- channel?: string;
97
- card_type?: string;
98
- bank?: string;
99
- country_code?: string;
100
- brand?: string;
101
- reusable?: boolean;
102
- signature?: string;
103
- account_name?: string | null;
104
- receiver_bank_account_number?: string | null;
105
- receiver_bank?: string | null;
106
- };
107
- customer: {
108
- id: number;
109
- first_name: string | null;
110
- last_name: string | null;
111
- email: string;
112
- customer_code: string;
113
- phone: string | null;
114
- metadata: Record<string, never> | null;
115
- risk_action: string;
116
- international_format_phone?: string | null;
117
- };
118
- plan: (string | Record<string, never>) | null;
119
- split: Record<string, never> | null;
120
- order_id: unknown;
121
- paidAt: string | null;
122
- createdAt: string;
123
- requested_amount: number;
124
- pos_transaction_data: unknown;
125
- source: unknown;
126
- fees_breakdown: unknown;
127
- connect: unknown;
128
- transaction_date: string;
129
- plan_object: {
130
- id?: number;
131
- name?: string;
132
- plan_code?: string;
133
- description?: unknown;
134
- amount?: number;
135
- interval?: string;
136
- send_invoices?: boolean;
137
- send_sms?: boolean;
138
- currency?: string;
139
- };
140
- subaccount: Record<string, never> | null;
141
- };
142
- }>;
143
- listSubscriptions: StrictEndpoint<"/paystack/list-subscriptions", {
144
- method: "GET";
145
- query: ZodObject<{
146
- referenceId: ZodOptional<ZodString>;
147
- }, $strip>;
148
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
149
- }, {
150
- subscriptions: Subscription[];
151
- }>;
152
- paystackWebhook: StrictEndpoint<"/paystack/webhook", {
153
- method: "POST";
154
- metadata: {
155
- openapi: {
156
- operationId: string;
157
- };
158
- scope: "server";
159
- };
160
- cloneRequest: true;
161
- disableBody: true;
162
- }, {
163
- received: boolean;
164
- }>;
165
- listTransactions: StrictEndpoint<"/paystack/list-transactions", {
166
- method: "GET";
167
- query: ZodObject<{
168
- referenceId: ZodOptional<ZodString>;
169
- }, $strip>;
170
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
171
- }, {
172
- transactions: PaystackTransaction[];
173
- }>;
174
- getConfig: StrictEndpoint<"/paystack/config", {
175
- method: "GET";
176
- metadata: {
177
- openapi: {
178
- operationId: string;
179
- };
180
- };
181
- }, {
182
- plans: PaystackPlan[];
183
- products: PaystackProduct[];
184
- }>;
185
- disableSubscription: StrictEndpoint<"/paystack/disable-subscription", {
186
- method: "POST";
187
- body: ZodObject<{
188
- referenceId: ZodOptional<ZodString>;
189
- subscriptionCode: ZodString;
190
- emailToken: ZodOptional<ZodString>;
191
- atPeriodEnd: ZodOptional<ZodBoolean>;
192
- }, $strip>;
193
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
194
- }, {
195
- status: string;
196
- }>;
197
- enableSubscription: StrictEndpoint<"/paystack/enable-subscription", {
198
- method: "POST";
199
- body: ZodObject<{
200
- referenceId: ZodOptional<ZodString>;
201
- subscriptionCode: ZodString;
202
- emailToken: ZodOptional<ZodString>;
203
- atPeriodEnd: ZodOptional<ZodBoolean>;
204
- }, $strip>;
205
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
206
- }, {
207
- status: string;
208
- }>;
209
- getSubscriptionManageLink: StrictEndpoint<"/paystack/subscription-manage-link", {
210
- method: "GET";
211
- query: ZodObject<{
212
- subscriptionCode: ZodString;
213
- }, $strip>;
214
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
215
- }, {
216
- link: string | null;
217
- }>;
218
- subscriptionManageLink: StrictEndpoint<"/paystack/subscription/manage-link", {
219
- method: "GET";
220
- query: ZodObject<{
221
- subscriptionCode: ZodString;
222
- }, $strip>;
223
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
224
- }, {
225
- link: string | null;
226
- }>;
227
- createSubscription: StrictEndpoint<"/paystack/create-subscription", {
228
- method: "POST";
229
- body: ZodObject<{
230
- plan: ZodOptional<ZodString>;
231
- product: ZodOptional<ZodString>;
232
- amount: ZodOptional<ZodNumber>;
233
- currency: ZodOptional<ZodString>;
234
- email: ZodOptional<ZodString>;
235
- metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
236
- referenceId: ZodOptional<ZodString>;
237
- callbackURL: ZodOptional<ZodString>;
238
- quantity: ZodOptional<ZodNumber>;
239
- scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
240
- cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
241
- prorateAndCharge: ZodOptional<ZodBoolean>;
242
- }, $strip>;
243
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
244
- }, {
245
- status: string;
246
- message: string;
247
- scheduled: boolean;
248
- } | {
249
- status: string;
250
- message: string;
251
- prorated: boolean;
252
- } | {
253
- url: string;
254
- reference: string;
255
- accessCode: string;
256
- redirect: boolean;
257
- } | undefined>;
258
- upgradeSubscription: StrictEndpoint<"/paystack/upgrade-subscription", {
259
- method: "POST";
260
- body: ZodObject<{
261
- plan: ZodOptional<ZodString>;
262
- product: ZodOptional<ZodString>;
263
- amount: ZodOptional<ZodNumber>;
264
- currency: ZodOptional<ZodString>;
265
- email: ZodOptional<ZodString>;
266
- metadata: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
267
- referenceId: ZodOptional<ZodString>;
268
- callbackURL: ZodOptional<ZodString>;
269
- quantity: ZodOptional<ZodNumber>;
270
- scheduleAtPeriodEnd: ZodOptional<ZodBoolean>;
271
- cancelAtPeriodEnd: ZodOptional<ZodBoolean>;
272
- prorateAndCharge: ZodOptional<ZodBoolean>;
273
- }, $strip>;
274
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
275
- }, {
276
- status: string;
277
- message: string;
278
- scheduled: boolean;
279
- } | {
280
- status: string;
281
- message: string;
282
- prorated: boolean;
283
- } | {
284
- url: string;
285
- reference: string;
286
- accessCode: string;
287
- redirect: boolean;
288
- } | undefined>;
289
- cancelSubscription: StrictEndpoint<"/paystack/cancel-subscription", {
290
- method: "POST";
291
- body: ZodObject<{
292
- referenceId: ZodOptional<ZodString>;
293
- subscriptionCode: ZodString;
294
- emailToken: ZodOptional<ZodString>;
295
- atPeriodEnd: ZodOptional<ZodBoolean>;
296
- }, $strip>;
297
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
298
- }, {
299
- status: string;
300
- }>;
301
- restoreSubscription: StrictEndpoint<"/paystack/restore-subscription", {
302
- method: "POST";
303
- body: ZodObject<{
304
- referenceId: ZodOptional<ZodString>;
305
- subscriptionCode: ZodString;
306
- emailToken: ZodOptional<ZodString>;
307
- atPeriodEnd: ZodOptional<ZodBoolean>;
308
- }, $strip>;
309
- use: (((getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>) | ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>))[];
310
- }, {
311
- status: string;
312
- }>;
313
- listProducts: StrictEndpoint<"/paystack/list-products", {
314
- method: "GET";
315
- metadata: {
316
- openapi: {
317
- operationId: string;
318
- };
319
- };
320
- }, {
321
- products: PaystackProduct[];
322
- }>;
323
- listPlans: StrictEndpoint<"/paystack/list-plans", {
324
- method: "GET";
325
- metadata: {
326
- scope: "server";
327
- };
328
- use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
329
- session: {
330
- session: Record<string, unknown> & {
331
- id: string;
332
- createdAt: Date;
333
- updatedAt: Date;
334
- userId: string;
335
- expiresAt: Date;
336
- token: string;
337
- ipAddress?: string | null | undefined;
338
- userAgent?: string | null | undefined;
339
- };
340
- user: Record<string, unknown> & {
341
- id: string;
342
- createdAt: Date;
343
- updatedAt: Date;
344
- email: string;
345
- emailVerified: boolean;
346
- name: string;
347
- image?: string | null | undefined;
348
- };
349
- };
350
- }>)[];
351
- }, {
352
- plans: PaystackPlan[];
353
- }>;
354
- };
355
- schema: BetterAuthPluginDBSchema;
356
- init: (ctx: AuthContext) => {
357
- options: {
358
- databaseHooks: {
359
- user: {
360
- create: {
361
- after(user: {
362
- id: string;
363
- email?: string | null;
364
- name?: string | null;
365
- }, hookCtx?: GenericEndpointContext | null): Promise<void>;
366
- };
367
- };
368
- organization: {
369
- create: {
370
- after(org: {
371
- id: string;
372
- name: string;
373
- email?: string | null;
374
- }, hookCtx: GenericEndpointContext | null): Promise<void>;
375
- };
376
- } | undefined;
377
- };
378
- member: {
379
- create: {
380
- before: (member: {
381
- organizationId: string;
382
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
383
- after: (member: {
384
- organizationId: string | undefined;
385
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
386
- };
387
- delete: {
388
- after: (member: {
389
- organizationId: string | undefined;
390
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
391
- };
392
- };
393
- invitation: {
394
- create: {
395
- before: (invitation: {
396
- organizationId: string;
397
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
398
- after: (invitation: {
399
- organizationId: string | undefined;
400
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
401
- };
402
- delete: {
403
- after: (invitation: {
404
- organizationId: string | undefined;
405
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
406
- };
407
- };
408
- team: {
347
+ declare const INTERNAL_ERROR_CODES: ReturnType<typeof defineErrorCodes>;
348
+ type BetterAuthEndpoint = NonNullable<BetterAuthPlugin["endpoints"]>[string];
349
+ interface PaystackPluginEndpoints extends Record<string, BetterAuthEndpoint> {
350
+ initializeTransaction: ReturnType<typeof initializeTransaction>;
351
+ verifyTransaction: ReturnType<typeof verifyTransaction>;
352
+ listSubscriptions: ReturnType<typeof listSubscriptions>;
353
+ paystackWebhook: ReturnType<typeof paystackWebhook>;
354
+ listTransactions: ReturnType<typeof listTransactions>;
355
+ getConfig: ReturnType<typeof getConfig>;
356
+ disableSubscription: ReturnType<typeof disablePaystackSubscription>;
357
+ enableSubscription: ReturnType<typeof enablePaystackSubscription>;
358
+ getSubscriptionManageLink: ReturnType<typeof getSubscriptionManageLink>;
359
+ subscriptionManageLink: ReturnType<typeof getSubscriptionManageLink>;
360
+ createSubscription: ReturnType<typeof createSubscription>;
361
+ upgradeSubscription: ReturnType<typeof upgradeSubscription>;
362
+ cancelSubscription: ReturnType<typeof cancelSubscription>;
363
+ restoreSubscription: ReturnType<typeof restoreSubscription>;
364
+ listProducts: ReturnType<typeof listProducts>;
365
+ listPlans: ReturnType<typeof listPlans>;
366
+ }
367
+ type PaystackHookHandler = (...args: unknown[]) => unknown;
368
+ interface PaystackPluginInitResult {
369
+ options: {
370
+ databaseHooks: Record<string, unknown> & {
371
+ organization: {
409
372
  create: {
410
- before: (team: {
411
- organizationId: string;
412
- }, ctx: GenericEndpointContext | null | undefined) => Promise<void>;
373
+ after: PaystackHookHandler;
413
374
  };
414
375
  };
415
376
  };
416
377
  };
417
- $ERROR_CODES: Record<string, RawError<string>>;
378
+ }
379
+ type PaystackPluginInit = ((ctx: AuthContext) => PaystackPluginInitResult) & NonNullable<BetterAuthPlugin["init"]>;
380
+ type PaystackPluginInstance<O extends AnyPaystackOptions> = Omit<BetterAuthPlugin, "id" | "version" | "endpoints" | "schema" | "init" | "$ERROR_CODES" | "options"> & {
381
+ id: "paystack";
382
+ version: typeof PACKAGE_VERSION;
383
+ endpoints: PaystackPluginEndpoints;
384
+ schema: ReturnType<typeof getSchema>;
385
+ init: PaystackPluginInit;
386
+ $ERROR_CODES: typeof INTERNAL_ERROR_CODES;
418
387
  options: NoInfer<O>;
419
388
  };
389
+ declare const createPaystackPlugin: <TPaystackClient extends PaystackClientLike = PaystackClientLike, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>>(options: O) => PaystackPluginInstance<O>;
390
+ declare const paystack: typeof createPaystackPlugin;
420
391
  type PaystackPlugin<TPaystackClient extends PaystackClientLike = PaystackClientLike, O extends PaystackOptions<TPaystackClient> = PaystackOptions<TPaystackClient>> = ReturnType<typeof paystack<TPaystackClient, O>>;
421
392
  //#endregion
422
393
  export { type ChargeRecurringSubscriptionResult, type PaystackClientLike, type PaystackOptions, type PaystackPlan, PaystackPlugin, type PaystackProduct, type PaystackSyncResult, type Subscription, type SubscriptionOptions, chargeSubscriptionRenewal, paystack, syncPaystackPlans, syncPaystackProducts };