better-auth-mercadopago 0.1.4 → 0.1.6

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,1019 @@
1
+ import { BetterFetchOption } from 'better-auth/client';
2
+ import * as better_auth from 'better-auth';
3
+ import { z } from 'zod';
4
+
5
+ /** biome-ignore-all lint/suspicious/noExplicitAny: <no need to use any> */
6
+ interface MercadoPagoPluginOptions {
7
+ /**
8
+ * Your Mercado Pago access token
9
+ */
10
+ accessToken: string;
11
+ /**
12
+ * Base URL for redirects and webhooks
13
+ * @default process.env.APP_URL
14
+ */
15
+ baseUrl?: string;
16
+ /**
17
+ * Webhook secret for signature verification (optional)
18
+ */
19
+ webhookSecret?: string;
20
+ /**
21
+ * App ID for OAuth (required for marketplace features)
22
+ * Get it from: https://www.mercadopago.com/developers/panel/app
23
+ */
24
+ appId?: string;
25
+ /**
26
+ * App Secret for OAuth (required for marketplace features)
27
+ */
28
+ appSecret?: string;
29
+ /**
30
+ * Trusted origins for OAuth redirects
31
+ */
32
+ trustedOrigins?: string[];
33
+ /**
34
+ * Callback executed when a payment status changes
35
+ */
36
+ onPaymentUpdate?: (data: {
37
+ payment: MercadoPagoPaymentRecord;
38
+ status: string;
39
+ statusDetail: string;
40
+ mpPayment: MercadoPagoPaymentResponse;
41
+ }) => void | Promise<void>;
42
+ /**
43
+ * Callback executed when a subscription status changes
44
+ */
45
+ onSubscriptionUpdate?: (data: {
46
+ subscription: MercadoPagoSubscriptionRecord;
47
+ status: string;
48
+ reason: string;
49
+ mpPreapproval: MercadoPagoPreApprovalResponse;
50
+ }) => void | Promise<void>;
51
+ /**
52
+ * Callback executed when a recurring payment is processed (monthly, etc.)
53
+ */
54
+ onSubscriptionPayment?: (data: {
55
+ subscription: MercadoPagoSubscriptionRecord;
56
+ payment: MercadoPagoPaymentResponse;
57
+ status: string;
58
+ }) => void | Promise<void>;
59
+ }
60
+ interface MercadoPagoCustomerRecord {
61
+ id: string;
62
+ userId: string;
63
+ mercadoPagoId: string;
64
+ email: string;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ }
68
+ interface MercadoPagoPaymentRecord {
69
+ id: string;
70
+ userId: string;
71
+ mercadoPagoPaymentId: string;
72
+ preferenceId: string;
73
+ status: string;
74
+ amount: number;
75
+ currency: string;
76
+ metadata?: string;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ }
80
+ interface MercadoPagoSubscriptionRecord {
81
+ id: string;
82
+ userId: string;
83
+ mercadoPagoSubscriptionId: string;
84
+ planId: string;
85
+ status: string;
86
+ reason?: string;
87
+ nextPaymentDate?: Date;
88
+ lastPaymentDate?: Date;
89
+ summarized?: string;
90
+ metadata?: string;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ }
94
+ interface MercadoPagoMarketplaceSplitRecord {
95
+ id: string;
96
+ paymentId: string;
97
+ collectorId: string;
98
+ collectorEmail: string;
99
+ applicationFeeAmount?: number;
100
+ applicationFeePercentage?: number;
101
+ netAmount: number;
102
+ metadata?: string;
103
+ createdAt: Date;
104
+ }
105
+ interface MercadoPagoOAuthTokenRecord {
106
+ id: string;
107
+ userId: string;
108
+ accessToken: string;
109
+ refreshToken: string;
110
+ publicKey: string;
111
+ mercadoPagoUserId: string;
112
+ expiresAt: Date;
113
+ createdAt: Date;
114
+ updatedAt: Date;
115
+ }
116
+ interface MercadoPagoPreapprovalPlanRecord {
117
+ id: string;
118
+ mercadoPagoPlanId: string;
119
+ reason: string;
120
+ frequency: number;
121
+ frequencyType: string;
122
+ transactionAmount: number;
123
+ currencyId: string;
124
+ repetitions?: number;
125
+ freeTrial?: string;
126
+ metadata?: string;
127
+ createdAt: Date;
128
+ updatedAt: Date;
129
+ }
130
+ interface PaymentItem {
131
+ id: string;
132
+ title: string;
133
+ quantity: number;
134
+ unitPrice: number;
135
+ currencyId?: string;
136
+ }
137
+ interface MarketplaceConfig {
138
+ collectorId: string;
139
+ applicationFee?: number;
140
+ applicationFeePercentage?: number;
141
+ }
142
+ interface CreatePaymentParams {
143
+ items: PaymentItem[];
144
+ metadata?: Record<string, any>;
145
+ marketplace?: MarketplaceConfig;
146
+ successUrl?: string;
147
+ failureUrl?: string;
148
+ pendingUrl?: string;
149
+ }
150
+ interface CreateSubscriptionParams {
151
+ preapprovalPlanId?: string;
152
+ reason?: string;
153
+ autoRecurring?: {
154
+ frequency: number;
155
+ frequencyType: "days" | "months";
156
+ transactionAmount: number;
157
+ currencyId?: string;
158
+ startDate?: string;
159
+ endDate?: string;
160
+ freeTrial?: {
161
+ frequency: number;
162
+ frequencyType: "days" | "months";
163
+ };
164
+ };
165
+ backUrl?: string;
166
+ metadata?: Record<string, any>;
167
+ }
168
+ interface CreatePreapprovalPlanParams {
169
+ reason: string;
170
+ autoRecurring: {
171
+ frequency: number;
172
+ frequencyType: "days" | "months";
173
+ transactionAmount: number;
174
+ currencyId?: string;
175
+ freeTrial?: {
176
+ frequency: number;
177
+ frequencyType: "days" | "months";
178
+ };
179
+ };
180
+ repetitions?: number;
181
+ backUrl?: string;
182
+ metadata?: Record<string, any>;
183
+ }
184
+ interface CreatePreapprovalPlanResponse {
185
+ plan: MercadoPagoPreapprovalPlanRecord;
186
+ }
187
+ interface CreatePaymentResponse {
188
+ checkoutUrl: string;
189
+ preferenceId: string;
190
+ payment: MercadoPagoPaymentRecord;
191
+ }
192
+ interface CreateSubscriptionResponse {
193
+ checkoutUrl: string;
194
+ subscription: MercadoPagoSubscriptionRecord;
195
+ }
196
+ interface OAuthUrlResponse {
197
+ authUrl: string;
198
+ }
199
+ interface OAuthTokenResponse {
200
+ success: boolean;
201
+ oauthToken: {
202
+ id: string;
203
+ mercadoPagoUserId: string;
204
+ expiresAt: Date;
205
+ };
206
+ }
207
+ interface MercadoPagoPaymentResponse {
208
+ id: number;
209
+ date_created: string;
210
+ date_approved: string;
211
+ date_last_updated: string;
212
+ money_release_date: string;
213
+ payment_method_id: string;
214
+ payment_type_id: string;
215
+ status: string;
216
+ status_detail: string;
217
+ currency_id: string;
218
+ description: string;
219
+ live_mode: boolean;
220
+ sponsor_id: number;
221
+ authorization_code: string;
222
+ integrator_id: string;
223
+ taxes_amount: number;
224
+ counter_currency: string;
225
+ operation_type: string;
226
+ additional_info: {
227
+ items: {
228
+ id: string;
229
+ title: string;
230
+ description: string;
231
+ picture_url: string;
232
+ category_id: string;
233
+ quantity: string;
234
+ unit_price: string;
235
+ }[];
236
+ payer: {
237
+ first_name: string;
238
+ last_name: string;
239
+ phone: {
240
+ area_code: string;
241
+ number: string;
242
+ };
243
+ };
244
+ ip_address: string;
245
+ };
246
+ external_reference: string;
247
+ transaction_amount: number;
248
+ transaction_amount_refunded: number;
249
+ coupon_amount: number;
250
+ installments: number;
251
+ transaction_details: {
252
+ net_received_amount: number;
253
+ total_paid_amount: number;
254
+ overpaid_amount: number;
255
+ external_resource_url: string;
256
+ installment_amount: number;
257
+ financial_institution: string;
258
+ payment_method_reference_id: string;
259
+ };
260
+ }
261
+ interface MercadoPagoPreApprovalResponse {
262
+ id: string;
263
+ payer_id: number;
264
+ payer_email: string;
265
+ back_url: string;
266
+ collector_id: number;
267
+ application_id: number;
268
+ status: string;
269
+ reason: string;
270
+ external_reference: string;
271
+ date_created: string;
272
+ last_modified: string;
273
+ init_point: string;
274
+ auto_recurring: {
275
+ frequency: number;
276
+ frequency_type: string;
277
+ transaction_amount: number;
278
+ currency_id: string;
279
+ start_date: string;
280
+ end_date: string;
281
+ free_trial?: {
282
+ frequency: number;
283
+ frequency_type: string;
284
+ };
285
+ };
286
+ summarized?: {
287
+ quotas: number;
288
+ charged_quantity: number;
289
+ pending_charge_quantity: number;
290
+ charged_amount: number;
291
+ pending_charge_amount: number;
292
+ semester: number;
293
+ year: number;
294
+ };
295
+ next_payment_date: string;
296
+ payment_method_id: string;
297
+ }
298
+
299
+ declare const mercadoPagoPlugin: (options: MercadoPagoPluginOptions) => {
300
+ trustedOrigins?: string[] | undefined;
301
+ id: "mercadoPago";
302
+ schema: {
303
+ mercadoPagoCustomer: {
304
+ fields: {
305
+ id: {
306
+ type: "string";
307
+ required: true;
308
+ };
309
+ userId: {
310
+ type: "string";
311
+ required: true;
312
+ references: {
313
+ model: string;
314
+ field: string;
315
+ onDelete: "cascade";
316
+ };
317
+ };
318
+ mercadoPagoId: {
319
+ type: "string";
320
+ required: true;
321
+ unique: true;
322
+ };
323
+ email: {
324
+ type: "string";
325
+ required: true;
326
+ };
327
+ createdAt: {
328
+ type: "date";
329
+ required: true;
330
+ };
331
+ updatedAt: {
332
+ type: "date";
333
+ required: true;
334
+ };
335
+ };
336
+ };
337
+ mercadoPagoPayment: {
338
+ fields: {
339
+ id: {
340
+ type: "string";
341
+ required: true;
342
+ };
343
+ userId: {
344
+ type: "string";
345
+ required: true;
346
+ references: {
347
+ model: string;
348
+ field: string;
349
+ onDelete: "cascade";
350
+ };
351
+ };
352
+ mercadoPagoPaymentId: {
353
+ type: "string";
354
+ required: true;
355
+ unique: true;
356
+ };
357
+ preferenceId: {
358
+ type: "string";
359
+ required: true;
360
+ };
361
+ status: {
362
+ type: "string";
363
+ required: true;
364
+ };
365
+ statusDetail: {
366
+ type: "string";
367
+ };
368
+ amount: {
369
+ type: "number";
370
+ required: true;
371
+ };
372
+ currency: {
373
+ type: "string";
374
+ required: true;
375
+ };
376
+ paymentMethodId: {
377
+ type: "string";
378
+ };
379
+ paymentTypeId: {
380
+ type: "string";
381
+ };
382
+ metadata: {
383
+ type: "string";
384
+ };
385
+ createdAt: {
386
+ type: "date";
387
+ required: true;
388
+ };
389
+ updatedAt: {
390
+ type: "date";
391
+ required: true;
392
+ };
393
+ };
394
+ };
395
+ mercadoPagoSubscription: {
396
+ fields: {
397
+ id: {
398
+ type: "string";
399
+ required: true;
400
+ };
401
+ userId: {
402
+ type: "string";
403
+ required: true;
404
+ references: {
405
+ model: string;
406
+ field: string;
407
+ onDelete: "cascade";
408
+ };
409
+ };
410
+ mercadoPagoSubscriptionId: {
411
+ type: "string";
412
+ required: true;
413
+ unique: true;
414
+ };
415
+ planId: {
416
+ type: "string";
417
+ required: true;
418
+ };
419
+ status: {
420
+ type: "string";
421
+ required: true;
422
+ };
423
+ reason: {
424
+ type: "string";
425
+ };
426
+ nextPaymentDate: {
427
+ type: "date";
428
+ };
429
+ lastPaymentDate: {
430
+ type: "date";
431
+ };
432
+ summarized: {
433
+ type: "string";
434
+ };
435
+ metadata: {
436
+ type: "string";
437
+ };
438
+ createdAt: {
439
+ type: "date";
440
+ required: true;
441
+ };
442
+ updatedAt: {
443
+ type: "date";
444
+ required: true;
445
+ };
446
+ };
447
+ };
448
+ mercadoPagoPreapprovalPlan: {
449
+ fields: {
450
+ id: {
451
+ type: "string";
452
+ required: true;
453
+ };
454
+ mercadoPagoPlanId: {
455
+ type: "string";
456
+ required: true;
457
+ unique: true;
458
+ };
459
+ reason: {
460
+ type: "string";
461
+ required: true;
462
+ };
463
+ frequency: {
464
+ type: "number";
465
+ required: true;
466
+ };
467
+ frequencyType: {
468
+ type: "string";
469
+ required: true;
470
+ };
471
+ transactionAmount: {
472
+ type: "number";
473
+ required: true;
474
+ };
475
+ currencyId: {
476
+ type: "string";
477
+ required: true;
478
+ };
479
+ repetitions: {
480
+ type: "number";
481
+ };
482
+ freeTrial: {
483
+ type: "string";
484
+ };
485
+ metadata: {
486
+ type: "string";
487
+ };
488
+ createdAt: {
489
+ type: "date";
490
+ required: true;
491
+ };
492
+ updatedAt: {
493
+ type: "date";
494
+ required: true;
495
+ };
496
+ };
497
+ };
498
+ mercadoPagoMarketplaceSplit: {
499
+ fields: {
500
+ id: {
501
+ type: "string";
502
+ required: true;
503
+ };
504
+ paymentId: {
505
+ type: "string";
506
+ required: true;
507
+ references: {
508
+ model: string;
509
+ field: string;
510
+ onDelete: "cascade";
511
+ };
512
+ };
513
+ collectorId: {
514
+ type: "string";
515
+ required: true;
516
+ };
517
+ collectorEmail: {
518
+ type: "string";
519
+ required: true;
520
+ };
521
+ applicationFeeAmount: {
522
+ type: "number";
523
+ };
524
+ applicationFeePercentage: {
525
+ type: "number";
526
+ };
527
+ netAmount: {
528
+ type: "number";
529
+ required: true;
530
+ };
531
+ metadata: {
532
+ type: "string";
533
+ };
534
+ createdAt: {
535
+ type: "date";
536
+ required: true;
537
+ };
538
+ };
539
+ };
540
+ mercadoPagoOAuthToken: {
541
+ fields: {
542
+ id: {
543
+ type: "string";
544
+ required: true;
545
+ };
546
+ userId: {
547
+ type: "string";
548
+ required: true;
549
+ references: {
550
+ model: string;
551
+ field: string;
552
+ onDelete: "cascade";
553
+ };
554
+ };
555
+ accessToken: {
556
+ type: "string";
557
+ required: true;
558
+ };
559
+ refreshToken: {
560
+ type: "string";
561
+ required: true;
562
+ };
563
+ publicKey: {
564
+ type: "string";
565
+ required: true;
566
+ };
567
+ mercadoPagoUserId: {
568
+ type: "string";
569
+ required: true;
570
+ unique: true;
571
+ };
572
+ expiresAt: {
573
+ type: "date";
574
+ required: true;
575
+ };
576
+ createdAt: {
577
+ type: "date";
578
+ required: true;
579
+ };
580
+ updatedAt: {
581
+ type: "date";
582
+ required: true;
583
+ };
584
+ };
585
+ };
586
+ };
587
+ endpoints: {
588
+ getOrCreateCustomer: better_auth.StrictEndpoint<"/mercado-pago/customer", {
589
+ method: "POST";
590
+ requireAuth: boolean;
591
+ body: z.ZodObject<{
592
+ email: z.ZodOptional<z.ZodString>;
593
+ firstName: z.ZodOptional<z.ZodString>;
594
+ lastName: z.ZodOptional<z.ZodString>;
595
+ }, "strip", z.ZodTypeAny, {
596
+ email?: string | undefined;
597
+ firstName?: string | undefined;
598
+ lastName?: string | undefined;
599
+ }, {
600
+ email?: string | undefined;
601
+ firstName?: string | undefined;
602
+ lastName?: string | undefined;
603
+ }>;
604
+ }, {
605
+ customer: {};
606
+ }>;
607
+ getOAuthUrl: better_auth.StrictEndpoint<"/mercado-pago/oauth/authorize", {
608
+ method: "GET";
609
+ requireAuth: boolean;
610
+ query: z.ZodObject<{
611
+ redirectUri: z.ZodString;
612
+ }, "strip", z.ZodTypeAny, {
613
+ redirectUri: string;
614
+ }, {
615
+ redirectUri: string;
616
+ }>;
617
+ }, {
618
+ authUrl: string;
619
+ }>;
620
+ exchangeOAuthCode: better_auth.StrictEndpoint<"/mercado-pago/oauth/callback", {
621
+ method: "POST";
622
+ requireAuth: boolean;
623
+ body: z.ZodObject<{
624
+ code: z.ZodString;
625
+ redirectUri: z.ZodString;
626
+ }, "strip", z.ZodTypeAny, {
627
+ code: string;
628
+ redirectUri: string;
629
+ }, {
630
+ code: string;
631
+ redirectUri: string;
632
+ }>;
633
+ }, {
634
+ success: boolean;
635
+ oauthToken: {
636
+ id: any;
637
+ mercadoPagoUserId: any;
638
+ expiresAt: any;
639
+ };
640
+ }>;
641
+ createPreapprovalPlan: better_auth.StrictEndpoint<"/mercado-pago/plan/create", {
642
+ method: "POST";
643
+ body: z.ZodObject<{
644
+ reason: z.ZodString;
645
+ autoRecurring: z.ZodObject<{
646
+ frequency: z.ZodNumber;
647
+ frequencyType: z.ZodEnum<["days", "months"]>;
648
+ transactionAmount: z.ZodNumber;
649
+ currencyId: z.ZodDefault<z.ZodString>;
650
+ freeTrial: z.ZodOptional<z.ZodObject<{
651
+ frequency: z.ZodNumber;
652
+ frequencyType: z.ZodEnum<["days", "months"]>;
653
+ }, "strip", z.ZodTypeAny, {
654
+ frequency: number;
655
+ frequencyType: "days" | "months";
656
+ }, {
657
+ frequency: number;
658
+ frequencyType: "days" | "months";
659
+ }>>;
660
+ }, "strip", z.ZodTypeAny, {
661
+ frequency: number;
662
+ frequencyType: "days" | "months";
663
+ transactionAmount: number;
664
+ currencyId: string;
665
+ freeTrial?: {
666
+ frequency: number;
667
+ frequencyType: "days" | "months";
668
+ } | undefined;
669
+ }, {
670
+ frequency: number;
671
+ frequencyType: "days" | "months";
672
+ transactionAmount: number;
673
+ currencyId?: string | undefined;
674
+ freeTrial?: {
675
+ frequency: number;
676
+ frequencyType: "days" | "months";
677
+ } | undefined;
678
+ }>;
679
+ repetitions: z.ZodOptional<z.ZodNumber>;
680
+ backUrl: z.ZodOptional<z.ZodString>;
681
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
682
+ }, "strip", z.ZodTypeAny, {
683
+ reason: string;
684
+ autoRecurring: {
685
+ frequency: number;
686
+ frequencyType: "days" | "months";
687
+ transactionAmount: number;
688
+ currencyId: string;
689
+ freeTrial?: {
690
+ frequency: number;
691
+ frequencyType: "days" | "months";
692
+ } | undefined;
693
+ };
694
+ metadata?: Record<string, any> | undefined;
695
+ repetitions?: number | undefined;
696
+ backUrl?: string | undefined;
697
+ }, {
698
+ reason: string;
699
+ autoRecurring: {
700
+ frequency: number;
701
+ frequencyType: "days" | "months";
702
+ transactionAmount: number;
703
+ currencyId?: string | undefined;
704
+ freeTrial?: {
705
+ frequency: number;
706
+ frequencyType: "days" | "months";
707
+ } | undefined;
708
+ };
709
+ metadata?: Record<string, any> | undefined;
710
+ repetitions?: number | undefined;
711
+ backUrl?: string | undefined;
712
+ }>;
713
+ }, {
714
+ plan: Record<string, any>;
715
+ }>;
716
+ listPreapprovalPlans: better_auth.StrictEndpoint<"/mercado-pago/plans", {
717
+ method: "GET";
718
+ }, {
719
+ plans: unknown[];
720
+ }>;
721
+ createPayment: better_auth.StrictEndpoint<"/mercado-pago/payment/create", {
722
+ method: "POST";
723
+ requireAuth: boolean;
724
+ body: z.ZodObject<{
725
+ items: z.ZodArray<z.ZodObject<{
726
+ id: z.ZodString;
727
+ title: z.ZodString;
728
+ quantity: z.ZodNumber;
729
+ unitPrice: z.ZodNumber;
730
+ currencyId: z.ZodDefault<z.ZodString>;
731
+ }, "strip", z.ZodTypeAny, {
732
+ id: string;
733
+ currencyId: string;
734
+ title: string;
735
+ quantity: number;
736
+ unitPrice: number;
737
+ }, {
738
+ id: string;
739
+ title: string;
740
+ quantity: number;
741
+ unitPrice: number;
742
+ currencyId?: string | undefined;
743
+ }>, "many">;
744
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
745
+ marketplace: z.ZodOptional<z.ZodObject<{
746
+ collectorId: z.ZodString;
747
+ applicationFee: z.ZodOptional<z.ZodNumber>;
748
+ applicationFeePercentage: z.ZodOptional<z.ZodNumber>;
749
+ }, "strip", z.ZodTypeAny, {
750
+ collectorId: string;
751
+ applicationFeePercentage?: number | undefined;
752
+ applicationFee?: number | undefined;
753
+ }, {
754
+ collectorId: string;
755
+ applicationFeePercentage?: number | undefined;
756
+ applicationFee?: number | undefined;
757
+ }>>;
758
+ successUrl: z.ZodOptional<z.ZodString>;
759
+ failureUrl: z.ZodOptional<z.ZodString>;
760
+ pendingUrl: z.ZodOptional<z.ZodString>;
761
+ idempotencyKey: z.ZodOptional<z.ZodString>;
762
+ }, "strip", z.ZodTypeAny, {
763
+ items: {
764
+ id: string;
765
+ currencyId: string;
766
+ title: string;
767
+ quantity: number;
768
+ unitPrice: number;
769
+ }[];
770
+ metadata?: Record<string, any> | undefined;
771
+ marketplace?: {
772
+ collectorId: string;
773
+ applicationFeePercentage?: number | undefined;
774
+ applicationFee?: number | undefined;
775
+ } | undefined;
776
+ successUrl?: string | undefined;
777
+ failureUrl?: string | undefined;
778
+ pendingUrl?: string | undefined;
779
+ idempotencyKey?: string | undefined;
780
+ }, {
781
+ items: {
782
+ id: string;
783
+ title: string;
784
+ quantity: number;
785
+ unitPrice: number;
786
+ currencyId?: string | undefined;
787
+ }[];
788
+ metadata?: Record<string, any> | undefined;
789
+ marketplace?: {
790
+ collectorId: string;
791
+ applicationFeePercentage?: number | undefined;
792
+ applicationFee?: number | undefined;
793
+ } | undefined;
794
+ successUrl?: string | undefined;
795
+ failureUrl?: string | undefined;
796
+ pendingUrl?: string | undefined;
797
+ idempotencyKey?: string | undefined;
798
+ }>;
799
+ }, any>;
800
+ createSubscription: better_auth.StrictEndpoint<"/mercado-pago/subscription/create", {
801
+ method: "POST";
802
+ requireAuth: boolean;
803
+ body: z.ZodObject<{
804
+ preapprovalPlanId: z.ZodOptional<z.ZodString>;
805
+ reason: z.ZodOptional<z.ZodString>;
806
+ autoRecurring: z.ZodOptional<z.ZodObject<{
807
+ frequency: z.ZodNumber;
808
+ frequencyType: z.ZodEnum<["days", "months"]>;
809
+ transactionAmount: z.ZodNumber;
810
+ currencyId: z.ZodDefault<z.ZodString>;
811
+ startDate: z.ZodOptional<z.ZodString>;
812
+ endDate: z.ZodOptional<z.ZodString>;
813
+ freeTrial: z.ZodOptional<z.ZodObject<{
814
+ frequency: z.ZodNumber;
815
+ frequencyType: z.ZodEnum<["days", "months"]>;
816
+ }, "strip", z.ZodTypeAny, {
817
+ frequency: number;
818
+ frequencyType: "days" | "months";
819
+ }, {
820
+ frequency: number;
821
+ frequencyType: "days" | "months";
822
+ }>>;
823
+ }, "strip", z.ZodTypeAny, {
824
+ frequency: number;
825
+ frequencyType: "days" | "months";
826
+ transactionAmount: number;
827
+ currencyId: string;
828
+ freeTrial?: {
829
+ frequency: number;
830
+ frequencyType: "days" | "months";
831
+ } | undefined;
832
+ startDate?: string | undefined;
833
+ endDate?: string | undefined;
834
+ }, {
835
+ frequency: number;
836
+ frequencyType: "days" | "months";
837
+ transactionAmount: number;
838
+ currencyId?: string | undefined;
839
+ freeTrial?: {
840
+ frequency: number;
841
+ frequencyType: "days" | "months";
842
+ } | undefined;
843
+ startDate?: string | undefined;
844
+ endDate?: string | undefined;
845
+ }>>;
846
+ backUrl: z.ZodOptional<z.ZodString>;
847
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
848
+ }, "strip", z.ZodTypeAny, {
849
+ metadata?: Record<string, any> | undefined;
850
+ reason?: string | undefined;
851
+ autoRecurring?: {
852
+ frequency: number;
853
+ frequencyType: "days" | "months";
854
+ transactionAmount: number;
855
+ currencyId: string;
856
+ freeTrial?: {
857
+ frequency: number;
858
+ frequencyType: "days" | "months";
859
+ } | undefined;
860
+ startDate?: string | undefined;
861
+ endDate?: string | undefined;
862
+ } | undefined;
863
+ backUrl?: string | undefined;
864
+ preapprovalPlanId?: string | undefined;
865
+ }, {
866
+ metadata?: Record<string, any> | undefined;
867
+ reason?: string | undefined;
868
+ autoRecurring?: {
869
+ frequency: number;
870
+ frequencyType: "days" | "months";
871
+ transactionAmount: number;
872
+ currencyId?: string | undefined;
873
+ freeTrial?: {
874
+ frequency: number;
875
+ frequencyType: "days" | "months";
876
+ } | undefined;
877
+ startDate?: string | undefined;
878
+ endDate?: string | undefined;
879
+ } | undefined;
880
+ backUrl?: string | undefined;
881
+ preapprovalPlanId?: string | undefined;
882
+ }>;
883
+ }, {
884
+ checkoutUrl: string | undefined;
885
+ subscription: Record<string, any>;
886
+ }>;
887
+ cancelSubscription: better_auth.StrictEndpoint<"/mercado-pago/subscription/cancel", {
888
+ method: "POST";
889
+ requireAuth: boolean;
890
+ body: z.ZodObject<{
891
+ subscriptionId: z.ZodString;
892
+ }, "strip", z.ZodTypeAny, {
893
+ subscriptionId: string;
894
+ }, {
895
+ subscriptionId: string;
896
+ }>;
897
+ }, {
898
+ success: boolean;
899
+ }>;
900
+ getPayment: better_auth.StrictEndpoint<"/mercado-pago/payment/:id", {
901
+ method: "GET";
902
+ requireAuth: boolean;
903
+ }, {
904
+ payment: MercadoPagoPaymentRecord;
905
+ }>;
906
+ listPayments: better_auth.StrictEndpoint<"/mercado-pago/payments", {
907
+ method: "GET";
908
+ requireAuth: boolean;
909
+ query: z.ZodObject<{
910
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
911
+ offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
912
+ }, "strip", z.ZodTypeAny, {
913
+ limit: number;
914
+ offset: number;
915
+ }, {
916
+ limit?: number | undefined;
917
+ offset?: number | undefined;
918
+ }>;
919
+ }, {
920
+ payments: unknown[];
921
+ }>;
922
+ listSubscriptions: better_auth.StrictEndpoint<"/mercado-pago/subscriptions", {
923
+ method: "GET";
924
+ requireAuth: boolean;
925
+ }, {
926
+ subscriptions: unknown[];
927
+ }>;
928
+ webhook: better_auth.StrictEndpoint<"/mercado-pago/webhook", {
929
+ method: "POST";
930
+ }, {
931
+ received: boolean;
932
+ }>;
933
+ };
934
+ };
935
+
936
+ interface MercadoPagoClientActions {
937
+ /**
938
+ * Get or create a Mercado Pago customer for the authenticated user
939
+ */
940
+ getOrCreateCustomer: (data?: {
941
+ email?: string;
942
+ firstName?: string;
943
+ lastName?: string;
944
+ }, fetchOptions?: BetterFetchOption) => Promise<{
945
+ customer: MercadoPagoCustomerRecord;
946
+ }>;
947
+ /**
948
+ * Create a payment and get checkout URL
949
+ */
950
+ createPayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<CreatePaymentResponse>;
951
+ /**
952
+ * Create a marketplace payment with automatic split
953
+ */
954
+ createMarketplacePayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<CreatePaymentResponse>;
955
+ /**
956
+ * Create a subscription with recurring payments
957
+ */
958
+ createSubscription: (data: CreateSubscriptionParams, fetchOptions?: BetterFetchOption) => Promise<CreateSubscriptionResponse>;
959
+ /**
960
+ * Cancel a subscription
961
+ */
962
+ cancelSubscription: (data: {
963
+ subscriptionId: string;
964
+ }, fetchOptions?: BetterFetchOption) => Promise<{
965
+ success: boolean;
966
+ }>;
967
+ /**
968
+ * Create a reusable preapproval plan (subscription template)
969
+ */
970
+ createPreapprovalPlan: (data: CreatePreapprovalPlanParams, fetchOptions?: BetterFetchOption) => Promise<CreatePreapprovalPlanResponse>;
971
+ /**
972
+ * List all preapproval plans
973
+ */
974
+ listPreapprovalPlans: (fetchOptions?: BetterFetchOption) => Promise<{
975
+ plans: MercadoPagoPreapprovalPlanRecord[];
976
+ }>;
977
+ /**
978
+ * Get payment by ID
979
+ */
980
+ getPayment: (paymentId: string, fetchOptions?: BetterFetchOption) => Promise<{
981
+ payment: MercadoPagoPaymentRecord;
982
+ }>;
983
+ /**
984
+ * List all payments for the authenticated user
985
+ */
986
+ listPayments: (params?: {
987
+ limit?: number;
988
+ offset?: number;
989
+ }, fetchOptions?: BetterFetchOption) => Promise<{
990
+ payments: MercadoPagoPaymentRecord[];
991
+ }>;
992
+ /**
993
+ * List all subscriptions for the authenticated user
994
+ */
995
+ listSubscriptions: (fetchOptions?: BetterFetchOption) => Promise<{
996
+ subscriptions: MercadoPagoSubscriptionRecord[];
997
+ }>;
998
+ /**
999
+ * Get OAuth authorization URL for marketplace sellers
1000
+ */
1001
+ getOAuthUrl: (params: {
1002
+ redirectUri: string;
1003
+ }, fetchOptions?: BetterFetchOption) => Promise<OAuthUrlResponse>;
1004
+ /**
1005
+ * Exchange OAuth code for access token
1006
+ */
1007
+ exchangeOAuthCode: (data: {
1008
+ code: string;
1009
+ redirectUri: string;
1010
+ }, fetchOptions?: BetterFetchOption) => Promise<OAuthTokenResponse>;
1011
+ }
1012
+ type MercadoPagoClient = MercadoPagoClientActions;
1013
+ declare const mercadoPagoClient: () => {
1014
+ id: "mercadoPago";
1015
+ $InferServerPlugin: ReturnType<typeof mercadoPagoPlugin>;
1016
+ getActions: ($fetch: any) => MercadoPagoClientActions;
1017
+ };
1018
+
1019
+ export { type CreatePaymentParams, type CreatePaymentResponse, type CreatePreapprovalPlanParams, type CreatePreapprovalPlanResponse, type CreateSubscriptionParams, type CreateSubscriptionResponse, type MarketplaceConfig, type MercadoPagoClient, type MercadoPagoClientActions, type MercadoPagoCustomerRecord, type MercadoPagoMarketplaceSplitRecord, type MercadoPagoOAuthTokenRecord, type MercadoPagoPaymentRecord, type MercadoPagoPaymentResponse, type MercadoPagoPluginOptions, type MercadoPagoPreApprovalResponse, type MercadoPagoPreapprovalPlanRecord, type MercadoPagoSubscriptionRecord, type OAuthTokenResponse, type OAuthUrlResponse, type PaymentItem, mercadoPagoClient, mercadoPagoPlugin };