@ar-agents/mercadopago 0.2.0 → 0.3.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/CHANGELOG.md +53 -0
- package/dist/index.cjs +367 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -2
- package/dist/index.d.ts +138 -2
- package/dist/index.js +366 -22
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -66,6 +66,23 @@ declare class MercadoPagoRateLimitError extends MercadoPagoError {
|
|
|
66
66
|
retryAfterSeconds: number | null;
|
|
67
67
|
constructor(endpoint: string, retryAfterSeconds: number | null, body?: unknown);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Thrown when MP is overloaded and serves an HTML 503 page instead of a JSON
|
|
71
|
+
* error. The library detects content-type !== application/json on 5xx and
|
|
72
|
+
* raises this typed error so retry logic + agent UX can branch correctly.
|
|
73
|
+
*/
|
|
74
|
+
declare class MercadoPagoOverloadedError extends MercadoPagoError {
|
|
75
|
+
constructor(endpoint: string, status: number);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when a request exceeds the configured `requestTimeoutMs`. Retried
|
|
79
|
+
* automatically up to `maxRetries`; this surfaces only when the budget runs
|
|
80
|
+
* out.
|
|
81
|
+
*/
|
|
82
|
+
declare class MercadoPagoTimeoutError extends MercadoPagoError {
|
|
83
|
+
readonly timeoutMs: number;
|
|
84
|
+
constructor(endpoint: string, timeoutMs: number);
|
|
85
|
+
}
|
|
69
86
|
/**
|
|
70
87
|
* Maps an MP error response body to the most specific known error class. Falls
|
|
71
88
|
* back to the generic MercadoPagoError when no specific pattern matches.
|
|
@@ -546,6 +563,50 @@ declare const InstallmentOfferSchema: z.ZodObject<{
|
|
|
546
563
|
}, z.core.$loose>>;
|
|
547
564
|
}, z.core.$loose>;
|
|
548
565
|
type InstallmentOffer = z.infer<typeof InstallmentOfferSchema>;
|
|
566
|
+
declare const QrOrderSchema: z.ZodObject<{
|
|
567
|
+
in_store_order_id: z.ZodString;
|
|
568
|
+
qr_data: z.ZodString;
|
|
569
|
+
}, z.core.$loose>;
|
|
570
|
+
type QrOrder = z.infer<typeof QrOrderSchema>;
|
|
571
|
+
interface CreateQrPaymentParams {
|
|
572
|
+
/** Pre-configured POS external_id from MP dashboard. Required. */
|
|
573
|
+
externalPosId: string;
|
|
574
|
+
/** Total amount in ARS. */
|
|
575
|
+
totalAmount: number;
|
|
576
|
+
/** Display title shown to the buyer when scanning. */
|
|
577
|
+
title: string;
|
|
578
|
+
description?: string;
|
|
579
|
+
/** Webhook URL — MP fires `point_integration_wh` then `payment` topic. */
|
|
580
|
+
notificationUrl?: string;
|
|
581
|
+
/** Your-system identifier for correlation. */
|
|
582
|
+
externalReference?: string;
|
|
583
|
+
/** ISO 8601 expiration (default 10 min from now). */
|
|
584
|
+
expirationDate?: string;
|
|
585
|
+
/** Itemized line items (optional but improves analytics). */
|
|
586
|
+
items?: Array<{
|
|
587
|
+
title: string;
|
|
588
|
+
quantity: number;
|
|
589
|
+
unit_price: number;
|
|
590
|
+
unit_measure?: string;
|
|
591
|
+
total_amount?: number;
|
|
592
|
+
}>;
|
|
593
|
+
}
|
|
594
|
+
declare const CardTokenSchema: z.ZodObject<{
|
|
595
|
+
id: z.ZodString;
|
|
596
|
+
status: z.ZodOptional<z.ZodString>;
|
|
597
|
+
date_due: z.ZodOptional<z.ZodString>;
|
|
598
|
+
card_id: z.ZodOptional<z.ZodString>;
|
|
599
|
+
cardholder: z.ZodOptional<z.ZodUnknown>;
|
|
600
|
+
}, z.core.$loose>;
|
|
601
|
+
type CardToken = z.infer<typeof CardTokenSchema>;
|
|
602
|
+
interface CreateCardTokenParams {
|
|
603
|
+
/** Saved card id (from list_customer_cards). */
|
|
604
|
+
cardId: string;
|
|
605
|
+
/** Customer that owns the card. */
|
|
606
|
+
customerId: string;
|
|
607
|
+
/** CVV — required for AR; MP doesn't store CVV. */
|
|
608
|
+
securityCode: string;
|
|
609
|
+
}
|
|
549
610
|
declare const AccountInfoSchema: z.ZodObject<{
|
|
550
611
|
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
551
612
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -572,6 +633,29 @@ interface MercadoPagoClientOptions {
|
|
|
572
633
|
* inject your own retry/instrumentation layer or to test with MSW.
|
|
573
634
|
*/
|
|
574
635
|
fetch?: typeof fetch;
|
|
636
|
+
/**
|
|
637
|
+
* Per-request timeout in ms. Aborts the request and throws if exceeded.
|
|
638
|
+
* Default 30_000 (30s). MP can be slow under load; 30s is a safe upper bound.
|
|
639
|
+
*/
|
|
640
|
+
requestTimeoutMs?: number;
|
|
641
|
+
/**
|
|
642
|
+
* Number of retries on 5xx + network errors. Default 1 (single retry).
|
|
643
|
+
* 4xx errors are NEVER retried (they're user/config errors). Each retry
|
|
644
|
+
* uses exponential backoff: 250ms, 500ms, 1000ms, ...
|
|
645
|
+
*/
|
|
646
|
+
maxRetries?: number;
|
|
647
|
+
/**
|
|
648
|
+
* Observability hook fired AFTER every request (success or failure).
|
|
649
|
+
* Useful for logging, metrics, tracing. Synchronous, fire-and-forget.
|
|
650
|
+
*/
|
|
651
|
+
onCall?: (event: {
|
|
652
|
+
method: string;
|
|
653
|
+
path: string;
|
|
654
|
+
durationMs: number;
|
|
655
|
+
httpStatus: number | null;
|
|
656
|
+
retried: number;
|
|
657
|
+
success: boolean;
|
|
658
|
+
}) => void;
|
|
575
659
|
}
|
|
576
660
|
/**
|
|
577
661
|
* Thin, typed wrapper around Mercado Pago's REST API. Exposes the surface
|
|
@@ -584,6 +668,9 @@ declare class MercadoPagoClient {
|
|
|
584
668
|
private readonly accessToken;
|
|
585
669
|
private readonly baseUrl;
|
|
586
670
|
private readonly fetchImpl;
|
|
671
|
+
private readonly requestTimeoutMs;
|
|
672
|
+
private readonly maxRetries;
|
|
673
|
+
private readonly onCall;
|
|
587
674
|
constructor(options: MercadoPagoClientOptions);
|
|
588
675
|
private request;
|
|
589
676
|
/**
|
|
@@ -684,6 +771,55 @@ declare class MercadoPagoClient {
|
|
|
684
771
|
}): Promise<InstallmentOffer[]>;
|
|
685
772
|
/** Get info about the account that owns this access token. */
|
|
686
773
|
getMe(): Promise<AccountInfo>;
|
|
774
|
+
/**
|
|
775
|
+
* Create a single-use card token from a saved card. This is the server-side
|
|
776
|
+
* retokenization path (PCI-safe because the card data lives in MP's vault,
|
|
777
|
+
* we only pass the saved card_id + customer_id + the user-supplied CVV).
|
|
778
|
+
*
|
|
779
|
+
* Tokens expire in 7 days but typically burn on first use. AR currently
|
|
780
|
+
* REQUIRES CVV on every charge (MP doesn't store it); skipping CVV requires
|
|
781
|
+
* a private MP product enablement, not a public API.
|
|
782
|
+
*/
|
|
783
|
+
createCardToken(params: CreateCardTokenParams): Promise<CardToken>;
|
|
784
|
+
/**
|
|
785
|
+
* High-level helper: charge a saved card in 3 steps.
|
|
786
|
+
* 1. Mint a card token from {customer_id, card_id, security_code}
|
|
787
|
+
* 2. Lookup card to fill payment_method_id (avoids agent guessing)
|
|
788
|
+
* 3. Create the payment with the token + idempotency key
|
|
789
|
+
*
|
|
790
|
+
* Returns the resulting Payment. Uses deterministic idempotency from
|
|
791
|
+
* (card_id, amount, externalReference) so retries dedupe on MP's side.
|
|
792
|
+
*/
|
|
793
|
+
chargeSavedCard(params: {
|
|
794
|
+
customerId: string;
|
|
795
|
+
cardId: string;
|
|
796
|
+
securityCode: string;
|
|
797
|
+
amount: number;
|
|
798
|
+
description: string;
|
|
799
|
+
installments?: number;
|
|
800
|
+
externalReference?: string;
|
|
801
|
+
statementDescriptor?: string;
|
|
802
|
+
idempotencyKey?: string;
|
|
803
|
+
}): Promise<Payment>;
|
|
804
|
+
/**
|
|
805
|
+
* Create a dynamic in-store QR order. Returns `qr_data` (EMVCo TLV string)
|
|
806
|
+
* + `in_store_order_id`. The buyer scans the QR with any AR wallet (Modo,
|
|
807
|
+
* BNA+, Cuenta DNI, Naranja X, etc. — interop is mandated by Transferencias
|
|
808
|
+
* 3.0). On payment, MP fires `point_integration_wh` then `payment` topics.
|
|
809
|
+
*
|
|
810
|
+
* Requires a pre-configured POS (`external_pos_id` from MP dashboard or
|
|
811
|
+
* `POST /pos`). The seller's `user_id` is auto-fetched from `/users/me`.
|
|
812
|
+
*
|
|
813
|
+
* The lib does NOT render the QR image — pass `qr_data` to a QR renderer
|
|
814
|
+
* (e.g., `qrcode` package) to get a data URL. The agent tool layer wraps
|
|
815
|
+
* this and returns both raw + data URL.
|
|
816
|
+
*/
|
|
817
|
+
createQrPayment(userId: string, params: CreateQrPaymentParams): Promise<QrOrder>;
|
|
818
|
+
/**
|
|
819
|
+
* Cancel a pending QR order on a POS. Necessary if the buyer never scans
|
|
820
|
+
* — otherwise the next `createQrPayment` on the same POS returns 409.
|
|
821
|
+
*/
|
|
822
|
+
cancelQrPayment(userId: string, externalPosId: string): Promise<void>;
|
|
687
823
|
}
|
|
688
824
|
|
|
689
825
|
/**
|
|
@@ -752,7 +888,7 @@ interface MercadoPagoToolsOptions {
|
|
|
752
888
|
*/
|
|
753
889
|
notificationUrl?: string;
|
|
754
890
|
}
|
|
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";
|
|
891
|
+
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" | "charge_saved_card" | "create_qr_payment" | "cancel_qr_payment";
|
|
756
892
|
/**
|
|
757
893
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
758
894
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -818,4 +954,4 @@ declare function verifyWebhookSignature(params: {
|
|
|
818
954
|
secret: string;
|
|
819
955
|
}): boolean;
|
|
820
956
|
|
|
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 };
|
|
957
|
+
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreatePaymentParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CurrencyId, type Customer, type CustomerCard, type FrequencyType, InMemoryStateAdapter, type InstallmentOffer, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,23 @@ declare class MercadoPagoRateLimitError extends MercadoPagoError {
|
|
|
66
66
|
retryAfterSeconds: number | null;
|
|
67
67
|
constructor(endpoint: string, retryAfterSeconds: number | null, body?: unknown);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Thrown when MP is overloaded and serves an HTML 503 page instead of a JSON
|
|
71
|
+
* error. The library detects content-type !== application/json on 5xx and
|
|
72
|
+
* raises this typed error so retry logic + agent UX can branch correctly.
|
|
73
|
+
*/
|
|
74
|
+
declare class MercadoPagoOverloadedError extends MercadoPagoError {
|
|
75
|
+
constructor(endpoint: string, status: number);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when a request exceeds the configured `requestTimeoutMs`. Retried
|
|
79
|
+
* automatically up to `maxRetries`; this surfaces only when the budget runs
|
|
80
|
+
* out.
|
|
81
|
+
*/
|
|
82
|
+
declare class MercadoPagoTimeoutError extends MercadoPagoError {
|
|
83
|
+
readonly timeoutMs: number;
|
|
84
|
+
constructor(endpoint: string, timeoutMs: number);
|
|
85
|
+
}
|
|
69
86
|
/**
|
|
70
87
|
* Maps an MP error response body to the most specific known error class. Falls
|
|
71
88
|
* back to the generic MercadoPagoError when no specific pattern matches.
|
|
@@ -546,6 +563,50 @@ declare const InstallmentOfferSchema: z.ZodObject<{
|
|
|
546
563
|
}, z.core.$loose>>;
|
|
547
564
|
}, z.core.$loose>;
|
|
548
565
|
type InstallmentOffer = z.infer<typeof InstallmentOfferSchema>;
|
|
566
|
+
declare const QrOrderSchema: z.ZodObject<{
|
|
567
|
+
in_store_order_id: z.ZodString;
|
|
568
|
+
qr_data: z.ZodString;
|
|
569
|
+
}, z.core.$loose>;
|
|
570
|
+
type QrOrder = z.infer<typeof QrOrderSchema>;
|
|
571
|
+
interface CreateQrPaymentParams {
|
|
572
|
+
/** Pre-configured POS external_id from MP dashboard. Required. */
|
|
573
|
+
externalPosId: string;
|
|
574
|
+
/** Total amount in ARS. */
|
|
575
|
+
totalAmount: number;
|
|
576
|
+
/** Display title shown to the buyer when scanning. */
|
|
577
|
+
title: string;
|
|
578
|
+
description?: string;
|
|
579
|
+
/** Webhook URL — MP fires `point_integration_wh` then `payment` topic. */
|
|
580
|
+
notificationUrl?: string;
|
|
581
|
+
/** Your-system identifier for correlation. */
|
|
582
|
+
externalReference?: string;
|
|
583
|
+
/** ISO 8601 expiration (default 10 min from now). */
|
|
584
|
+
expirationDate?: string;
|
|
585
|
+
/** Itemized line items (optional but improves analytics). */
|
|
586
|
+
items?: Array<{
|
|
587
|
+
title: string;
|
|
588
|
+
quantity: number;
|
|
589
|
+
unit_price: number;
|
|
590
|
+
unit_measure?: string;
|
|
591
|
+
total_amount?: number;
|
|
592
|
+
}>;
|
|
593
|
+
}
|
|
594
|
+
declare const CardTokenSchema: z.ZodObject<{
|
|
595
|
+
id: z.ZodString;
|
|
596
|
+
status: z.ZodOptional<z.ZodString>;
|
|
597
|
+
date_due: z.ZodOptional<z.ZodString>;
|
|
598
|
+
card_id: z.ZodOptional<z.ZodString>;
|
|
599
|
+
cardholder: z.ZodOptional<z.ZodUnknown>;
|
|
600
|
+
}, z.core.$loose>;
|
|
601
|
+
type CardToken = z.infer<typeof CardTokenSchema>;
|
|
602
|
+
interface CreateCardTokenParams {
|
|
603
|
+
/** Saved card id (from list_customer_cards). */
|
|
604
|
+
cardId: string;
|
|
605
|
+
/** Customer that owns the card. */
|
|
606
|
+
customerId: string;
|
|
607
|
+
/** CVV — required for AR; MP doesn't store CVV. */
|
|
608
|
+
securityCode: string;
|
|
609
|
+
}
|
|
549
610
|
declare const AccountInfoSchema: z.ZodObject<{
|
|
550
611
|
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
551
612
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -572,6 +633,29 @@ interface MercadoPagoClientOptions {
|
|
|
572
633
|
* inject your own retry/instrumentation layer or to test with MSW.
|
|
573
634
|
*/
|
|
574
635
|
fetch?: typeof fetch;
|
|
636
|
+
/**
|
|
637
|
+
* Per-request timeout in ms. Aborts the request and throws if exceeded.
|
|
638
|
+
* Default 30_000 (30s). MP can be slow under load; 30s is a safe upper bound.
|
|
639
|
+
*/
|
|
640
|
+
requestTimeoutMs?: number;
|
|
641
|
+
/**
|
|
642
|
+
* Number of retries on 5xx + network errors. Default 1 (single retry).
|
|
643
|
+
* 4xx errors are NEVER retried (they're user/config errors). Each retry
|
|
644
|
+
* uses exponential backoff: 250ms, 500ms, 1000ms, ...
|
|
645
|
+
*/
|
|
646
|
+
maxRetries?: number;
|
|
647
|
+
/**
|
|
648
|
+
* Observability hook fired AFTER every request (success or failure).
|
|
649
|
+
* Useful for logging, metrics, tracing. Synchronous, fire-and-forget.
|
|
650
|
+
*/
|
|
651
|
+
onCall?: (event: {
|
|
652
|
+
method: string;
|
|
653
|
+
path: string;
|
|
654
|
+
durationMs: number;
|
|
655
|
+
httpStatus: number | null;
|
|
656
|
+
retried: number;
|
|
657
|
+
success: boolean;
|
|
658
|
+
}) => void;
|
|
575
659
|
}
|
|
576
660
|
/**
|
|
577
661
|
* Thin, typed wrapper around Mercado Pago's REST API. Exposes the surface
|
|
@@ -584,6 +668,9 @@ declare class MercadoPagoClient {
|
|
|
584
668
|
private readonly accessToken;
|
|
585
669
|
private readonly baseUrl;
|
|
586
670
|
private readonly fetchImpl;
|
|
671
|
+
private readonly requestTimeoutMs;
|
|
672
|
+
private readonly maxRetries;
|
|
673
|
+
private readonly onCall;
|
|
587
674
|
constructor(options: MercadoPagoClientOptions);
|
|
588
675
|
private request;
|
|
589
676
|
/**
|
|
@@ -684,6 +771,55 @@ declare class MercadoPagoClient {
|
|
|
684
771
|
}): Promise<InstallmentOffer[]>;
|
|
685
772
|
/** Get info about the account that owns this access token. */
|
|
686
773
|
getMe(): Promise<AccountInfo>;
|
|
774
|
+
/**
|
|
775
|
+
* Create a single-use card token from a saved card. This is the server-side
|
|
776
|
+
* retokenization path (PCI-safe because the card data lives in MP's vault,
|
|
777
|
+
* we only pass the saved card_id + customer_id + the user-supplied CVV).
|
|
778
|
+
*
|
|
779
|
+
* Tokens expire in 7 days but typically burn on first use. AR currently
|
|
780
|
+
* REQUIRES CVV on every charge (MP doesn't store it); skipping CVV requires
|
|
781
|
+
* a private MP product enablement, not a public API.
|
|
782
|
+
*/
|
|
783
|
+
createCardToken(params: CreateCardTokenParams): Promise<CardToken>;
|
|
784
|
+
/**
|
|
785
|
+
* High-level helper: charge a saved card in 3 steps.
|
|
786
|
+
* 1. Mint a card token from {customer_id, card_id, security_code}
|
|
787
|
+
* 2. Lookup card to fill payment_method_id (avoids agent guessing)
|
|
788
|
+
* 3. Create the payment with the token + idempotency key
|
|
789
|
+
*
|
|
790
|
+
* Returns the resulting Payment. Uses deterministic idempotency from
|
|
791
|
+
* (card_id, amount, externalReference) so retries dedupe on MP's side.
|
|
792
|
+
*/
|
|
793
|
+
chargeSavedCard(params: {
|
|
794
|
+
customerId: string;
|
|
795
|
+
cardId: string;
|
|
796
|
+
securityCode: string;
|
|
797
|
+
amount: number;
|
|
798
|
+
description: string;
|
|
799
|
+
installments?: number;
|
|
800
|
+
externalReference?: string;
|
|
801
|
+
statementDescriptor?: string;
|
|
802
|
+
idempotencyKey?: string;
|
|
803
|
+
}): Promise<Payment>;
|
|
804
|
+
/**
|
|
805
|
+
* Create a dynamic in-store QR order. Returns `qr_data` (EMVCo TLV string)
|
|
806
|
+
* + `in_store_order_id`. The buyer scans the QR with any AR wallet (Modo,
|
|
807
|
+
* BNA+, Cuenta DNI, Naranja X, etc. — interop is mandated by Transferencias
|
|
808
|
+
* 3.0). On payment, MP fires `point_integration_wh` then `payment` topics.
|
|
809
|
+
*
|
|
810
|
+
* Requires a pre-configured POS (`external_pos_id` from MP dashboard or
|
|
811
|
+
* `POST /pos`). The seller's `user_id` is auto-fetched from `/users/me`.
|
|
812
|
+
*
|
|
813
|
+
* The lib does NOT render the QR image — pass `qr_data` to a QR renderer
|
|
814
|
+
* (e.g., `qrcode` package) to get a data URL. The agent tool layer wraps
|
|
815
|
+
* this and returns both raw + data URL.
|
|
816
|
+
*/
|
|
817
|
+
createQrPayment(userId: string, params: CreateQrPaymentParams): Promise<QrOrder>;
|
|
818
|
+
/**
|
|
819
|
+
* Cancel a pending QR order on a POS. Necessary if the buyer never scans
|
|
820
|
+
* — otherwise the next `createQrPayment` on the same POS returns 409.
|
|
821
|
+
*/
|
|
822
|
+
cancelQrPayment(userId: string, externalPosId: string): Promise<void>;
|
|
687
823
|
}
|
|
688
824
|
|
|
689
825
|
/**
|
|
@@ -752,7 +888,7 @@ interface MercadoPagoToolsOptions {
|
|
|
752
888
|
*/
|
|
753
889
|
notificationUrl?: string;
|
|
754
890
|
}
|
|
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";
|
|
891
|
+
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" | "charge_saved_card" | "create_qr_payment" | "cancel_qr_payment";
|
|
756
892
|
/**
|
|
757
893
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
758
894
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -818,4 +954,4 @@ declare function verifyWebhookSignature(params: {
|
|
|
818
954
|
secret: string;
|
|
819
955
|
}): boolean;
|
|
820
956
|
|
|
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 };
|
|
957
|
+
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreatePaymentParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CurrencyId, type Customer, type CustomerCard, type FrequencyType, InMemoryStateAdapter, type InstallmentOffer, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|