@dodopayments/better-auth 1.4.0 → 1.4.2

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,701 @@
1
+ import DodoPayments, { DodoPayments as DodoPayments$1 } from 'dodopayments';
2
+ import * as better_auth from 'better-auth';
3
+ import { UnionToIntersection } from 'better-auth';
4
+ import { z } from 'zod/v3';
5
+ import { WebhookHandlerConfig } from '@dodopayments/core/webhook';
6
+ import { usage } from './plugins/usage.cjs';
7
+
8
+ interface CheckoutOptions {
9
+ /**
10
+ * Optional list of slug -> productId mappings for easy slug checkouts
11
+ */
12
+ products?: Product[] | (() => Promise<Product[]>);
13
+ /**
14
+ * Checkout Success URL
15
+ */
16
+ successUrl?: string;
17
+ /**
18
+ * Only allow authenticated customers to checkout
19
+ */
20
+ authenticatedUsersOnly?: boolean;
21
+ }
22
+ declare const checkout: (checkoutOptions?: CheckoutOptions) => (dodopayments: DodoPayments) => {
23
+ /**
24
+ * @deprecated
25
+ */
26
+ dodoCheckout: better_auth.StrictEndpoint<"/dodopayments/checkout", {
27
+ method: "POST";
28
+ body: z.ZodObject<{
29
+ product_id: z.ZodOptional<z.ZodString>;
30
+ quantity: z.ZodOptional<z.ZodNumber>;
31
+ product_cart: z.ZodOptional<z.ZodArray<z.ZodObject<{
32
+ product_id: z.ZodString;
33
+ quantity: z.ZodNumber;
34
+ }, "strip", z.ZodTypeAny, {
35
+ quantity: number;
36
+ product_id: string;
37
+ }, {
38
+ quantity: number;
39
+ product_id: string;
40
+ }>, "many">>;
41
+ billing: z.ZodObject<{
42
+ city: z.ZodString;
43
+ country: z.ZodString;
44
+ state: z.ZodString;
45
+ street: z.ZodString;
46
+ zipcode: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ country: string;
49
+ city: string;
50
+ state: string;
51
+ street: string;
52
+ zipcode: string;
53
+ }, {
54
+ country: string;
55
+ city: string;
56
+ state: string;
57
+ street: string;
58
+ zipcode: string;
59
+ }>;
60
+ customer: z.ZodObject<{
61
+ customer_id: z.ZodOptional<z.ZodString>;
62
+ email: z.ZodOptional<z.ZodString>;
63
+ name: z.ZodOptional<z.ZodString>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ email?: string | undefined;
66
+ customer_id?: string | undefined;
67
+ name?: string | undefined;
68
+ }, {
69
+ email?: string | undefined;
70
+ customer_id?: string | undefined;
71
+ name?: string | undefined;
72
+ }>;
73
+ discount_id: z.ZodOptional<z.ZodString>;
74
+ addons: z.ZodOptional<z.ZodArray<z.ZodObject<{
75
+ addon_id: z.ZodString;
76
+ quantity: z.ZodNumber;
77
+ }, "strip", z.ZodTypeAny, {
78
+ quantity: number;
79
+ addon_id: string;
80
+ }, {
81
+ quantity: number;
82
+ addon_id: string;
83
+ }>, "many">>;
84
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
85
+ currency: z.ZodOptional<z.ZodString>;
86
+ } & {
87
+ slug: z.ZodOptional<z.ZodString>;
88
+ referenceId: z.ZodOptional<z.ZodString>;
89
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
90
+ product_id: z.ZodOptional<z.ZodString>;
91
+ quantity: z.ZodOptional<z.ZodNumber>;
92
+ product_cart: z.ZodOptional<z.ZodArray<z.ZodObject<{
93
+ product_id: z.ZodString;
94
+ quantity: z.ZodNumber;
95
+ }, "strip", z.ZodTypeAny, {
96
+ quantity: number;
97
+ product_id: string;
98
+ }, {
99
+ quantity: number;
100
+ product_id: string;
101
+ }>, "many">>;
102
+ billing: z.ZodObject<{
103
+ city: z.ZodString;
104
+ country: z.ZodString;
105
+ state: z.ZodString;
106
+ street: z.ZodString;
107
+ zipcode: z.ZodString;
108
+ }, "strip", z.ZodTypeAny, {
109
+ country: string;
110
+ city: string;
111
+ state: string;
112
+ street: string;
113
+ zipcode: string;
114
+ }, {
115
+ country: string;
116
+ city: string;
117
+ state: string;
118
+ street: string;
119
+ zipcode: string;
120
+ }>;
121
+ customer: z.ZodObject<{
122
+ customer_id: z.ZodOptional<z.ZodString>;
123
+ email: z.ZodOptional<z.ZodString>;
124
+ name: z.ZodOptional<z.ZodString>;
125
+ }, "strip", z.ZodTypeAny, {
126
+ email?: string | undefined;
127
+ customer_id?: string | undefined;
128
+ name?: string | undefined;
129
+ }, {
130
+ email?: string | undefined;
131
+ customer_id?: string | undefined;
132
+ name?: string | undefined;
133
+ }>;
134
+ discount_id: z.ZodOptional<z.ZodString>;
135
+ addons: z.ZodOptional<z.ZodArray<z.ZodObject<{
136
+ addon_id: z.ZodString;
137
+ quantity: z.ZodNumber;
138
+ }, "strip", z.ZodTypeAny, {
139
+ quantity: number;
140
+ addon_id: string;
141
+ }, {
142
+ quantity: number;
143
+ addon_id: string;
144
+ }>, "many">>;
145
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
146
+ currency: z.ZodOptional<z.ZodString>;
147
+ } & {
148
+ slug: z.ZodOptional<z.ZodString>;
149
+ referenceId: z.ZodOptional<z.ZodString>;
150
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
151
+ product_id: z.ZodOptional<z.ZodString>;
152
+ quantity: z.ZodOptional<z.ZodNumber>;
153
+ product_cart: z.ZodOptional<z.ZodArray<z.ZodObject<{
154
+ product_id: z.ZodString;
155
+ quantity: z.ZodNumber;
156
+ }, "strip", z.ZodTypeAny, {
157
+ quantity: number;
158
+ product_id: string;
159
+ }, {
160
+ quantity: number;
161
+ product_id: string;
162
+ }>, "many">>;
163
+ billing: z.ZodObject<{
164
+ city: z.ZodString;
165
+ country: z.ZodString;
166
+ state: z.ZodString;
167
+ street: z.ZodString;
168
+ zipcode: z.ZodString;
169
+ }, "strip", z.ZodTypeAny, {
170
+ country: string;
171
+ city: string;
172
+ state: string;
173
+ street: string;
174
+ zipcode: string;
175
+ }, {
176
+ country: string;
177
+ city: string;
178
+ state: string;
179
+ street: string;
180
+ zipcode: string;
181
+ }>;
182
+ customer: z.ZodObject<{
183
+ customer_id: z.ZodOptional<z.ZodString>;
184
+ email: z.ZodOptional<z.ZodString>;
185
+ name: z.ZodOptional<z.ZodString>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ email?: string | undefined;
188
+ customer_id?: string | undefined;
189
+ name?: string | undefined;
190
+ }, {
191
+ email?: string | undefined;
192
+ customer_id?: string | undefined;
193
+ name?: string | undefined;
194
+ }>;
195
+ discount_id: z.ZodOptional<z.ZodString>;
196
+ addons: z.ZodOptional<z.ZodArray<z.ZodObject<{
197
+ addon_id: z.ZodString;
198
+ quantity: z.ZodNumber;
199
+ }, "strip", z.ZodTypeAny, {
200
+ quantity: number;
201
+ addon_id: string;
202
+ }, {
203
+ quantity: number;
204
+ addon_id: string;
205
+ }>, "many">>;
206
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
207
+ currency: z.ZodOptional<z.ZodString>;
208
+ } & {
209
+ slug: z.ZodOptional<z.ZodString>;
210
+ referenceId: z.ZodOptional<z.ZodString>;
211
+ }, z.ZodUnknown, "strip">>;
212
+ requireRequest: true;
213
+ } & {
214
+ use: any[];
215
+ }, CreateCheckoutResponse>;
216
+ dodoCheckoutSession: better_auth.StrictEndpoint<"/dodopayments/checkout-session", {
217
+ method: "POST";
218
+ body: z.ZodObject<{
219
+ product_cart: z.ZodOptional<z.ZodArray<z.ZodObject<{
220
+ product_id: z.ZodString;
221
+ quantity: z.ZodNumber;
222
+ addons: z.ZodOptional<z.ZodArray<z.ZodObject<{
223
+ addon_id: z.ZodString;
224
+ quantity: z.ZodNumber;
225
+ }, "strip", z.ZodTypeAny, {
226
+ quantity: number;
227
+ addon_id: string;
228
+ }, {
229
+ quantity: number;
230
+ addon_id: string;
231
+ }>, "many">>;
232
+ amount: z.ZodOptional<z.ZodNumber>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ quantity: number;
235
+ product_id: string;
236
+ addons?: {
237
+ quantity: number;
238
+ addon_id: string;
239
+ }[] | undefined;
240
+ amount?: number | undefined;
241
+ }, {
242
+ quantity: number;
243
+ product_id: string;
244
+ addons?: {
245
+ quantity: number;
246
+ addon_id: string;
247
+ }[] | undefined;
248
+ amount?: number | undefined;
249
+ }>, "many">>;
250
+ customer: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
251
+ email: z.ZodString;
252
+ name: z.ZodOptional<z.ZodString>;
253
+ phone_number: z.ZodOptional<z.ZodString>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ email: string;
256
+ name?: string | undefined;
257
+ phone_number?: string | undefined;
258
+ }, {
259
+ email: string;
260
+ name?: string | undefined;
261
+ phone_number?: string | undefined;
262
+ }>, z.ZodObject<{
263
+ customer_id: z.ZodString;
264
+ }, "strip", z.ZodTypeAny, {
265
+ customer_id: string;
266
+ }, {
267
+ customer_id: string;
268
+ }>]>>;
269
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
270
+ slug: z.ZodOptional<z.ZodString>;
271
+ referenceId: z.ZodOptional<z.ZodString>;
272
+ billing_address: z.ZodOptional<z.ZodObject<{
273
+ street: z.ZodOptional<z.ZodString>;
274
+ city: z.ZodOptional<z.ZodString>;
275
+ state: z.ZodOptional<z.ZodString>;
276
+ country: z.ZodString;
277
+ zipcode: z.ZodOptional<z.ZodString>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ country: string;
280
+ city?: string | undefined;
281
+ state?: string | undefined;
282
+ street?: string | undefined;
283
+ zipcode?: string | undefined;
284
+ }, {
285
+ country: string;
286
+ city?: string | undefined;
287
+ state?: string | undefined;
288
+ street?: string | undefined;
289
+ zipcode?: string | undefined;
290
+ }>>;
291
+ return_url: z.ZodOptional<z.ZodString>;
292
+ allowed_payment_method_types: z.ZodOptional<z.ZodArray<z.ZodEnum<["credit", "debit", "upi_collect", "upi_intent", "apple_pay", "cashapp", "google_pay", "multibanco", "bancontact_card", "eps", "ideal", "przelewy24", "paypal", "affirm", "klarna", "sepa", "ach", "amazon_pay", "afterpay_clearpay"]>, "many">>;
293
+ billing_currency: z.ZodOptional<z.ZodString>;
294
+ show_saved_payment_methods: z.ZodOptional<z.ZodBoolean>;
295
+ confirm: z.ZodOptional<z.ZodBoolean>;
296
+ discount_code: z.ZodOptional<z.ZodString>;
297
+ customization: z.ZodOptional<z.ZodObject<{
298
+ theme: z.ZodOptional<z.ZodEnum<["light", "dark", "system"]>>;
299
+ show_order_details: z.ZodOptional<z.ZodBoolean>;
300
+ show_on_demand_tag: z.ZodOptional<z.ZodBoolean>;
301
+ force_language: z.ZodOptional<z.ZodString>;
302
+ }, "strip", z.ZodTypeAny, {
303
+ theme?: "light" | "dark" | "system" | undefined;
304
+ show_order_details?: boolean | undefined;
305
+ show_on_demand_tag?: boolean | undefined;
306
+ force_language?: string | undefined;
307
+ }, {
308
+ theme?: "light" | "dark" | "system" | undefined;
309
+ show_order_details?: boolean | undefined;
310
+ show_on_demand_tag?: boolean | undefined;
311
+ force_language?: string | undefined;
312
+ }>>;
313
+ feature_flags: z.ZodOptional<z.ZodObject<{
314
+ allow_currency_selection: z.ZodOptional<z.ZodBoolean>;
315
+ allow_customer_editing_city: z.ZodOptional<z.ZodBoolean>;
316
+ allow_customer_editing_country: z.ZodOptional<z.ZodBoolean>;
317
+ allow_customer_editing_email: z.ZodOptional<z.ZodBoolean>;
318
+ allow_customer_editing_name: z.ZodOptional<z.ZodBoolean>;
319
+ allow_customer_editing_state: z.ZodOptional<z.ZodBoolean>;
320
+ allow_customer_editing_street: z.ZodOptional<z.ZodBoolean>;
321
+ allow_customer_editing_zipcode: z.ZodOptional<z.ZodBoolean>;
322
+ allow_discount_code: z.ZodOptional<z.ZodBoolean>;
323
+ allow_phone_number_collection: z.ZodOptional<z.ZodBoolean>;
324
+ allow_tax_id: z.ZodOptional<z.ZodBoolean>;
325
+ always_create_new_customer: z.ZodOptional<z.ZodBoolean>;
326
+ }, "strip", z.ZodTypeAny, {
327
+ allow_currency_selection?: boolean | undefined;
328
+ allow_customer_editing_city?: boolean | undefined;
329
+ allow_customer_editing_country?: boolean | undefined;
330
+ allow_customer_editing_email?: boolean | undefined;
331
+ allow_customer_editing_name?: boolean | undefined;
332
+ allow_customer_editing_state?: boolean | undefined;
333
+ allow_customer_editing_street?: boolean | undefined;
334
+ allow_customer_editing_zipcode?: boolean | undefined;
335
+ allow_discount_code?: boolean | undefined;
336
+ allow_phone_number_collection?: boolean | undefined;
337
+ allow_tax_id?: boolean | undefined;
338
+ always_create_new_customer?: boolean | undefined;
339
+ }, {
340
+ allow_currency_selection?: boolean | undefined;
341
+ allow_customer_editing_city?: boolean | undefined;
342
+ allow_customer_editing_country?: boolean | undefined;
343
+ allow_customer_editing_email?: boolean | undefined;
344
+ allow_customer_editing_name?: boolean | undefined;
345
+ allow_customer_editing_state?: boolean | undefined;
346
+ allow_customer_editing_street?: boolean | undefined;
347
+ allow_customer_editing_zipcode?: boolean | undefined;
348
+ allow_discount_code?: boolean | undefined;
349
+ allow_phone_number_collection?: boolean | undefined;
350
+ allow_tax_id?: boolean | undefined;
351
+ always_create_new_customer?: boolean | undefined;
352
+ }>>;
353
+ subscription_data: z.ZodOptional<z.ZodObject<{
354
+ trial_period_days: z.ZodOptional<z.ZodNumber>;
355
+ on_demand: z.ZodOptional<z.ZodObject<{
356
+ mandate_only: z.ZodBoolean;
357
+ product_price: z.ZodOptional<z.ZodNumber>;
358
+ product_currency: z.ZodOptional<z.ZodString>;
359
+ product_description: z.ZodOptional<z.ZodString>;
360
+ adaptive_currency_fees_inclusive: z.ZodOptional<z.ZodBoolean>;
361
+ }, "strip", z.ZodTypeAny, {
362
+ mandate_only: boolean;
363
+ product_price?: number | undefined;
364
+ product_currency?: string | undefined;
365
+ product_description?: string | undefined;
366
+ adaptive_currency_fees_inclusive?: boolean | undefined;
367
+ }, {
368
+ mandate_only: boolean;
369
+ product_price?: number | undefined;
370
+ product_currency?: string | undefined;
371
+ product_description?: string | undefined;
372
+ adaptive_currency_fees_inclusive?: boolean | undefined;
373
+ }>>;
374
+ }, "strip", z.ZodTypeAny, {
375
+ trial_period_days?: number | undefined;
376
+ on_demand?: {
377
+ mandate_only: boolean;
378
+ product_price?: number | undefined;
379
+ product_currency?: string | undefined;
380
+ product_description?: string | undefined;
381
+ adaptive_currency_fees_inclusive?: boolean | undefined;
382
+ } | undefined;
383
+ }, {
384
+ trial_period_days?: number | undefined;
385
+ on_demand?: {
386
+ mandate_only: boolean;
387
+ product_price?: number | undefined;
388
+ product_currency?: string | undefined;
389
+ product_description?: string | undefined;
390
+ adaptive_currency_fees_inclusive?: boolean | undefined;
391
+ } | undefined;
392
+ }>>;
393
+ force_3ds: z.ZodOptional<z.ZodBoolean>;
394
+ }, "strip", z.ZodTypeAny, {
395
+ product_cart?: {
396
+ quantity: number;
397
+ product_id: string;
398
+ addons?: {
399
+ quantity: number;
400
+ addon_id: string;
401
+ }[] | undefined;
402
+ amount?: number | undefined;
403
+ }[] | undefined;
404
+ customer?: {
405
+ email: string;
406
+ name?: string | undefined;
407
+ phone_number?: string | undefined;
408
+ } | {
409
+ customer_id: string;
410
+ } | undefined;
411
+ metadata?: Record<string, string> | undefined;
412
+ slug?: string | undefined;
413
+ referenceId?: string | undefined;
414
+ billing_address?: {
415
+ country: string;
416
+ city?: string | undefined;
417
+ state?: string | undefined;
418
+ street?: string | undefined;
419
+ zipcode?: string | undefined;
420
+ } | undefined;
421
+ return_url?: string | undefined;
422
+ allowed_payment_method_types?: ("credit" | "debit" | "upi_collect" | "upi_intent" | "apple_pay" | "cashapp" | "google_pay" | "multibanco" | "bancontact_card" | "eps" | "ideal" | "przelewy24" | "paypal" | "affirm" | "klarna" | "sepa" | "ach" | "amazon_pay" | "afterpay_clearpay")[] | undefined;
423
+ billing_currency?: string | undefined;
424
+ show_saved_payment_methods?: boolean | undefined;
425
+ confirm?: boolean | undefined;
426
+ discount_code?: string | undefined;
427
+ customization?: {
428
+ theme?: "light" | "dark" | "system" | undefined;
429
+ show_order_details?: boolean | undefined;
430
+ show_on_demand_tag?: boolean | undefined;
431
+ force_language?: string | undefined;
432
+ } | undefined;
433
+ feature_flags?: {
434
+ allow_currency_selection?: boolean | undefined;
435
+ allow_customer_editing_city?: boolean | undefined;
436
+ allow_customer_editing_country?: boolean | undefined;
437
+ allow_customer_editing_email?: boolean | undefined;
438
+ allow_customer_editing_name?: boolean | undefined;
439
+ allow_customer_editing_state?: boolean | undefined;
440
+ allow_customer_editing_street?: boolean | undefined;
441
+ allow_customer_editing_zipcode?: boolean | undefined;
442
+ allow_discount_code?: boolean | undefined;
443
+ allow_phone_number_collection?: boolean | undefined;
444
+ allow_tax_id?: boolean | undefined;
445
+ always_create_new_customer?: boolean | undefined;
446
+ } | undefined;
447
+ subscription_data?: {
448
+ trial_period_days?: number | undefined;
449
+ on_demand?: {
450
+ mandate_only: boolean;
451
+ product_price?: number | undefined;
452
+ product_currency?: string | undefined;
453
+ product_description?: string | undefined;
454
+ adaptive_currency_fees_inclusive?: boolean | undefined;
455
+ } | undefined;
456
+ } | undefined;
457
+ force_3ds?: boolean | undefined;
458
+ }, {
459
+ product_cart?: {
460
+ quantity: number;
461
+ product_id: string;
462
+ addons?: {
463
+ quantity: number;
464
+ addon_id: string;
465
+ }[] | undefined;
466
+ amount?: number | undefined;
467
+ }[] | undefined;
468
+ customer?: {
469
+ email: string;
470
+ name?: string | undefined;
471
+ phone_number?: string | undefined;
472
+ } | {
473
+ customer_id: string;
474
+ } | undefined;
475
+ metadata?: Record<string, string> | undefined;
476
+ slug?: string | undefined;
477
+ referenceId?: string | undefined;
478
+ billing_address?: {
479
+ country: string;
480
+ city?: string | undefined;
481
+ state?: string | undefined;
482
+ street?: string | undefined;
483
+ zipcode?: string | undefined;
484
+ } | undefined;
485
+ return_url?: string | undefined;
486
+ allowed_payment_method_types?: ("credit" | "debit" | "upi_collect" | "upi_intent" | "apple_pay" | "cashapp" | "google_pay" | "multibanco" | "bancontact_card" | "eps" | "ideal" | "przelewy24" | "paypal" | "affirm" | "klarna" | "sepa" | "ach" | "amazon_pay" | "afterpay_clearpay")[] | undefined;
487
+ billing_currency?: string | undefined;
488
+ show_saved_payment_methods?: boolean | undefined;
489
+ confirm?: boolean | undefined;
490
+ discount_code?: string | undefined;
491
+ customization?: {
492
+ theme?: "light" | "dark" | "system" | undefined;
493
+ show_order_details?: boolean | undefined;
494
+ show_on_demand_tag?: boolean | undefined;
495
+ force_language?: string | undefined;
496
+ } | undefined;
497
+ feature_flags?: {
498
+ allow_currency_selection?: boolean | undefined;
499
+ allow_customer_editing_city?: boolean | undefined;
500
+ allow_customer_editing_country?: boolean | undefined;
501
+ allow_customer_editing_email?: boolean | undefined;
502
+ allow_customer_editing_name?: boolean | undefined;
503
+ allow_customer_editing_state?: boolean | undefined;
504
+ allow_customer_editing_street?: boolean | undefined;
505
+ allow_customer_editing_zipcode?: boolean | undefined;
506
+ allow_discount_code?: boolean | undefined;
507
+ allow_phone_number_collection?: boolean | undefined;
508
+ allow_tax_id?: boolean | undefined;
509
+ always_create_new_customer?: boolean | undefined;
510
+ } | undefined;
511
+ subscription_data?: {
512
+ trial_period_days?: number | undefined;
513
+ on_demand?: {
514
+ mandate_only: boolean;
515
+ product_price?: number | undefined;
516
+ product_currency?: string | undefined;
517
+ product_description?: string | undefined;
518
+ adaptive_currency_fees_inclusive?: boolean | undefined;
519
+ } | undefined;
520
+ } | undefined;
521
+ force_3ds?: boolean | undefined;
522
+ }>;
523
+ requireRequest: true;
524
+ } & {
525
+ use: any[];
526
+ }, CreateCheckoutResponse>;
527
+ };
528
+
529
+ declare const portal: () => (dodopayments: DodoPayments$1) => {
530
+ dodoPortal: better_auth.StrictEndpoint<"/dodopayments/customer/portal", {
531
+ method: "GET";
532
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
533
+ session: {
534
+ session: Record<string, any> & {
535
+ id: string;
536
+ createdAt: Date;
537
+ updatedAt: Date;
538
+ userId: string;
539
+ expiresAt: Date;
540
+ token: string;
541
+ ipAddress?: string | null | undefined;
542
+ userAgent?: string | null | undefined;
543
+ };
544
+ user: Record<string, any> & {
545
+ id: string;
546
+ createdAt: Date;
547
+ updatedAt: Date;
548
+ email: string;
549
+ emailVerified: boolean;
550
+ name: string;
551
+ image?: string | null | undefined;
552
+ };
553
+ };
554
+ }>)[];
555
+ } & {
556
+ use: any[];
557
+ }, CustomerPortalResponse>;
558
+ dodoSubscriptions: better_auth.StrictEndpoint<"/dodopayments/customer/subscriptions/list", {
559
+ method: "GET";
560
+ query: z.ZodOptional<z.ZodObject<{
561
+ page: z.ZodOptional<z.ZodNumber>;
562
+ limit: z.ZodOptional<z.ZodNumber>;
563
+ status: z.ZodOptional<z.ZodEnum<["active", "cancelled", "on_hold", "pending", "failed", "expired"]>>;
564
+ }, "strip", z.ZodTypeAny, {
565
+ status?: "active" | "cancelled" | "on_hold" | "pending" | "failed" | "expired" | undefined;
566
+ page?: number | undefined;
567
+ limit?: number | undefined;
568
+ }, {
569
+ status?: "active" | "cancelled" | "on_hold" | "pending" | "failed" | "expired" | undefined;
570
+ page?: number | undefined;
571
+ limit?: number | undefined;
572
+ }>>;
573
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
574
+ session: {
575
+ session: Record<string, any> & {
576
+ id: string;
577
+ createdAt: Date;
578
+ updatedAt: Date;
579
+ userId: string;
580
+ expiresAt: Date;
581
+ token: string;
582
+ ipAddress?: string | null | undefined;
583
+ userAgent?: string | null | undefined;
584
+ };
585
+ user: Record<string, any> & {
586
+ id: string;
587
+ createdAt: Date;
588
+ updatedAt: Date;
589
+ email: string;
590
+ emailVerified: boolean;
591
+ name: string;
592
+ image?: string | null | undefined;
593
+ };
594
+ };
595
+ }>)[];
596
+ } & {
597
+ use: any[];
598
+ }, SubscriptionItems>;
599
+ dodoPayments: better_auth.StrictEndpoint<"/dodopayments/customer/payments/list", {
600
+ method: "GET";
601
+ query: z.ZodOptional<z.ZodObject<{
602
+ page: z.ZodOptional<z.ZodNumber>;
603
+ limit: z.ZodOptional<z.ZodNumber>;
604
+ status: z.ZodOptional<z.ZodEnum<["succeeded", "failed", "cancelled", "processing", "requires_customer_action", "requires_merchant_action", "requires_payment_method", "requires_confirmation", "requires_capture", "partially_captured", "partially_captured_and_capturable"]>>;
605
+ }, "strip", z.ZodTypeAny, {
606
+ status?: "cancelled" | "failed" | "succeeded" | "processing" | "requires_customer_action" | "requires_merchant_action" | "requires_payment_method" | "requires_confirmation" | "requires_capture" | "partially_captured" | "partially_captured_and_capturable" | undefined;
607
+ page?: number | undefined;
608
+ limit?: number | undefined;
609
+ }, {
610
+ status?: "cancelled" | "failed" | "succeeded" | "processing" | "requires_customer_action" | "requires_merchant_action" | "requires_payment_method" | "requires_confirmation" | "requires_capture" | "partially_captured" | "partially_captured_and_capturable" | undefined;
611
+ page?: number | undefined;
612
+ limit?: number | undefined;
613
+ }>>;
614
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
615
+ session: {
616
+ session: Record<string, any> & {
617
+ id: string;
618
+ createdAt: Date;
619
+ updatedAt: Date;
620
+ userId: string;
621
+ expiresAt: Date;
622
+ token: string;
623
+ ipAddress?: string | null | undefined;
624
+ userAgent?: string | null | undefined;
625
+ };
626
+ user: Record<string, any> & {
627
+ id: string;
628
+ createdAt: Date;
629
+ updatedAt: Date;
630
+ email: string;
631
+ emailVerified: boolean;
632
+ name: string;
633
+ image?: string | null | undefined;
634
+ };
635
+ };
636
+ }>)[];
637
+ } & {
638
+ use: any[];
639
+ }, PaymentItems>;
640
+ };
641
+
642
+ declare const webhooks: (options: WebhookHandlerConfig) => (_dodopayments: DodoPayments$1) => {
643
+ dodopaymentsWebhooks: better_auth.StrictEndpoint<"/dodopayments/webhooks", {
644
+ method: "POST";
645
+ metadata: {
646
+ isAction: false;
647
+ };
648
+ cloneRequest: true;
649
+ } & {
650
+ use: any[];
651
+ }, WebhookResponse>;
652
+ };
653
+
654
+ type Product = {
655
+ /**
656
+ * Product Id from DodoPayments Product
657
+ */
658
+ productId: string;
659
+ /**
660
+ * Easily identifiable slug for the product
661
+ */
662
+ slug: string;
663
+ };
664
+ type DodoPaymentsPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof webhooks> | ReturnType<typeof usage>;
665
+ type DodoPaymentsPlugins = [DodoPaymentsPlugin, ...DodoPaymentsPlugin[]];
666
+ type DodoPaymentsEndpoints = UnionToIntersection<ReturnType<DodoPaymentsPlugin>>;
667
+ interface DodoPaymentsOptions {
668
+ /**
669
+ * DodoPayments Client
670
+ */
671
+ client: DodoPayments$1;
672
+ /**
673
+ * Enable customer creation when a user signs up
674
+ */
675
+ createCustomerOnSignUp?: boolean;
676
+ /**
677
+ * Use DodoPayments plugins
678
+ */
679
+ use: DodoPaymentsPlugins;
680
+ }
681
+ type PaymentsList = Awaited<ReturnType<DodoPayments$1["payments"]["list"]>>;
682
+ type SubscriptionsList = Awaited<ReturnType<DodoPayments$1["subscriptions"]["list"]>>;
683
+ type PaymentItems = {
684
+ items: PaymentsList["items"];
685
+ };
686
+ type SubscriptionItems = {
687
+ items: SubscriptionsList["items"];
688
+ };
689
+ type CustomerPortalResponse = {
690
+ url: string;
691
+ redirect: boolean;
692
+ };
693
+ type CreateCheckoutResponse = {
694
+ url: string;
695
+ redirect: boolean;
696
+ };
697
+ type WebhookResponse = {
698
+ received: boolean;
699
+ };
700
+
701
+ export { type CreateCheckoutResponse as C, type DodoPaymentsOptions as D, type PaymentItems as P, type SubscriptionItems as S, type WebhookResponse as W, type CustomerPortalResponse as a, type Product as b, type DodoPaymentsPlugin as c, type DodoPaymentsPlugins as d, type DodoPaymentsEndpoints as e, checkout as f, type CheckoutOptions as g, portal as p, webhooks as w };