@ar-agents/mercadopago 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -217,6 +217,347 @@ interface ParsedWebhookEvent {
217
217
  /** Raw body MP sent, for caller inspection / debugging. */
218
218
  raw: WebhookBody;
219
219
  }
220
+ /**
221
+ * Top-level lifecycle status of a payment. MP-canonical values; widened to
222
+ * string for forward compatibility.
223
+ */
224
+ declare const PaymentStatusSchema: z.ZodUnion<readonly [z.ZodLiteral<"pending">, z.ZodLiteral<"approved">, z.ZodLiteral<"authorized">, z.ZodLiteral<"in_process">, z.ZodLiteral<"in_mediation">, z.ZodLiteral<"rejected">, z.ZodLiteral<"cancelled">, z.ZodLiteral<"refunded">, z.ZodLiteral<"charged_back">, z.ZodString]>;
225
+ type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
226
+ /**
227
+ * The full Payment object MP returns. Many fields are optional because they
228
+ * vary by payment method, status, and integration mode (Checkout Pro vs API).
229
+ */
230
+ declare const PaymentSchema: z.ZodObject<{
231
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
232
+ status: z.ZodUnion<readonly [z.ZodLiteral<"pending">, z.ZodLiteral<"approved">, z.ZodLiteral<"authorized">, z.ZodLiteral<"in_process">, z.ZodLiteral<"in_mediation">, z.ZodLiteral<"rejected">, z.ZodLiteral<"cancelled">, z.ZodLiteral<"refunded">, z.ZodLiteral<"charged_back">, z.ZodString]>;
233
+ status_detail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
234
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
235
+ date_approved: z.ZodOptional<z.ZodNullable<z.ZodString>>;
236
+ date_last_updated: z.ZodOptional<z.ZodNullable<z.ZodString>>;
237
+ transaction_amount: z.ZodNumber;
238
+ currency_id: z.ZodString;
239
+ installments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
240
+ payment_method_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
241
+ payment_type_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
242
+ external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
243
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
244
+ payer: z.ZodOptional<z.ZodObject<{
245
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
246
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
247
+ identification: z.ZodOptional<z.ZodNullable<z.ZodObject<{
248
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
249
+ number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
250
+ }, z.core.$strip>>>;
251
+ }, z.core.$loose>>;
252
+ transaction_details: z.ZodOptional<z.ZodObject<{
253
+ net_received_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
254
+ total_paid_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
255
+ installment_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
256
+ }, z.core.$loose>>;
257
+ }, z.core.$loose>;
258
+ type Payment = z.infer<typeof PaymentSchema>;
259
+ /** Params for creating a payment (Checkout API / transparent flow). */
260
+ interface CreatePaymentParams {
261
+ /** Amount in account currency. ARS for Argentina. */
262
+ transactionAmount: number;
263
+ /** Number of installments. Use 1 for no cuotas; AR cards typically allow up to 12. */
264
+ installments?: number;
265
+ /** MP payment_method_id — `visa`, `master`, `naranja`, `account_money`, etc. */
266
+ paymentMethodId: string;
267
+ /** Payer email — REQUIRED. Cannot equal seller email. */
268
+ payerEmail: string;
269
+ /** Card token from MP frontend SDK (Cardform). Required for credit/debit; omit for `account_money` etc. */
270
+ token?: string;
271
+ /** Description shown in payer's MP statement. */
272
+ description?: string;
273
+ /** Your-system identifier for correlation. */
274
+ externalReference?: string;
275
+ /** Optional payer identification (DNI/CUIT) — required for some payment types. */
276
+ identification?: {
277
+ type: "DNI" | "CUIT" | "CUIL";
278
+ number: string;
279
+ };
280
+ /** Webhook override URL. Falls back to dashboard config if omitted. */
281
+ notificationUrl?: string;
282
+ /** AFIP/ARCA discount/fee/tax additions. Used to discriminate IVA, marketplace fees, etc. */
283
+ additionalInfo?: {
284
+ items?: Array<{
285
+ id?: string;
286
+ title: string;
287
+ quantity: number;
288
+ unit_price: number;
289
+ description?: string;
290
+ }>;
291
+ };
292
+ /** Statement descriptor — what shows on the buyer's card statement. Max 13 chars. */
293
+ statementDescriptor?: string;
294
+ /** When true, capture is deferred (only for credit cards) — useful for hold flows. */
295
+ capture?: boolean;
296
+ /** Idempotency key — pass the same value on retries to dedupe. Required for non-GET. */
297
+ idempotencyKey?: string;
298
+ }
299
+ interface SearchPaymentsParams {
300
+ /** Filter by external_reference (your-system id). */
301
+ externalReference?: string;
302
+ /** Filter by payment status. */
303
+ status?: PaymentStatus;
304
+ /** Filter by payer email. */
305
+ payerEmail?: string;
306
+ /** Date range for date_created (ISO 8601). */
307
+ beginDate?: string;
308
+ endDate?: string;
309
+ /** Result page (default 0). */
310
+ offset?: number;
311
+ /** Page size (default 30, max 100). */
312
+ limit?: number;
313
+ /** Sort: e.g. "date_created" desc. */
314
+ sort?: string;
315
+ criteria?: "asc" | "desc";
316
+ }
317
+ declare const PaymentsSearchResultSchema: z.ZodObject<{
318
+ paging: z.ZodObject<{
319
+ total: z.ZodNumber;
320
+ limit: z.ZodNumber;
321
+ offset: z.ZodNumber;
322
+ }, z.core.$strip>;
323
+ results: z.ZodArray<z.ZodObject<{
324
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
325
+ status: z.ZodUnion<readonly [z.ZodLiteral<"pending">, z.ZodLiteral<"approved">, z.ZodLiteral<"authorized">, z.ZodLiteral<"in_process">, z.ZodLiteral<"in_mediation">, z.ZodLiteral<"rejected">, z.ZodLiteral<"cancelled">, z.ZodLiteral<"refunded">, z.ZodLiteral<"charged_back">, z.ZodString]>;
326
+ status_detail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
327
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
328
+ date_approved: z.ZodOptional<z.ZodNullable<z.ZodString>>;
329
+ date_last_updated: z.ZodOptional<z.ZodNullable<z.ZodString>>;
330
+ transaction_amount: z.ZodNumber;
331
+ currency_id: z.ZodString;
332
+ installments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
333
+ payment_method_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
334
+ payment_type_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
335
+ external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
336
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
337
+ payer: z.ZodOptional<z.ZodObject<{
338
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
339
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
340
+ identification: z.ZodOptional<z.ZodNullable<z.ZodObject<{
341
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
342
+ number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
343
+ }, z.core.$strip>>>;
344
+ }, z.core.$loose>>;
345
+ transaction_details: z.ZodOptional<z.ZodObject<{
346
+ net_received_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
347
+ total_paid_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
348
+ installment_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
349
+ }, z.core.$loose>>;
350
+ }, z.core.$loose>>;
351
+ }, z.core.$strip>;
352
+ type PaymentsSearchResult = z.infer<typeof PaymentsSearchResultSchema>;
353
+ declare const RefundSchema: z.ZodObject<{
354
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
355
+ payment_id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
356
+ amount: z.ZodNumber;
357
+ source: z.ZodOptional<z.ZodNullable<z.ZodObject<{
358
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
359
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
360
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
361
+ }, z.core.$strip>>>;
362
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
363
+ status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
364
+ }, z.core.$loose>;
365
+ type Refund = z.infer<typeof RefundSchema>;
366
+ interface CreateRefundParams {
367
+ paymentId: string;
368
+ /** Partial refund amount. Omit for full refund. */
369
+ amount?: number;
370
+ /** Idempotency key — required for retry-safety. */
371
+ idempotencyKey?: string;
372
+ }
373
+ declare const PreferenceItemSchema: z.ZodObject<{
374
+ id: z.ZodOptional<z.ZodString>;
375
+ title: z.ZodString;
376
+ description: z.ZodOptional<z.ZodString>;
377
+ picture_url: z.ZodOptional<z.ZodString>;
378
+ category_id: z.ZodOptional<z.ZodString>;
379
+ quantity: z.ZodNumber;
380
+ unit_price: z.ZodNumber;
381
+ currency_id: z.ZodOptional<z.ZodEnum<{
382
+ ARS: "ARS";
383
+ USD: "USD";
384
+ BRL: "BRL";
385
+ MXN: "MXN";
386
+ }>>;
387
+ }, z.core.$strip>;
388
+ type PreferenceItem = z.infer<typeof PreferenceItemSchema>;
389
+ declare const PreferenceSchema: z.ZodObject<{
390
+ id: z.ZodString;
391
+ init_point: z.ZodOptional<z.ZodString>;
392
+ sandbox_init_point: z.ZodOptional<z.ZodString>;
393
+ client_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
394
+ collector_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
395
+ items: z.ZodOptional<z.ZodArray<z.ZodObject<{
396
+ id: z.ZodOptional<z.ZodString>;
397
+ title: z.ZodString;
398
+ description: z.ZodOptional<z.ZodString>;
399
+ picture_url: z.ZodOptional<z.ZodString>;
400
+ category_id: z.ZodOptional<z.ZodString>;
401
+ quantity: z.ZodNumber;
402
+ unit_price: z.ZodNumber;
403
+ currency_id: z.ZodOptional<z.ZodEnum<{
404
+ ARS: "ARS";
405
+ USD: "USD";
406
+ BRL: "BRL";
407
+ MXN: "MXN";
408
+ }>>;
409
+ }, z.core.$strip>>>;
410
+ external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
411
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
412
+ expires: z.ZodOptional<z.ZodBoolean>;
413
+ expiration_date_from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
414
+ expiration_date_to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
415
+ }, z.core.$loose>;
416
+ type Preference = z.infer<typeof PreferenceSchema>;
417
+ interface CreatePreferenceParams {
418
+ items: Array<{
419
+ title: string;
420
+ quantity: number;
421
+ unit_price: number;
422
+ currency_id?: CurrencyId;
423
+ description?: string;
424
+ picture_url?: string;
425
+ }>;
426
+ payer?: {
427
+ name?: string;
428
+ surname?: string;
429
+ email?: string;
430
+ phone?: {
431
+ area_code?: string;
432
+ number?: string;
433
+ };
434
+ identification?: {
435
+ type: string;
436
+ number: string;
437
+ };
438
+ address?: {
439
+ street_name?: string;
440
+ street_number?: number;
441
+ zip_code?: string;
442
+ };
443
+ };
444
+ /** Where to send the buyer after success/failure/pending. */
445
+ backUrls?: {
446
+ success?: string;
447
+ failure?: string;
448
+ pending?: string;
449
+ };
450
+ /** "approved" → auto-redirect on success; "all" → always; "" → never. */
451
+ autoReturn?: "approved" | "all";
452
+ /** Webhook URL. */
453
+ notificationUrl?: string;
454
+ /** Your-system id for correlation. */
455
+ externalReference?: string;
456
+ /** Max installments offered. Defaults to MP account config. */
457
+ paymentMethods?: {
458
+ excluded_payment_types?: Array<{
459
+ id: string;
460
+ }>;
461
+ excluded_payment_methods?: Array<{
462
+ id: string;
463
+ }>;
464
+ installments?: number;
465
+ default_installments?: number;
466
+ };
467
+ /** Statement descriptor — shows on buyer's card statement. */
468
+ statementDescriptor?: string;
469
+ /** Expiration window for the link itself. */
470
+ expires?: boolean;
471
+ expirationDateFrom?: string;
472
+ expirationDateTo?: string;
473
+ }
474
+ declare const CustomerSchema: z.ZodObject<{
475
+ id: z.ZodString;
476
+ email: z.ZodString;
477
+ first_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
478
+ last_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
479
+ phone: z.ZodOptional<z.ZodNullable<z.ZodObject<{
480
+ area_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
481
+ number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
482
+ }, z.core.$strip>>>;
483
+ identification: z.ZodOptional<z.ZodNullable<z.ZodObject<{
484
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
485
+ number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
486
+ }, z.core.$strip>>>;
487
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
488
+ date_last_updated: z.ZodOptional<z.ZodNullable<z.ZodString>>;
489
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
490
+ }, z.core.$loose>;
491
+ type Customer = z.infer<typeof CustomerSchema>;
492
+ declare const CustomerCardSchema: z.ZodObject<{
493
+ id: z.ZodString;
494
+ customer_id: z.ZodString;
495
+ expiration_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
496
+ expiration_year: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
497
+ first_six_digits: z.ZodOptional<z.ZodNullable<z.ZodString>>;
498
+ last_four_digits: z.ZodOptional<z.ZodNullable<z.ZodString>>;
499
+ payment_method: z.ZodOptional<z.ZodNullable<z.ZodObject<{
500
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
501
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
502
+ payment_type_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
503
+ }, z.core.$strip>>>;
504
+ date_created: z.ZodOptional<z.ZodNullable<z.ZodString>>;
505
+ }, z.core.$loose>;
506
+ type CustomerCard = z.infer<typeof CustomerCardSchema>;
507
+ interface CreateCustomerParams {
508
+ email: string;
509
+ firstName?: string;
510
+ lastName?: string;
511
+ phone?: {
512
+ areaCode?: string;
513
+ number?: string;
514
+ };
515
+ identification?: {
516
+ type: "DNI" | "CUIT" | "CUIL";
517
+ number: string;
518
+ };
519
+ description?: string;
520
+ }
521
+ declare const PaymentMethodSchema: z.ZodObject<{
522
+ id: z.ZodString;
523
+ name: z.ZodString;
524
+ payment_type_id: z.ZodString;
525
+ status: z.ZodString;
526
+ thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
527
+ secure_thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
528
+ min_allowed_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
529
+ max_allowed_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
530
+ }, z.core.$loose>;
531
+ type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
532
+ declare const InstallmentOfferSchema: z.ZodObject<{
533
+ payment_method_id: z.ZodString;
534
+ payment_type_id: z.ZodString;
535
+ issuer: z.ZodOptional<z.ZodNullable<z.ZodObject<{
536
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
537
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
538
+ }, z.core.$strip>>>;
539
+ payer_costs: z.ZodArray<z.ZodObject<{
540
+ installments: z.ZodNumber;
541
+ installment_rate: z.ZodNumber;
542
+ discount_rate: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
543
+ installment_amount: z.ZodNumber;
544
+ total_amount: z.ZodNumber;
545
+ recommended_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
546
+ }, z.core.$loose>>;
547
+ }, z.core.$loose>;
548
+ type InstallmentOffer = z.infer<typeof InstallmentOfferSchema>;
549
+ declare const AccountInfoSchema: z.ZodObject<{
550
+ id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
551
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
552
+ nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
553
+ country_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
554
+ site_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
555
+ user_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
556
+ status: z.ZodOptional<z.ZodNullable<z.ZodObject<{
557
+ user_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
558
+ }, z.core.$loose>>>;
559
+ }, z.core.$loose>;
560
+ type AccountInfo = z.infer<typeof AccountInfoSchema>;
220
561
 
