better-auth-mercadopago 0.1.1 → 0.1.3

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 DELETED
@@ -1,1277 +0,0 @@
1
- import * as better_auth_client from 'better-auth/client';
2
- import { BetterFetchOption } from 'better-auth/client';
3
- import * as better_auth from 'better-auth';
4
- import { z } from 'zod';
5
-
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: "mercado-pago";
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
- declare const mercadoPagoClient: () => {
937
- id: "mercado-pago";
938
- $InferServerPlugin: ReturnType<typeof mercadoPagoPlugin>;
939
- getActions: ($fetch: better_auth_client.BetterFetch) => {
940
- /**
941
- * Get or create a Mercado Pago customer for the authenticated user
942
- */
943
- getOrCreateCustomer: (data?: {
944
- email?: string;
945
- firstName?: string;
946
- lastName?: string;
947
- }, fetchOptions?: BetterFetchOption) => Promise<{
948
- data: {
949
- customer: MercadoPagoCustomerRecord;
950
- };
951
- error: null;
952
- } | {
953
- data: null;
954
- error: {
955
- message?: string | undefined;
956
- status: number;
957
- statusText: string;
958
- };
959
- }>;
960
- /**
961
- * Create a payment and get checkout URL
962
- *
963
- * @example
964
- * ```ts
965
- * const { data } = await authClient.mercadoPago.createPayment({
966
- * items: [{
967
- * title: "Premium Plan",
968
- * quantity: 1,
969
- * unitPrice: 99.90,
970
- * currencyId: "ARS"
971
- * }]
972
- * });
973
- *
974
- * // Redirect user to checkout
975
- * window.location.href = data.checkoutUrl;
976
- * ```
977
- */
978
- createPayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<{
979
- data: null;
980
- error: {
981
- message?: string | undefined;
982
- status: number;
983
- statusText: string;
984
- };
985
- } | {
986
- data: CreatePaymentResponse;
987
- error: null;
988
- }>;
989
- /**
990
- * Create a marketplace payment with automatic split
991
- *
992
- * You need to have the seller's MP User ID (collector_id) which they get
993
- * after authorizing your app via OAuth.
994
- *
995
- * @example
996
- * ```ts
997
- * const { data } = await authClient.mercadoPago.createPayment({
998
- * items: [{
999
- * title: "Product from Seller",
1000
- * quantity: 1,
1001
- * unitPrice: 100
1002
- * }],
1003
- * marketplace: {
1004
- * collectorId: "123456789", // Seller's MP User ID
1005
- * applicationFeePercentage: 10 // Platform keeps 10%
1006
- * }
1007
- * });
1008
- * ```
1009
- */
1010
- createMarketplacePayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<{
1011
- data: null;
1012
- error: {
1013
- message?: string | undefined;
1014
- status: number;
1015
- statusText: string;
1016
- };
1017
- } | {
1018
- data: CreatePaymentResponse;
1019
- error: null;
1020
- }>;
1021
- /**
1022
- * Create a subscription with recurring payments
1023
- *
1024
- * Supports two modes:
1025
- * 1. With preapproval plan (reusable): Pass preapprovalPlanId
1026
- * 2. Direct subscription (one-off): Pass reason + autoRecurring
1027
- *
1028
- * @example With plan
1029
- * ```ts
1030
- * const { data } = await authClient.mercadoPago.createSubscription({
1031
- * preapprovalPlanId: "plan_abc123"
1032
- * });
1033
- * ```
1034
- *
1035
- * @example Direct (without plan)
1036
- * ```ts
1037
- * const { data } = await authClient.mercadoPago.createSubscription({
1038
- * reason: "Premium Monthly Plan",
1039
- * autoRecurring: {
1040
- * frequency: 1,
1041
- * frequencyType: "months",
1042
- * transactionAmount: 99.90,
1043
- * currencyId: "ARS"
1044
- * }
1045
- * });
1046
- * ```
1047
- */
1048
- createSubscription: (data: CreateSubscriptionParams, fetchOptions?: BetterFetchOption) => Promise<{
1049
- data: null;
1050
- error: {
1051
- message?: string | undefined;
1052
- status: number;
1053
- statusText: string;
1054
- };
1055
- } | {
1056
- data: CreateSubscriptionResponse;
1057
- error: null;
1058
- }>;
1059
- /**
1060
- * Cancel a subscription
1061
- *
1062
- * @example
1063
- * ```ts
1064
- * await authClient.mercadoPago.cancelSubscription({
1065
- * subscriptionId: "sub_123"
1066
- * });
1067
- * ```
1068
- */
1069
- cancelSubscription: (data: {
1070
- subscriptionId: string;
1071
- }, fetchOptions?: BetterFetchOption) => Promise<{
1072
- data: null;
1073
- error: {
1074
- message?: string | undefined;
1075
- status: number;
1076
- statusText: string;
1077
- };
1078
- } | {
1079
- data: {
1080
- success: boolean;
1081
- };
1082
- error: null;
1083
- }>;
1084
- /**
1085
- * Create a reusable preapproval plan (subscription template)
1086
- *
1087
- * Plans can be reused for multiple subscriptions. Create once,
1088
- * use many times with createSubscription({ preapprovalPlanId })
1089
- *
1090
- * @example
1091
- * ```ts
1092
- * const { data } = await authClient.mercadoPago.createPreapprovalPlan({
1093
- * reason: "Premium Monthly",
1094
- * autoRecurring: {
1095
- * frequency: 1,
1096
- * frequencyType: "months",
1097
- * transactionAmount: 99.90,
1098
- * freeTrial: {
1099
- * frequency: 7,
1100
- * frequencyType: "days"
1101
- * }
1102
- * },
1103
- * repetitions: 12 // 12 months, omit for infinite
1104
- * });
1105
- *
1106
- * // Use the plan
1107
- * const planId = data.plan.mercadoPagoPlanId;
1108
- * ```
1109
- */
1110
- createPreapprovalPlan: (data: CreatePreapprovalPlanParams, fetchOptions?: BetterFetchOption) => Promise<{
1111
- data: null;
1112
- error: {
1113
- message?: string | undefined;
1114
- status: number;
1115
- statusText: string;
1116
- };
1117
- } | {
1118
- data: CreatePreapprovalPlanResponse;
1119
- error: null;
1120
- }>;
1121
- /**
1122
- * List all preapproval plans
1123
- *
1124
- * @example
1125
- * ```ts
1126
- * const { data } = await authClient.mercadoPago.listPreapprovalPlans();
1127
- *
1128
- * data.plans.forEach(plan => {
1129
- * console.log(plan.reason); // "Premium Monthly"
1130
- * console.log(plan.transactionAmount); // 99.90
1131
- * });
1132
- * ```
1133
- */
1134
- listPreapprovalPlans: (fetchOptions?: BetterFetchOption) => Promise<{
1135
- data: null;
1136
- error: {
1137
- message?: string | undefined;
1138
- status: number;
1139
- statusText: string;
1140
- };
1141
- } | {
1142
- data: {
1143
- plans: MercadoPagoPreapprovalPlanRecord[];
1144
- };
1145
- error: null;
1146
- }>;
1147
- /**
1148
- * Get payment by ID
1149
- */
1150
- getPayment: (paymentId: string, fetchOptions?: BetterFetchOption) => Promise<{
1151
- data: null;
1152
- error: {
1153
- message?: string | undefined;
1154
- status: number;
1155
- statusText: string;
1156
- };
1157
- } | {
1158
- data: {
1159
- payment: MercadoPagoPaymentRecord;
1160
- };
1161
- error: null;
1162
- }>;
1163
- /**
1164
- * List all payments for the authenticated user
1165
- *
1166
- * @example
1167
- * ```ts
1168
- * const { data } = await authClient.mercadoPago.listPayments({
1169
- * limit: 20,
1170
- * offset: 0
1171
- * });
1172
- * ```
1173
- */
1174
- listPayments: (params?: {
1175
- limit?: number;
1176
- offset?: number;
1177
- }, fetchOptions?: BetterFetchOption) => Promise<{
1178
- data: null;
1179
- error: {
1180
- message?: string | undefined;
1181
- status: number;
1182
- statusText: string;
1183
- };
1184
- } | {
1185
- data: {
1186
- payments: MercadoPagoPaymentRecord[];
1187
- };
1188
- error: null;
1189
- }>;
1190
- /**
1191
- * List all subscriptions for the authenticated user
1192
- *
1193
- * @example
1194
- * ```ts
1195
- * const { data } = await authClient.mercadoPago.listSubscriptions();
1196
- * ```
1197
- */
1198
- listSubscriptions: (fetchOptions?: BetterFetchOption) => Promise<{
1199
- data: null;
1200
- error: {
1201
- message?: string | undefined;
1202
- status: number;
1203
- statusText: string;
1204
- };
1205
- } | {
1206
- data: {
1207
- subscriptions: MercadoPagoSubscriptionRecord[];
1208
- };
1209
- error: null;
1210
- }>;
1211
- /**
1212
- * Get OAuth authorization URL for marketplace sellers
1213
- *
1214
- * This is Step 1 of OAuth flow. Redirect the seller to this URL so they
1215
- * can authorize your app to process payments on their behalf.
1216
- *
1217
- * @example
1218
- * ```ts
1219
- * const { data } = await authClient.mercadoPago.getOAuthUrl({
1220
- * redirectUri: "https://myapp.com/oauth/callback"
1221
- * });
1222
- *
1223
- * // Redirect seller to authorize
1224
- * window.location.href = data.authUrl;
1225
- * ```
1226
- */
1227
- getOAuthUrl: (params: {
1228
- redirectUri: string;
1229
- }, fetchOptions?: BetterFetchOption) => Promise<{
1230
- data: null;
1231
- error: {
1232
- message?: string | undefined;
1233
- status: number;
1234
- statusText: string;
1235
- };
1236
- } | {
1237
- data: OAuthUrlResponse;
1238
- error: null;
1239
- }>;
1240
- /**
1241
- * Exchange OAuth code for access token
1242
- *
1243
- * This is Step 2 of OAuth flow. After the seller authorizes and MP redirects
1244
- * them back with a code, exchange that code for an access token.
1245
- *
1246
- * @example
1247
- * ```ts
1248
- * // In your /oauth/callback page:
1249
- * const code = new URLSearchParams(window.location.search).get("code");
1250
- *
1251
- * const { data } = await authClient.mercadoPago.exchangeOAuthCode({
1252
- * code,
1253
- * redirectUri: "https://myapp.com/oauth/callback"
1254
- * });
1255
- *
1256
- * // Now you have the seller's MP User ID
1257
- * console.log(data.oauthToken.mercadoPagoUserId);
1258
- * ```
1259
- */
1260
- exchangeOAuthCode: (data: {
1261
- code: string;
1262
- redirectUri: string;
1263
- }, fetchOptions?: BetterFetchOption) => Promise<{
1264
- data: null;
1265
- error: {
1266
- message?: string | undefined;
1267
- status: number;
1268
- statusText: string;
1269
- };
1270
- } | {
1271
- data: OAuthTokenResponse;
1272
- error: null;
1273
- }>;
1274
- };
1275
- };
1276
-
1277
- export { type CreatePaymentParams, type CreatePaymentResponse, type CreatePreapprovalPlanParams, type CreatePreapprovalPlanResponse, type CreateSubscriptionParams, type CreateSubscriptionResponse, type MarketplaceConfig, 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 };