@ar-agents/mercadopago 0.5.0 → 0.6.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 +25 -0
- package/dist/index.cjs +326 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +243 -2
- package/dist/index.d.ts +243 -2
- package/dist/index.js +323 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -951,6 +951,72 @@ interface MarketplaceParams {
|
|
|
951
951
|
*/
|
|
952
952
|
application_fee?: number;
|
|
953
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Account balance snapshot. Sum of `available + unavailable` is the seller's
|
|
956
|
+
* total Mercado Pago balance.
|
|
957
|
+
*
|
|
958
|
+
* - `available` — funds the seller can withdraw or pay with right now.
|
|
959
|
+
* - `unavailable` — funds in retention (typically 14-21 days for new sellers
|
|
960
|
+
* or for risk-flagged transactions). Becomes `available` automatically.
|
|
961
|
+
*/
|
|
962
|
+
declare const AccountBalanceSchema: z.ZodObject<{
|
|
963
|
+
user_id: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>;
|
|
964
|
+
available_balance: z.ZodNumber;
|
|
965
|
+
unavailable_balance: z.ZodNumber;
|
|
966
|
+
total_amount: z.ZodNumber;
|
|
967
|
+
currency_id: z.ZodDefault<z.ZodString>;
|
|
968
|
+
}, z.core.$loose>;
|
|
969
|
+
type AccountBalance = z.infer<typeof AccountBalanceSchema>;
|
|
970
|
+
/**
|
|
971
|
+
* Account movement (a single line in the seller's MP "movements" log).
|
|
972
|
+
* Includes incoming payments, outgoing transfers, refunds, holdings, etc.
|
|
973
|
+
*/
|
|
974
|
+
declare const AccountMovementSchema: z.ZodObject<{
|
|
975
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
976
|
+
type: z.ZodString;
|
|
977
|
+
description: z.ZodOptional<z.ZodString>;
|
|
978
|
+
amount: z.ZodNumber;
|
|
979
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
980
|
+
status: z.ZodOptional<z.ZodString>;
|
|
981
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
982
|
+
date_released: z.ZodOptional<z.ZodString>;
|
|
983
|
+
reference_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
984
|
+
payment_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
985
|
+
}, z.core.$loose>;
|
|
986
|
+
type AccountMovement = z.infer<typeof AccountMovementSchema>;
|
|
987
|
+
/**
|
|
988
|
+
* A scheduled or completed transfer from the MP account to the seller's
|
|
989
|
+
* registered bank account (CBU). Settlements are the core of "when do I
|
|
990
|
+
* actually get paid".
|
|
991
|
+
*/
|
|
992
|
+
declare const SettlementSchema: z.ZodObject<{
|
|
993
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
994
|
+
status: z.ZodOptional<z.ZodString>;
|
|
995
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
996
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
997
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
998
|
+
date_scheduled: z.ZodOptional<z.ZodString>;
|
|
999
|
+
date_processed: z.ZodOptional<z.ZodString>;
|
|
1000
|
+
bank_account: z.ZodOptional<z.ZodObject<{
|
|
1001
|
+
cbu: z.ZodOptional<z.ZodString>;
|
|
1002
|
+
bank_name: z.ZodOptional<z.ZodString>;
|
|
1003
|
+
}, z.core.$loose>>;
|
|
1004
|
+
}, z.core.$loose>;
|
|
1005
|
+
type Settlement = z.infer<typeof SettlementSchema>;
|
|
1006
|
+
type ThreeDSStatus = "not_required" | "frictionless" | "challenge_required" | "rejected" | "unknown";
|
|
1007
|
+
interface ThreeDSInfo {
|
|
1008
|
+
/** High-level status — the field most agents care about. */
|
|
1009
|
+
status: ThreeDSStatus;
|
|
1010
|
+
/** Raw `three_d_secure_mode` field from the payment, if present. */
|
|
1011
|
+
mode: string | null;
|
|
1012
|
+
/**
|
|
1013
|
+
* URL the buyer must visit to complete the 3DS challenge, if one was
|
|
1014
|
+
* triggered. `null` for frictionless/not_required.
|
|
1015
|
+
*/
|
|
1016
|
+
challengeUrl: string | null;
|
|
1017
|
+
/** Human-readable explanation suitable for surfacing to the user. */
|
|
1018
|
+
description: string;
|
|
1019
|
+
}
|
|
954
1020
|
|
|
955
1021
|
interface MercadoPagoClientOptions {
|
|
956
1022
|
/** Access token. TEST- prefix for sandbox, APP_USR- for production. */
|
|
@@ -1284,6 +1350,54 @@ declare class MercadoPagoClient {
|
|
|
1284
1350
|
* For orders that have already been captured, use `createRefund` instead.
|
|
1285
1351
|
*/
|
|
1286
1352
|
cancelOrder(id: string): Promise<Order>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Get the seller's current MP wallet balance (available + unavailable).
|
|
1355
|
+
* - `available_balance`: spendable / withdrawable right now.
|
|
1356
|
+
* - `unavailable_balance`: in retention (e.g., 14-21 days for new sellers).
|
|
1357
|
+
* - `total_amount` = sum of both.
|
|
1358
|
+
*/
|
|
1359
|
+
getAccountBalance(): Promise<AccountBalance>;
|
|
1360
|
+
/**
|
|
1361
|
+
* List wallet movements (incoming payments, transfers, refunds, holdings).
|
|
1362
|
+
* Defaults to most-recent-first, paginated. Filter by date range with
|
|
1363
|
+
* `from`/`to` (ISO 8601).
|
|
1364
|
+
*/
|
|
1365
|
+
listAccountMovements(params?: {
|
|
1366
|
+
from?: string;
|
|
1367
|
+
to?: string;
|
|
1368
|
+
limit?: number;
|
|
1369
|
+
offset?: number;
|
|
1370
|
+
}): Promise<{
|
|
1371
|
+
movements: AccountMovement[];
|
|
1372
|
+
paging: {
|
|
1373
|
+
limit: number;
|
|
1374
|
+
offset: number;
|
|
1375
|
+
total: number;
|
|
1376
|
+
};
|
|
1377
|
+
}>;
|
|
1378
|
+
/**
|
|
1379
|
+
* List settlements (transfers from MP wallet to your bank account).
|
|
1380
|
+
* Useful for monthly conciliation reports.
|
|
1381
|
+
*/
|
|
1382
|
+
listSettlements(params?: {
|
|
1383
|
+
from?: string;
|
|
1384
|
+
to?: string;
|
|
1385
|
+
status?: string;
|
|
1386
|
+
limit?: number;
|
|
1387
|
+
offset?: number;
|
|
1388
|
+
}): Promise<{
|
|
1389
|
+
settlements: Settlement[];
|
|
1390
|
+
paging: {
|
|
1391
|
+
limit: number;
|
|
1392
|
+
offset: number;
|
|
1393
|
+
total: number;
|
|
1394
|
+
};
|
|
1395
|
+
}>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Get a single settlement by id. Returns the full Settlement object
|
|
1398
|
+
* including bank_account info (CBU, bank name).
|
|
1399
|
+
*/
|
|
1400
|
+
getSettlement(id: string): Promise<Settlement>;
|
|
1287
1401
|
}
|
|
1288
1402
|
|
|
1289
1403
|
/**
|
|
@@ -1370,7 +1484,7 @@ interface MercadoPagoToolsOptions {
|
|
|
1370
1484
|
clientSecret: string;
|
|
1371
1485
|
};
|
|
1372
1486
|
}
|
|
1373
|
-
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" | "create_subscription_plan" | "list_subscription_plans" | "update_subscription_plan" | "subscribe_to_plan" | "list_subscription_payments" | "create_store" | "list_stores" | "create_pos" | "list_pos" | "list_payment_disputes" | "get_dispute" | "list_identification_types" | "list_issuers" | "list_webhooks" | "create_webhook" | "update_webhook" | "delete_webhook" | "handle_webhook" | "oauth_authorize_url" | "oauth_exchange_code" | "oauth_refresh_token" | "create_order" | "get_order" | "update_order" | "capture_order" | "cancel_order";
|
|
1487
|
+
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" | "create_subscription_plan" | "list_subscription_plans" | "update_subscription_plan" | "subscribe_to_plan" | "list_subscription_payments" | "create_store" | "list_stores" | "create_pos" | "list_pos" | "list_payment_disputes" | "get_dispute" | "list_identification_types" | "list_issuers" | "list_webhooks" | "create_webhook" | "update_webhook" | "delete_webhook" | "handle_webhook" | "oauth_authorize_url" | "oauth_exchange_code" | "oauth_refresh_token" | "create_order" | "get_order" | "update_order" | "capture_order" | "cancel_order" | "get_account_balance" | "list_account_movements" | "list_settlements" | "get_settlement" | "analyze_payment_3ds" | "get_test_cards";
|
|
1374
1488
|
/**
|
|
1375
1489
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
1376
1490
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -1548,4 +1662,131 @@ declare function expirationTimeMs(issuedAtMs: number, expiresInSeconds: number |
|
|
|
1548
1662
|
*/
|
|
1549
1663
|
declare function isExpiringSoon(expirationMs: number, skewSeconds?: number): boolean;
|
|
1550
1664
|
|
|
1551
|
-
|
|
1665
|
+
/**
|
|
1666
|
+
* MP sandbox test cards for AR (MLA) — the official numbers MP publishes for
|
|
1667
|
+
* its TEST environment. Use these in unit tests + integration tests to
|
|
1668
|
+
* exercise the create_payment / charge_saved_card flows without touching a
|
|
1669
|
+
* real card.
|
|
1670
|
+
*
|
|
1671
|
+
* # When this matters
|
|
1672
|
+
*
|
|
1673
|
+
* Most non-trivial dev flows hit the issue of "I want to test approved /
|
|
1674
|
+
* rejected / pending paths" but MP's docs scatter the test card numbers
|
|
1675
|
+
* across multiple pages. This module collects them so you can `import { TEST_CARDS_AR }`
|
|
1676
|
+
* and pick the scenario you need.
|
|
1677
|
+
*
|
|
1678
|
+
* # Source
|
|
1679
|
+
*
|
|
1680
|
+
* AR (MLA) test cards published at
|
|
1681
|
+
* https://www.mercadopago.com.ar/developers/es/docs/checkout-api/additional-content/test-cards
|
|
1682
|
+
*
|
|
1683
|
+
* Last sync: 2026-05.
|
|
1684
|
+
*/
|
|
1685
|
+
/**
|
|
1686
|
+
* The full data needed to test a payment:
|
|
1687
|
+
* - `number` — 16 digits
|
|
1688
|
+
* - `cvv` — 3 digits
|
|
1689
|
+
* - `exp` — MM/YY (use any future date in TEST mode)
|
|
1690
|
+
* - `paymentMethodId` — what to pass as `payment_method_id` to create_payment
|
|
1691
|
+
* - `holderName` — special string that triggers the desired status
|
|
1692
|
+
* (e.g. "APRO" → approved, "OTHE" → rejected with bad CVV)
|
|
1693
|
+
*/
|
|
1694
|
+
interface TestCard {
|
|
1695
|
+
brand: string;
|
|
1696
|
+
number: string;
|
|
1697
|
+
cvv: string;
|
|
1698
|
+
exp: string;
|
|
1699
|
+
paymentMethodId: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* Holder-name "magic strings" — MP routes the payment to a specific
|
|
1702
|
+
* status_detail based on this:
|
|
1703
|
+
* - `APRO` → status: approved
|
|
1704
|
+
* - `OTHE` → rejected (status_detail: cc_rejected_other_reason)
|
|
1705
|
+
* - `CONT` → pending (status_detail: pending_contingency)
|
|
1706
|
+
* - `CALL` → rejected (status_detail: cc_rejected_call_for_authorize)
|
|
1707
|
+
* - `FUND` → rejected (status_detail: cc_rejected_insufficient_amount)
|
|
1708
|
+
* - `SECU` → rejected (status_detail: cc_rejected_bad_filled_security_code)
|
|
1709
|
+
* - `EXPI` → rejected (status_detail: cc_rejected_bad_filled_date)
|
|
1710
|
+
* - `FORM` → rejected (status_detail: cc_rejected_bad_filled_other)
|
|
1711
|
+
*/
|
|
1712
|
+
holderNameToTest: Record<string, string>;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* The MP-published test cards for AR. Pass `holderName: "APRO"` for an
|
|
1716
|
+
* approved payment, `"OTHE"` for a rejected one, etc.
|
|
1717
|
+
*/
|
|
1718
|
+
declare const TEST_CARDS_AR: Record<string, TestCard>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Pre-built payer objects that MP recognizes as test buyers. Pair with
|
|
1721
|
+
* an APRO test card → status: approved.
|
|
1722
|
+
*
|
|
1723
|
+
* **Use a NEW email per call** if you don't want MP's idempotency-on-email
|
|
1724
|
+
* to dedupe — append a timestamp.
|
|
1725
|
+
*/
|
|
1726
|
+
declare const TEST_PAYERS_AR: {
|
|
1727
|
+
readonly approvedBuyer: () => {
|
|
1728
|
+
email: string;
|
|
1729
|
+
identification: {
|
|
1730
|
+
type: string;
|
|
1731
|
+
number: string;
|
|
1732
|
+
};
|
|
1733
|
+
};
|
|
1734
|
+
};
|
|
1735
|
+
/**
|
|
1736
|
+
* Resolve a `(card, scenario)` pair to a ready-to-use `CreatePaymentParams`-like
|
|
1737
|
+
* object. Reduces boilerplate in test files.
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* ```ts
|
|
1741
|
+
* const card = buildTestCardScenario("VISA_CREDIT", "APRO", 1500);
|
|
1742
|
+
* await client.createPayment({ ...card, externalReference: "test-1" });
|
|
1743
|
+
* ```
|
|
1744
|
+
*/
|
|
1745
|
+
declare function buildTestCardScenario(cardKey: keyof typeof TEST_CARDS_AR, scenario: string, amountArs: number): {
|
|
1746
|
+
transactionAmount: number;
|
|
1747
|
+
paymentMethodId: string;
|
|
1748
|
+
payerEmail: string;
|
|
1749
|
+
description: string;
|
|
1750
|
+
installments: number;
|
|
1751
|
+
/**
|
|
1752
|
+
* Magic holder name — pass to MP frontend's CardForm `cardholderName`
|
|
1753
|
+
* field. (For server-side create_payment, pass via additional_info.)
|
|
1754
|
+
*/
|
|
1755
|
+
holderName: string;
|
|
1756
|
+
};
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* 3DS (Strong Customer Authentication) analyzer for Mercado Pago Payments.
|
|
1760
|
+
*
|
|
1761
|
+
* # Background
|
|
1762
|
+
*
|
|
1763
|
+
* 3DS (3-D Secure / "verified by Visa", "Mastercard SecureCode") is the
|
|
1764
|
+
* issuer-side 2FA layer for card payments. MP triggers it automatically when:
|
|
1765
|
+
* - The card's issuer requires it (driven by MCC + amount + risk).
|
|
1766
|
+
* - The buyer's country mandates it (MX, BR, several EU countries).
|
|
1767
|
+
*
|
|
1768
|
+
* In Argentina (MLA), 3DS is OPTIONAL but strongly recommended for
|
|
1769
|
+
* high-value transactions and is required for some FCE MiPyMEs flows.
|
|
1770
|
+
*
|
|
1771
|
+
* # What this module does
|
|
1772
|
+
*
|
|
1773
|
+
* Given a `Payment` returned by `getPayment()` or `createPayment()`, derive
|
|
1774
|
+
* a normalized `ThreeDSInfo` telling you:
|
|
1775
|
+
* - Whether 3DS was triggered at all
|
|
1776
|
+
* - Whether it was frictionless (no buyer interaction) or required a challenge
|
|
1777
|
+
* - The challenge URL (if any) you must redirect the buyer to
|
|
1778
|
+
* - A human-readable description suitable for surfacing to the user
|
|
1779
|
+
*
|
|
1780
|
+
* # When to use
|
|
1781
|
+
*
|
|
1782
|
+
* Call `analyze3DS(payment)` after EVERY `createPayment()` for credit cards.
|
|
1783
|
+
* If `info.challengeUrl !== null`, you MUST redirect the buyer there before
|
|
1784
|
+
* the payment can complete — otherwise it stays in `pending` forever.
|
|
1785
|
+
*/
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Analyze a Payment's 3DS state. Pure function, no I/O.
|
|
1789
|
+
*/
|
|
1790
|
+
declare function analyze3DS(payment: Payment): ThreeDSInfo;
|
|
1791
|
+
|
|
1792
|
+
export { type AccountBalance, type AccountInfo, type AccountMovement, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreateOrderParams, type CreatePaymentParams, type CreatePosParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CreateStoreParams, type CreateSubscriptionPlanParams, type CreateWebhookParams, type CurrencyId, type Customer, type CustomerCard, type Dispute, type FrequencyType, type IdentificationType, InMemoryStateAdapter, type InstallmentOffer, type Issuer, type MarketplaceParams, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type OAuthToken, type Order, type OrderItem, type OrderStatus, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Pos, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type Settlement, type SiteId, type Store, type SubscriptionPayment, type SubscriptionPlan, type SubscriptionStateAdapter, type SubscriptionStateRecord, TEST_CARDS_AR, TEST_PAYERS_AR, type TestCard, type ThreeDSInfo, type ThreeDSStatus, type WebhookBody, type WebhookConfig, type WebhookTopic, analyze3DS, buildAuthorizeUrl, buildTestCardScenario, classifyError, exchangeCodeForToken, expirationTimeMs, isExpiringSoon, mercadoPagoTools, parseWebhookEvent, refreshAccessToken, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -951,6 +951,72 @@ interface MarketplaceParams {
|
|
|
951
951
|
*/
|
|
952
952
|
application_fee?: number;
|
|
953
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Account balance snapshot. Sum of `available + unavailable` is the seller's
|
|
956
|
+
* total Mercado Pago balance.
|
|
957
|
+
*
|
|
958
|
+
* - `available` — funds the seller can withdraw or pay with right now.
|
|
959
|
+
* - `unavailable` — funds in retention (typically 14-21 days for new sellers
|
|
960
|
+
* or for risk-flagged transactions). Becomes `available` automatically.
|
|
961
|
+
*/
|
|
962
|
+
declare const AccountBalanceSchema: z.ZodObject<{
|
|
963
|
+
user_id: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>;
|
|
964
|
+
available_balance: z.ZodNumber;
|
|
965
|
+
unavailable_balance: z.ZodNumber;
|
|
966
|
+
total_amount: z.ZodNumber;
|
|
967
|
+
currency_id: z.ZodDefault<z.ZodString>;
|
|
968
|
+
}, z.core.$loose>;
|
|
969
|
+
type AccountBalance = z.infer<typeof AccountBalanceSchema>;
|
|
970
|
+
/**
|
|
971
|
+
* Account movement (a single line in the seller's MP "movements" log).
|
|
972
|
+
* Includes incoming payments, outgoing transfers, refunds, holdings, etc.
|
|
973
|
+
*/
|
|
974
|
+
declare const AccountMovementSchema: z.ZodObject<{
|
|
975
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
976
|
+
type: z.ZodString;
|
|
977
|
+
description: z.ZodOptional<z.ZodString>;
|
|
978
|
+
amount: z.ZodNumber;
|
|
979
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
980
|
+
status: z.ZodOptional<z.ZodString>;
|
|
981
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
982
|
+
date_released: z.ZodOptional<z.ZodString>;
|
|
983
|
+
reference_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
984
|
+
payment_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
985
|
+
}, z.core.$loose>;
|
|
986
|
+
type AccountMovement = z.infer<typeof AccountMovementSchema>;
|
|
987
|
+
/**
|
|
988
|
+
* A scheduled or completed transfer from the MP account to the seller's
|
|
989
|
+
* registered bank account (CBU). Settlements are the core of "when do I
|
|
990
|
+
* actually get paid".
|
|
991
|
+
*/
|
|
992
|
+
declare const SettlementSchema: z.ZodObject<{
|
|
993
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
994
|
+
status: z.ZodOptional<z.ZodString>;
|
|
995
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
996
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
997
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
998
|
+
date_scheduled: z.ZodOptional<z.ZodString>;
|
|
999
|
+
date_processed: z.ZodOptional<z.ZodString>;
|
|
1000
|
+
bank_account: z.ZodOptional<z.ZodObject<{
|
|
1001
|
+
cbu: z.ZodOptional<z.ZodString>;
|
|
1002
|
+
bank_name: z.ZodOptional<z.ZodString>;
|
|
1003
|
+
}, z.core.$loose>>;
|
|
1004
|
+
}, z.core.$loose>;
|
|
1005
|
+
type Settlement = z.infer<typeof SettlementSchema>;
|
|
1006
|
+
type ThreeDSStatus = "not_required" | "frictionless" | "challenge_required" | "rejected" | "unknown";
|
|
1007
|
+
interface ThreeDSInfo {
|
|
1008
|
+
/** High-level status — the field most agents care about. */
|
|
1009
|
+
status: ThreeDSStatus;
|
|
1010
|
+
/** Raw `three_d_secure_mode` field from the payment, if present. */
|
|
1011
|
+
mode: string | null;
|
|
1012
|
+
/**
|
|
1013
|
+
* URL the buyer must visit to complete the 3DS challenge, if one was
|
|
1014
|
+
* triggered. `null` for frictionless/not_required.
|
|
1015
|
+
*/
|
|
1016
|
+
challengeUrl: string | null;
|
|
1017
|
+
/** Human-readable explanation suitable for surfacing to the user. */
|
|
1018
|
+
description: string;
|
|
1019
|
+
}
|
|
954
1020
|
|
|
955
1021
|
interface MercadoPagoClientOptions {
|
|
956
1022
|
/** Access token. TEST- prefix for sandbox, APP_USR- for production. */
|
|
@@ -1284,6 +1350,54 @@ declare class MercadoPagoClient {
|
|
|
1284
1350
|
* For orders that have already been captured, use `createRefund` instead.
|
|
1285
1351
|
*/
|
|
1286
1352
|
cancelOrder(id: string): Promise<Order>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Get the seller's current MP wallet balance (available + unavailable).
|
|
1355
|
+
* - `available_balance`: spendable / withdrawable right now.
|
|
1356
|
+
* - `unavailable_balance`: in retention (e.g., 14-21 days for new sellers).
|
|
1357
|
+
* - `total_amount` = sum of both.
|
|
1358
|
+
*/
|
|
1359
|
+
getAccountBalance(): Promise<AccountBalance>;
|
|
1360
|
+
/**
|
|
1361
|
+
* List wallet movements (incoming payments, transfers, refunds, holdings).
|
|
1362
|
+
* Defaults to most-recent-first, paginated. Filter by date range with
|
|
1363
|
+
* `from`/`to` (ISO 8601).
|
|
1364
|
+
*/
|
|
1365
|
+
listAccountMovements(params?: {
|
|
1366
|
+
from?: string;
|
|
1367
|
+
to?: string;
|
|
1368
|
+
limit?: number;
|
|
1369
|
+
offset?: number;
|
|
1370
|
+
}): Promise<{
|
|
1371
|
+
movements: AccountMovement[];
|
|
1372
|
+
paging: {
|
|
1373
|
+
limit: number;
|
|
1374
|
+
offset: number;
|
|
1375
|
+
total: number;
|
|
1376
|
+
};
|
|
1377
|
+
}>;
|
|
1378
|
+
/**
|
|
1379
|
+
* List settlements (transfers from MP wallet to your bank account).
|
|
1380
|
+
* Useful for monthly conciliation reports.
|
|
1381
|
+
*/
|
|
1382
|
+
listSettlements(params?: {
|
|
1383
|
+
from?: string;
|
|
1384
|
+
to?: string;
|
|
1385
|
+
status?: string;
|
|
1386
|
+
limit?: number;
|
|
1387
|
+
offset?: number;
|
|
1388
|
+
}): Promise<{
|
|
1389
|
+
settlements: Settlement[];
|
|
1390
|
+
paging: {
|
|
1391
|
+
limit: number;
|
|
1392
|
+
offset: number;
|
|
1393
|
+
total: number;
|
|
1394
|
+
};
|
|
1395
|
+
}>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Get a single settlement by id. Returns the full Settlement object
|
|
1398
|
+
* including bank_account info (CBU, bank name).
|
|
1399
|
+
*/
|
|
1400
|
+
getSettlement(id: string): Promise<Settlement>;
|
|
1287
1401
|
}
|
|
1288
1402
|
|
|
1289
1403
|
/**
|
|
@@ -1370,7 +1484,7 @@ interface MercadoPagoToolsOptions {
|
|
|
1370
1484
|
clientSecret: string;
|
|
1371
1485
|
};
|
|
1372
1486
|
}
|
|
1373
|
-
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" | "create_subscription_plan" | "list_subscription_plans" | "update_subscription_plan" | "subscribe_to_plan" | "list_subscription_payments" | "create_store" | "list_stores" | "create_pos" | "list_pos" | "list_payment_disputes" | "get_dispute" | "list_identification_types" | "list_issuers" | "list_webhooks" | "create_webhook" | "update_webhook" | "delete_webhook" | "handle_webhook" | "oauth_authorize_url" | "oauth_exchange_code" | "oauth_refresh_token" | "create_order" | "get_order" | "update_order" | "capture_order" | "cancel_order";
|
|
1487
|
+
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" | "create_subscription_plan" | "list_subscription_plans" | "update_subscription_plan" | "subscribe_to_plan" | "list_subscription_payments" | "create_store" | "list_stores" | "create_pos" | "list_pos" | "list_payment_disputes" | "get_dispute" | "list_identification_types" | "list_issuers" | "list_webhooks" | "create_webhook" | "update_webhook" | "delete_webhook" | "handle_webhook" | "oauth_authorize_url" | "oauth_exchange_code" | "oauth_refresh_token" | "create_order" | "get_order" | "update_order" | "capture_order" | "cancel_order" | "get_account_balance" | "list_account_movements" | "list_settlements" | "get_settlement" | "analyze_payment_3ds" | "get_test_cards";
|
|
1374
1488
|
/**
|
|
1375
1489
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
1376
1490
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -1548,4 +1662,131 @@ declare function expirationTimeMs(issuedAtMs: number, expiresInSeconds: number |
|
|
|
1548
1662
|
*/
|
|
1549
1663
|
declare function isExpiringSoon(expirationMs: number, skewSeconds?: number): boolean;
|
|
1550
1664
|
|
|
1551
|
-
|
|
1665
|
+
/**
|
|
1666
|
+
* MP sandbox test cards for AR (MLA) — the official numbers MP publishes for
|
|
1667
|
+
* its TEST environment. Use these in unit tests + integration tests to
|
|
1668
|
+
* exercise the create_payment / charge_saved_card flows without touching a
|
|
1669
|
+
* real card.
|
|
1670
|
+
*
|
|
1671
|
+
* # When this matters
|
|
1672
|
+
*
|
|
1673
|
+
* Most non-trivial dev flows hit the issue of "I want to test approved /
|
|
1674
|
+
* rejected / pending paths" but MP's docs scatter the test card numbers
|
|
1675
|
+
* across multiple pages. This module collects them so you can `import { TEST_CARDS_AR }`
|
|
1676
|
+
* and pick the scenario you need.
|
|
1677
|
+
*
|
|
1678
|
+
* # Source
|
|
1679
|
+
*
|
|
1680
|
+
* AR (MLA) test cards published at
|
|
1681
|
+
* https://www.mercadopago.com.ar/developers/es/docs/checkout-api/additional-content/test-cards
|
|
1682
|
+
*
|
|
1683
|
+
* Last sync: 2026-05.
|
|
1684
|
+
*/
|
|
1685
|
+
/**
|
|
1686
|
+
* The full data needed to test a payment:
|
|
1687
|
+
* - `number` — 16 digits
|
|
1688
|
+
* - `cvv` — 3 digits
|
|
1689
|
+
* - `exp` — MM/YY (use any future date in TEST mode)
|
|
1690
|
+
* - `paymentMethodId` — what to pass as `payment_method_id` to create_payment
|
|
1691
|
+
* - `holderName` — special string that triggers the desired status
|
|
1692
|
+
* (e.g. "APRO" → approved, "OTHE" → rejected with bad CVV)
|
|
1693
|
+
*/
|
|
1694
|
+
interface TestCard {
|
|
1695
|
+
brand: string;
|
|
1696
|
+
number: string;
|
|
1697
|
+
cvv: string;
|
|
1698
|
+
exp: string;
|
|
1699
|
+
paymentMethodId: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* Holder-name "magic strings" — MP routes the payment to a specific
|
|
1702
|
+
* status_detail based on this:
|
|
1703
|
+
* - `APRO` → status: approved
|
|
1704
|
+
* - `OTHE` → rejected (status_detail: cc_rejected_other_reason)
|
|
1705
|
+
* - `CONT` → pending (status_detail: pending_contingency)
|
|
1706
|
+
* - `CALL` → rejected (status_detail: cc_rejected_call_for_authorize)
|
|
1707
|
+
* - `FUND` → rejected (status_detail: cc_rejected_insufficient_amount)
|
|
1708
|
+
* - `SECU` → rejected (status_detail: cc_rejected_bad_filled_security_code)
|
|
1709
|
+
* - `EXPI` → rejected (status_detail: cc_rejected_bad_filled_date)
|
|
1710
|
+
* - `FORM` → rejected (status_detail: cc_rejected_bad_filled_other)
|
|
1711
|
+
*/
|
|
1712
|
+
holderNameToTest: Record<string, string>;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* The MP-published test cards for AR. Pass `holderName: "APRO"` for an
|
|
1716
|
+
* approved payment, `"OTHE"` for a rejected one, etc.
|
|
1717
|
+
*/
|
|
1718
|
+
declare const TEST_CARDS_AR: Record<string, TestCard>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Pre-built payer objects that MP recognizes as test buyers. Pair with
|
|
1721
|
+
* an APRO test card → status: approved.
|
|
1722
|
+
*
|
|
1723
|
+
* **Use a NEW email per call** if you don't want MP's idempotency-on-email
|
|
1724
|
+
* to dedupe — append a timestamp.
|
|
1725
|
+
*/
|
|
1726
|
+
declare const TEST_PAYERS_AR: {
|
|
1727
|
+
readonly approvedBuyer: () => {
|
|
1728
|
+
email: string;
|
|
1729
|
+
identification: {
|
|
1730
|
+
type: string;
|
|
1731
|
+
number: string;
|
|
1732
|
+
};
|
|
1733
|
+
};
|
|
1734
|
+
};
|
|
1735
|
+
/**
|
|
1736
|
+
* Resolve a `(card, scenario)` pair to a ready-to-use `CreatePaymentParams`-like
|
|
1737
|
+
* object. Reduces boilerplate in test files.
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* ```ts
|
|
1741
|
+
* const card = buildTestCardScenario("VISA_CREDIT", "APRO", 1500);
|
|
1742
|
+
* await client.createPayment({ ...card, externalReference: "test-1" });
|
|
1743
|
+
* ```
|
|
1744
|
+
*/
|
|
1745
|
+
declare function buildTestCardScenario(cardKey: keyof typeof TEST_CARDS_AR, scenario: string, amountArs: number): {
|
|
1746
|
+
transactionAmount: number;
|
|
1747
|
+
paymentMethodId: string;
|
|
1748
|
+
payerEmail: string;
|
|
1749
|
+
description: string;
|
|
1750
|
+
installments: number;
|
|
1751
|
+
/**
|
|
1752
|
+
* Magic holder name — pass to MP frontend's CardForm `cardholderName`
|
|
1753
|
+
* field. (For server-side create_payment, pass via additional_info.)
|
|
1754
|
+
*/
|
|
1755
|
+
holderName: string;
|
|
1756
|
+
};
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* 3DS (Strong Customer Authentication) analyzer for Mercado Pago Payments.
|
|
1760
|
+
*
|
|
1761
|
+
* # Background
|
|
1762
|
+
*
|
|
1763
|
+
* 3DS (3-D Secure / "verified by Visa", "Mastercard SecureCode") is the
|
|
1764
|
+
* issuer-side 2FA layer for card payments. MP triggers it automatically when:
|
|
1765
|
+
* - The card's issuer requires it (driven by MCC + amount + risk).
|
|
1766
|
+
* - The buyer's country mandates it (MX, BR, several EU countries).
|
|
1767
|
+
*
|
|
1768
|
+
* In Argentina (MLA), 3DS is OPTIONAL but strongly recommended for
|
|
1769
|
+
* high-value transactions and is required for some FCE MiPyMEs flows.
|
|
1770
|
+
*
|
|
1771
|
+
* # What this module does
|
|
1772
|
+
*
|
|
1773
|
+
* Given a `Payment` returned by `getPayment()` or `createPayment()`, derive
|
|
1774
|
+
* a normalized `ThreeDSInfo` telling you:
|
|
1775
|
+
* - Whether 3DS was triggered at all
|
|
1776
|
+
* - Whether it was frictionless (no buyer interaction) or required a challenge
|
|
1777
|
+
* - The challenge URL (if any) you must redirect the buyer to
|
|
1778
|
+
* - A human-readable description suitable for surfacing to the user
|
|
1779
|
+
*
|
|
1780
|
+
* # When to use
|
|
1781
|
+
*
|
|
1782
|
+
* Call `analyze3DS(payment)` after EVERY `createPayment()` for credit cards.
|
|
1783
|
+
* If `info.challengeUrl !== null`, you MUST redirect the buyer there before
|
|
1784
|
+
* the payment can complete — otherwise it stays in `pending` forever.
|
|
1785
|
+
*/
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Analyze a Payment's 3DS state. Pure function, no I/O.
|
|
1789
|
+
*/
|
|
1790
|
+
declare function analyze3DS(payment: Payment): ThreeDSInfo;
|
|
1791
|
+
|
|
1792
|
+
export { type AccountBalance, type AccountInfo, type AccountMovement, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreateOrderParams, type CreatePaymentParams, type CreatePosParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CreateStoreParams, type CreateSubscriptionPlanParams, type CreateWebhookParams, type CurrencyId, type Customer, type CustomerCard, type Dispute, type FrequencyType, type IdentificationType, InMemoryStateAdapter, type InstallmentOffer, type Issuer, type MarketplaceParams, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type OAuthToken, type Order, type OrderItem, type OrderStatus, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Pos, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type Settlement, type SiteId, type Store, type SubscriptionPayment, type SubscriptionPlan, type SubscriptionStateAdapter, type SubscriptionStateRecord, TEST_CARDS_AR, TEST_PAYERS_AR, type TestCard, type ThreeDSInfo, type ThreeDSStatus, type WebhookBody, type WebhookConfig, type WebhookTopic, analyze3DS, buildAuthorizeUrl, buildTestCardScenario, classifyError, exchangeCodeForToken, expirationTimeMs, isExpiringSoon, mercadoPagoTools, parseWebhookEvent, refreshAccessToken, verifyWebhookSignature };
|