221
562
  interface MercadoPagoClientOptions {
222
563
  /** Access token. TEST- prefix for sandbox, APP_USR- for production. */
@@ -233,9 +574,11 @@ interface MercadoPagoClientOptions {
233
574
  fetch?: typeof fetch;
234
575
  }
235
576
  /**
236
- * Thin, typed wrapper around Mercado Pago's REST API. Only the endpoints the
237
- * agent layer needs are exposed; this is deliberately narrow rather than a
238
- * full SDK rebuild.
577
+ * Thin, typed wrapper around Mercado Pago's REST API. Exposes the surface
578
+ * the agent layer needs: Subscriptions (Preapprovals), Payments, Checkout Pro
579
+ * (Preferences), Customers + saved Cards, Refunds, Payment Methods +
580
+ * Installments, and Account info. Deliberately narrower than a full SDK
581
+ * rebuild — we add endpoints when the agent layer needs them.
239
582
  */
240
583
  declare class MercadoPagoClient {
241
584
  private readonly accessToken;
@@ -249,28 +592,98 @@ declare class MercadoPagoClient {
249
592
  * CVV — there is no API path that bypasses this human step.
250
593
  */
251
594
  createPreapproval(params: CreatePreapprovalParams): Promise<Preapproval>;
595
+ getPreapproval(id: string): Promise<Preapproval>;
596
+ cancelPreapproval(id: string): Promise<Preapproval>;
597
+ pausePreapproval(id: string): Promise<Preapproval>;
598
+ resumePreapproval(id: string): Promise<Preapproval>;
252
599
  /**
253
- * Fetch the current state of a preapproval. Useful to confirm whether the
254
- * buyer has completed the first payment (`status: 'authorized'`) or whether
255
- * the subscription was cancelled.
600
+ * Create a payment. Two main flows:
601
+ * - **Card payment**: pass `token` (from MP frontend Cardform) + payment_method_id.
602
+ * - **Account money / cash**: omit token, pass payment_method_id like "account_money", "rapipago", "pagofacil".
603
+ *
604
+ * For credit card payments where you don't have a card token (i.e., you only
605
+ * have a payer email and want to send them a payment link), use
606
+ * `createPreference` (Checkout Pro) instead.
607
+ *
608
+ * Idempotency: pass `idempotencyKey` to safely retry. Required for production
609
+ * to dedupe network-failed requests.
256
610
  */
257
- getPreapproval(id: string): Promise<Preapproval>;
611
+ createPayment(params: CreatePaymentParams): Promise<Payment>;
612
+ /** Fetch a payment by ID. */
613
+ getPayment(id: string): Promise<Payment>;
258
614
  /**
259
- * Cancel an active preapproval. Irreversible: MP will not charge the buyer
260
- * again and the subscription cannot be reactivated.
615
+ * Search payments with filters. Common: by external_reference (your-system
616
+ * id), by status, by date range. Pagination via offset + limit (max 100).
261
617
  */
262
- cancelPreapproval(id: string): Promise<Preapproval>;
618
+ searchPayments(params?: SearchPaymentsParams): Promise<PaymentsSearchResult>;
263
619
  /**
264
- * Pause an authorized preapproval. The subscription stops auto-charging but
265
- * can be re-activated. Note: MP only allows pausing subs that are currently
266
- * `authorized` — pending/cancelled subs reject this.
620
+ * Capture a previously authorized payment. Only works for credit-card
621
+ * payments created with `capture: false`. Optional partial capture amount.
267
622
  */
268
- pausePreapproval(id: string): Promise<Preapproval>;
623
+ capturePayment(id: string, amount?: number): Promise<Payment>;
269
624
  /**
270
- * Re-activate a paused preapproval. Charges resume on the next scheduled
271
- * date.
625
+ * Cancel a pending or in_process payment. Once approved, you must use
626
+ * `createRefund` instead.
272
627
  */
273
- resumePreapproval(id: string): Promise<Preapproval>;
628
+ cancelPayment(id: string): Promise<Payment>;
629
+ /**
630
+ * Refund a payment fully (omit `amount`) or partially. Idempotency key
631
+ * recommended — refunds can fail mid-flight and you don't want double-refunds
632
+ * on retry.
633
+ */
634
+ createRefund(params: CreateRefundParams): Promise<Refund>;
635
+ listRefunds(paymentId: string): Promise<Refund[]>;
636
+ getRefund(paymentId: string, refundId: string): Promise<Refund>;
637
+ /**
638
+ * Create a payment preference for Checkout Pro. Returns `init_point` URL
639
+ * where the buyer completes payment on MP-hosted form. This is the
640
+ * recommended flow when you don't have a card token (most common path for
641
+ * agents — you don't want to handle PCI data).
642
+ *
643
+ * Sandbox: use `sandbox_init_point` instead of `init_point`.
644
+ */
645
+ createPreference(params: CreatePreferenceParams): Promise<Preference>;
646
+ getPreference(id: string): Promise<Preference>;
647
+ updatePreference(id: string, patch: Partial<CreatePreferenceParams>): Promise<Preference>;
648
+ createCustomer(params: CreateCustomerParams): Promise<Customer>;
649
+ getCustomer(id: string): Promise<Customer>;
650
+ /**
651
+ * Search customers. Most common: by email (returns 0 or 1 result).
652
+ * Note: MP's `/v1/customers/search` returns a paginated wrapper, not a flat array.
653
+ */
654
+ searchCustomers(params?: {
655
+ email?: string;
656
+ limit?: number;
657
+ offset?: number;
658
+ }): Promise<{
659
+ paging: {
660
+ total: number;
661
+ limit: number;
662
+ offset: number;
663
+ };
664
+ results: Customer[];
665
+ }>;
666
+ listCustomerCards(customerId: string): Promise<CustomerCard[]>;
667
+ getCustomerCard(customerId: string, cardId: string): Promise<CustomerCard>;
668
+ deleteCustomerCard(customerId: string, cardId: string): Promise<void>;
669
+ /** List all payment methods enabled for the account's site (MLA = Argentina). */
670
+ listPaymentMethods(): Promise<PaymentMethod[]>;
671
+ /**
672
+ * Get installment options for an amount. THE killer AR feature — returns
673
+ * `payer_costs` with `recommended_message` strings like "12 cuotas sin
674
+ * interés de $X" that you should surface verbatim to the user.
675
+ *
676
+ * Pass `bin` (first 6 digits of card) for issuer-specific offers (e.g.,
677
+ * Naranja's interest-free promotions). Without bin, returns generic offers.
678
+ */
679
+ getInstallments(params: {
680
+ amount: number;
681
+ paymentMethodId?: string;
682
+ bin?: string;
683
+ issuerId?: string;
684
+ }): Promise<InstallmentOffer[]>;
685
+ /** Get info about the account that owns this access token. */
686
+ getMe(): Promise<AccountInfo>;
274
687
  }
275
688
 
276
689
  /**
@@ -333,12 +746,17 @@ interface MercadoPagoToolsOptions {
333
746
  * Useful for localizing the agent's tool reasoning.
334
747
  */
335
748
  descriptions?: Partial<Record<ToolName, string>>;
749
+ /**
750
+ * Default notification webhook URL used when callers don't supply one.
751
+ * Optional — MP falls back to dashboard config if not set.
752
+ */
753
+ notificationUrl?: string;
336
754
  }
337
- type ToolName = "create_subscription" | "get_subscription_status" | "cancel_subscription" | "pause_subscription" | "resume_subscription";
755
+ type ToolName = "create_subscription" | "get_subscription_status" | "cancel_subscription" | "pause_subscription" | "resume_subscription" | "create_payment" | "get_payment" | "search_payments" | "cancel_payment" | "capture_payment" | "refund_payment" | "list_refunds" | "create_payment_preference" | "get_payment_preference" | "create_customer" | "find_customer_by_email" | "list_customer_cards" | "delete_customer_card" | "list_payment_methods" | "calculate_installments" | "get_account_info";
338
756
  /**
339
- * Build a tool set for the Vercel AI SDK that exposes Mercado Pago Subscriptions
340
- * to an agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge
341
- * with other tool sets.
757
+ * Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
758
+ * agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
759
+ * other tool sets.
342
760
  *
343
761
  * @example
344
762
  * ```ts
@@ -400,4 +818,4 @@ declare function verifyWebhookSignature(params: {
400
818
  secret: string;
401
819
  }): boolean;
402
820
 
403
- export { type AutoRecurring, type CreatePreapprovalParams, type CurrencyId, type FrequencyType, InMemoryStateAdapter, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Preapproval, type PreapprovalStatus, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
821
+ export { type AccountInfo, type AutoRecurring, type CreateCustomerParams, type CreatePaymentParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateRefundParams, type CurrencyId, type Customer, type CustomerCard, type FrequencyType, InMemoryStateAdapter, type InstallmentOffer, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type Refund, type SearchPaymentsParams, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };