@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- MP v0.6: account/balance + settlements + 3DS analyzer + test cards. **+6 tools (56 total)**.
|
|
8
|
+
|
|
9
|
+
**Account / Balance / Settlements (4 tools)**:
|
|
10
|
+
|
|
11
|
+
- `get_account_balance` — current MP wallet `{ available, unavailable, total, currency_id }`. Per-seller in marketplace setups.
|
|
12
|
+
- `list_account_movements({ from?, to?, limit?, offset? })` — wallet movement log (incoming payments, refunds, holdings, transfers).
|
|
13
|
+
- `list_settlements({ from?, to?, status? })` — `release_money` transfers from MP wallet → registered CBU.
|
|
14
|
+
- `get_settlement(id)` — single settlement detail with bank_account info.
|
|
15
|
+
|
|
16
|
+
**3DS analyzer (1 tool + 1 helper)**:
|
|
17
|
+
|
|
18
|
+
- `analyze_payment_3ds(payment_id)` — fetches the Payment, derives `{ status: 'not_required'|'frictionless'|'challenge_required'|'rejected'|'unknown', mode, challengeUrl, description }`. When `challengeUrl !== null`, MUST redirect the buyer to complete authentication.
|
|
19
|
+
- `analyze3DS(payment)` exported as a pure helper for callers who already have a Payment object.
|
|
20
|
+
|
|
21
|
+
**Test cards (1 tool + helpers)**:
|
|
22
|
+
|
|
23
|
+
- `get_test_cards` — returns the official AR (MLA) sandbox cards: VISA/Mastercard/Amex credit + debit. Each has the "magic" holder names that route to specific status_detail (APRO, OTHE, CONT, FUND, CALL, SECU, EXPI, FORM).
|
|
24
|
+
- `TEST_CARDS_AR`, `TEST_PAYERS_AR`, `buildTestCardScenario(card, scenario, amount)` exported for direct use in test files.
|
|
25
|
+
|
|
26
|
+
**132 tests pass** (was 117; +15 v0.6 tests). publint clean. attw 🟢. 24.3 KB brotli'd (within 32 KB budget).
|
|
27
|
+
|
|
3
28
|
## 0.5.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -960,6 +960,71 @@ var MercadoPagoClient = class {
|
|
|
960
960
|
async cancelOrder(id) {
|
|
961
961
|
return this.request("POST", `/v1/orders/${id}/cancel`);
|
|
962
962
|
}
|
|
963
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
964
|
+
// v0.6 — Account Balance + Movements
|
|
965
|
+
//
|
|
966
|
+
// Inspect the seller's MP wallet — what's available to withdraw, what's
|
|
967
|
+
// in retention (pending release), and the movement log.
|
|
968
|
+
//
|
|
969
|
+
// For per-seller marketplace setups, instantiate the client AS THE SELLER
|
|
970
|
+
// (with their OAuth access_token) before calling these — `getAccountBalance`
|
|
971
|
+
// returns the balance of WHOEVER's accessToken is active.
|
|
972
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
973
|
+
/**
|
|
974
|
+
* Get the seller's current MP wallet balance (available + unavailable).
|
|
975
|
+
* - `available_balance`: spendable / withdrawable right now.
|
|
976
|
+
* - `unavailable_balance`: in retention (e.g., 14-21 days for new sellers).
|
|
977
|
+
* - `total_amount` = sum of both.
|
|
978
|
+
*/
|
|
979
|
+
async getAccountBalance() {
|
|
980
|
+
return this.request("GET", "/users/me/mercadopago_account/balance");
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* List wallet movements (incoming payments, transfers, refunds, holdings).
|
|
984
|
+
* Defaults to most-recent-first, paginated. Filter by date range with
|
|
985
|
+
* `from`/`to` (ISO 8601).
|
|
986
|
+
*/
|
|
987
|
+
async listAccountMovements(params = {}) {
|
|
988
|
+
const query = {};
|
|
989
|
+
if (params.from) query.begin_date = params.from;
|
|
990
|
+
if (params.to) query.end_date = params.to;
|
|
991
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
992
|
+
if (params.offset !== void 0) query.offset = params.offset;
|
|
993
|
+
const result = await this.request("GET", "/users/me/mercadopago_account/movements/search", void 0, { query });
|
|
994
|
+
return {
|
|
995
|
+
movements: result.results ?? [],
|
|
996
|
+
paging: result.paging ?? { limit: params.limit ?? 25, offset: params.offset ?? 0, total: 0 }
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
1000
|
+
// v0.6 — Settlements (release_money)
|
|
1001
|
+
//
|
|
1002
|
+
// When MP transfers funds from your MP wallet to your registered CBU.
|
|
1003
|
+
// ──────────────────────────────────────────────────────────────────────────
|
|
1004
|
+
/**
|
|
1005
|
+
* List settlements (transfers from MP wallet to your bank account).
|
|
1006
|
+
* Useful for monthly conciliation reports.
|
|
1007
|
+
*/
|
|
1008
|
+
async listSettlements(params = {}) {
|
|
1009
|
+
const query = {};
|
|
1010
|
+
if (params.from) query.begin_date = params.from;
|
|
1011
|
+
if (params.to) query.end_date = params.to;
|
|
1012
|
+
if (params.status) query.status = params.status;
|
|
1013
|
+
if (params.limit !== void 0) query.limit = params.limit;
|
|
1014
|
+
if (params.offset !== void 0) query.offset = params.offset;
|
|
1015
|
+
const result = await this.request("GET", "/v1/account/release_money/search", void 0, { query });
|
|
1016
|
+
return {
|
|
1017
|
+
settlements: result.results ?? [],
|
|
1018
|
+
paging: result.paging ?? { limit: params.limit ?? 25, offset: params.offset ?? 0, total: 0 }
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Get a single settlement by id. Returns the full Settlement object
|
|
1023
|
+
* including bank_account info (CBU, bank name).
|
|
1024
|
+
*/
|
|
1025
|
+
async getSettlement(id) {
|
|
1026
|
+
return this.request("GET", `/v1/account/release_money/${id}`);
|
|
1027
|
+
}
|
|
963
1028
|
};
|
|
964
1029
|
zod.z.enum(["MLA", "MLB", "MLM", "MCO", "MLC", "MLU"]);
|
|
965
1030
|
var CurrencyIdSchema = zod.z.enum(["ARS", "USD", "BRL", "MXN"]);
|
|
@@ -1308,6 +1373,38 @@ zod.z.object({
|
|
|
1308
1373
|
/** Capture mode: "automatic" (charges immediately) or "manual" (auth-only). */
|
|
1309
1374
|
capture_mode: zod.z.string().optional()
|
|
1310
1375
|
}).passthrough();
|
|
1376
|
+
zod.z.object({
|
|
1377
|
+
user_id: zod.z.union([zod.z.string(), zod.z.number()]).transform(String).optional(),
|
|
1378
|
+
available_balance: zod.z.number(),
|
|
1379
|
+
unavailable_balance: zod.z.number(),
|
|
1380
|
+
total_amount: zod.z.number(),
|
|
1381
|
+
currency_id: zod.z.string().default("ARS")
|
|
1382
|
+
}).passthrough();
|
|
1383
|
+
zod.z.object({
|
|
1384
|
+
id: zod.z.union([zod.z.string(), zod.z.number()]).transform(String),
|
|
1385
|
+
type: zod.z.string(),
|
|
1386
|
+
description: zod.z.string().optional(),
|
|
1387
|
+
amount: zod.z.number(),
|
|
1388
|
+
currency_id: zod.z.string().optional(),
|
|
1389
|
+
status: zod.z.string().optional(),
|
|
1390
|
+
date_created: zod.z.string().optional(),
|
|
1391
|
+
date_released: zod.z.string().optional(),
|
|
1392
|
+
reference_id: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
1393
|
+
payment_id: zod.z.union([zod.z.string(), zod.z.number()]).optional()
|
|
1394
|
+
}).passthrough();
|
|
1395
|
+
zod.z.object({
|
|
1396
|
+
id: zod.z.union([zod.z.string(), zod.z.number()]).transform(String),
|
|
1397
|
+
status: zod.z.string().optional(),
|
|
1398
|
+
amount: zod.z.number().optional(),
|
|
1399
|
+
currency_id: zod.z.string().optional(),
|
|
1400
|
+
date_created: zod.z.string().optional(),
|
|
1401
|
+
date_scheduled: zod.z.string().optional(),
|
|
1402
|
+
date_processed: zod.z.string().optional(),
|
|
1403
|
+
bank_account: zod.z.object({
|
|
1404
|
+
cbu: zod.z.string().optional(),
|
|
1405
|
+
bank_name: zod.z.string().optional()
|
|
1406
|
+
}).passthrough().optional()
|
|
1407
|
+
}).passthrough();
|
|
1311
1408
|
|
|
1312
1409
|
// src/oauth.ts
|
|
1313
1410
|
var DEFAULT_AUTHORIZE_URL = "https://auth.mercadopago.com.ar/authorization";
|
|
@@ -1374,6 +1471,134 @@ function expirationTimeMs(issuedAtMs, expiresInSeconds) {
|
|
|
1374
1471
|
function isExpiringSoon(expirationMs, skewSeconds = 300) {
|
|
1375
1472
|
return Date.now() + skewSeconds * 1e3 >= expirationMs;
|
|
1376
1473
|
}
|
|
1474
|
+
|
|
1475
|
+
// src/test-cards.ts
|
|
1476
|
+
var TEST_CARDS_AR = {
|
|
1477
|
+
VISA_CREDIT: {
|
|
1478
|
+
brand: "Visa (cr\xE9dito)",
|
|
1479
|
+
number: "4509 9535 6623 3704".replace(/\s/g, ""),
|
|
1480
|
+
cvv: "123",
|
|
1481
|
+
exp: "11/30",
|
|
1482
|
+
paymentMethodId: "visa",
|
|
1483
|
+
holderNameToTest: {
|
|
1484
|
+
APRO: "approved",
|
|
1485
|
+
OTHE: "cc_rejected_other_reason",
|
|
1486
|
+
CONT: "pending_contingency",
|
|
1487
|
+
CALL: "cc_rejected_call_for_authorize",
|
|
1488
|
+
FUND: "cc_rejected_insufficient_amount",
|
|
1489
|
+
SECU: "cc_rejected_bad_filled_security_code",
|
|
1490
|
+
EXPI: "cc_rejected_bad_filled_date",
|
|
1491
|
+
FORM: "cc_rejected_bad_filled_other"
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
MASTERCARD_CREDIT: {
|
|
1495
|
+
brand: "Mastercard (cr\xE9dito)",
|
|
1496
|
+
number: "5031 7557 3453 0604".replace(/\s/g, ""),
|
|
1497
|
+
cvv: "123",
|
|
1498
|
+
exp: "11/30",
|
|
1499
|
+
paymentMethodId: "master",
|
|
1500
|
+
holderNameToTest: {
|
|
1501
|
+
APRO: "approved",
|
|
1502
|
+
OTHE: "cc_rejected_other_reason",
|
|
1503
|
+
CONT: "pending_contingency",
|
|
1504
|
+
CALL: "cc_rejected_call_for_authorize",
|
|
1505
|
+
FUND: "cc_rejected_insufficient_amount"
|
|
1506
|
+
}
|
|
1507
|
+
},
|
|
1508
|
+
AMEX_CREDIT: {
|
|
1509
|
+
brand: "American Express (cr\xE9dito)",
|
|
1510
|
+
number: "3711 803032 57522".replace(/\s/g, ""),
|
|
1511
|
+
cvv: "1234",
|
|
1512
|
+
exp: "11/30",
|
|
1513
|
+
paymentMethodId: "amex",
|
|
1514
|
+
holderNameToTest: { APRO: "approved", OTHE: "cc_rejected_other_reason" }
|
|
1515
|
+
},
|
|
1516
|
+
VISA_DEBIT: {
|
|
1517
|
+
brand: "Visa (d\xE9bito)",
|
|
1518
|
+
number: "4002 7686 9439 5619".replace(/\s/g, ""),
|
|
1519
|
+
cvv: "123",
|
|
1520
|
+
exp: "11/30",
|
|
1521
|
+
paymentMethodId: "debvisa",
|
|
1522
|
+
holderNameToTest: { APRO: "approved", OTHE: "cc_rejected_other_reason" }
|
|
1523
|
+
},
|
|
1524
|
+
MASTERCARD_DEBIT: {
|
|
1525
|
+
brand: "Mastercard (d\xE9bito)",
|
|
1526
|
+
number: "5287 3383 0125 4634".replace(/\s/g, ""),
|
|
1527
|
+
cvv: "123",
|
|
1528
|
+
exp: "11/30",
|
|
1529
|
+
paymentMethodId: "debmaster",
|
|
1530
|
+
holderNameToTest: { APRO: "approved", OTHE: "cc_rejected_other_reason" }
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
var TEST_PAYERS_AR = {
|
|
1534
|
+
approvedBuyer: () => ({
|
|
1535
|
+
email: `test_user_${Date.now()}@testuser.com`,
|
|
1536
|
+
identification: { type: "DNI", number: "12345678" }
|
|
1537
|
+
})
|
|
1538
|
+
};
|
|
1539
|
+
function buildTestCardScenario(cardKey, scenario, amountArs) {
|
|
1540
|
+
const card = TEST_CARDS_AR[cardKey];
|
|
1541
|
+
if (!card) throw new Error(`Unknown test card: ${cardKey}`);
|
|
1542
|
+
if (!card.holderNameToTest[scenario]) {
|
|
1543
|
+
throw new Error(
|
|
1544
|
+
`Card ${cardKey} doesn't define scenario ${scenario}. Available: ${Object.keys(card.holderNameToTest).join(", ")}`
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
return {
|
|
1548
|
+
transactionAmount: amountArs,
|
|
1549
|
+
paymentMethodId: card.paymentMethodId,
|
|
1550
|
+
payerEmail: TEST_PAYERS_AR.approvedBuyer().email,
|
|
1551
|
+
description: `TEST ${scenario} via ${cardKey}`,
|
|
1552
|
+
installments: 1,
|
|
1553
|
+
holderName: scenario
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// src/three-ds.ts
|
|
1558
|
+
function analyze3DS(payment) {
|
|
1559
|
+
const raw = payment;
|
|
1560
|
+
const mode = raw.three_d_secure_mode ?? null;
|
|
1561
|
+
const statusDetail = payment.status_detail ?? null;
|
|
1562
|
+
if (!mode || mode === "not_supported" || mode === "off") {
|
|
1563
|
+
return {
|
|
1564
|
+
status: "not_required",
|
|
1565
|
+
mode,
|
|
1566
|
+
challengeUrl: null,
|
|
1567
|
+
description: "3DS no fue requerido para este pago (riesgo bajo o emisor sin 3DS habilitado)."
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
const threeDsInfo = raw.three_ds_info ?? void 0;
|
|
1571
|
+
if (statusDetail === "pending_challenge" && threeDsInfo?.external_resource_url) {
|
|
1572
|
+
return {
|
|
1573
|
+
status: "challenge_required",
|
|
1574
|
+
mode,
|
|
1575
|
+
challengeUrl: threeDsInfo.external_resource_url,
|
|
1576
|
+
description: "El emisor de la tarjeta requiri\xF3 autenticaci\xF3n 3DS. Redirig\xED al comprador a challengeUrl para completar el desaf\xEDo. El pago queda pending hasta que lo haga."
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
if (payment.status === "approved") {
|
|
1580
|
+
return {
|
|
1581
|
+
status: "frictionless",
|
|
1582
|
+
mode,
|
|
1583
|
+
challengeUrl: null,
|
|
1584
|
+
description: "3DS frictionless: el emisor autoriz\xF3 sin desafiar al comprador."
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
if (payment.status === "rejected" && typeof statusDetail === "string" && statusDetail.includes("3ds")) {
|
|
1588
|
+
return {
|
|
1589
|
+
status: "rejected",
|
|
1590
|
+
mode,
|
|
1591
|
+
challengeUrl: null,
|
|
1592
|
+
description: `Autenticaci\xF3n 3DS rechazada (${statusDetail}). El comprador debe usar otra tarjeta o validarla con el emisor.`
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
return {
|
|
1596
|
+
status: "unknown",
|
|
1597
|
+
mode,
|
|
1598
|
+
challengeUrl: threeDsInfo?.external_resource_url ?? null,
|
|
1599
|
+
description: "No se pudo determinar el estado 3DS \u2014 revisar payment.three_d_secure_mode + payment.status_detail manualmente."
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1377
1602
|
function parseWebhookEvent(body, searchParams) {
|
|
1378
1603
|
const parseResult = WebhookBodySchema.safeParse(body ?? {});
|
|
1379
1604
|
const parsedBody = parseResult.success ? parseResult.data : {};
|
|
@@ -1475,7 +1700,16 @@ var DEFAULT_DESCRIPTIONS = {
|
|
|
1475
1700
|
get_order: "Fetch an Order by ID. Returns the Order with its lifecycle status and any attached payments/refunds.",
|
|
1476
1701
|
update_order: "Patch an existing Order before it's captured/canceled. Common use: update items or external_reference.",
|
|
1477
1702
|
capture_order: "Capture a previously-authorized Order (only for orders created with capture_mode='manual'). Captures up to the originally-authorized amount; pass amount for partial capture. Common use: ride-share marks ride complete \u2192 capture; hotel checks-out guest \u2192 capture.",
|
|
1478
|
-
cancel_order: "Cancel an Order. Releases any auth-holds and marks the Order as canceled. For orders that have already been CAPTURED, use refund_payment instead \u2014 cancel only works pre-capture."
|
|
1703
|
+
cancel_order: "Cancel an Order. Releases any auth-holds and marks the Order as canceled. For orders that have already been CAPTURED, use refund_payment instead \u2014 cancel only works pre-capture.",
|
|
1704
|
+
// ── Account / Balance / Movements / Settlements (v0.6) ───────────────────
|
|
1705
|
+
get_account_balance: "Get the seller's current MP wallet balance. Returns { available_balance, unavailable_balance, total_amount, currency_id }. The available balance is what the seller can withdraw or pay with right now; unavailable is in retention (typically 14-21 days for new sellers or risk-flagged transactions). For per-seller marketplace setups, instantiate the client AS THE SELLER first.",
|
|
1706
|
+
list_account_movements: "List wallet movements (incoming payments, transfers, refunds, holdings) for the active MP account. Filter by date range with `from`/`to` (ISO 8601). Useful for monthly conciliation or 'show me what came in this month' workflows.",
|
|
1707
|
+
list_settlements: "List settlements (release_money) \u2014 i.e. transfers from the MP wallet to the seller's registered bank account (CBU). USE WHEN the user asks 'cu\xE1ndo me deposita MP' or for monthly bank-conciliation reports. Filter by date range and status.",
|
|
1708
|
+
get_settlement: "Get details of a single settlement: amount, date_scheduled, date_processed, bank_account info (CBU + bank name).",
|
|
1709
|
+
// ── 3DS analyzer (v0.6 — pure) ───────────────────────────────────────────
|
|
1710
|
+
analyze_payment_3ds: "Pure local analyzer for a Payment's 3DS (Strong Customer Authentication) state. Pass a payment_id (string) and the tool fetches the Payment then derives { status: 'not_required'|'frictionless'|'challenge_required'|'rejected'|'unknown', mode, challengeUrl, description }. USE THIS after every create_payment for credit cards: when challengeUrl !== null, you MUST redirect the buyer there before the payment can complete. Without 3DS, payments stay in 'pending' indefinitely if the issuer demanded a challenge.",
|
|
1711
|
+
// ── Test cards (v0.6 — pure) ─────────────────────────────────────────────
|
|
1712
|
+
get_test_cards: "Pure helper that returns the official MP test cards for AR (MLA): VISA/Mastercard/Amex credit + debit, with the 'magic' holder names that route the payment to specific status_detail values (APRO=approved, OTHE=rejected, CONT=pending, FUND=insufficient_amount, etc.). USE WHEN you need to demo a payment flow without a real card, or to script integration tests. Pure data \u2014 no network call."
|
|
1479
1713
|
};
|
|
1480
1714
|
function mercadoPagoTools(client, options) {
|
|
1481
1715
|
const desc = (name) => options.descriptions?.[name] ?? DEFAULT_DESCRIPTIONS[name];
|
|
@@ -2782,6 +3016,93 @@ function mercadoPagoTools(client, options) {
|
|
|
2782
3016
|
status: order.status ?? "canceled"
|
|
2783
3017
|
};
|
|
2784
3018
|
}
|
|
3019
|
+
}),
|
|
3020
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3021
|
+
// v0.6 — Account / Balance / Movements / Settlements
|
|
3022
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3023
|
+
get_account_balance: ai.tool({
|
|
3024
|
+
description: desc("get_account_balance"),
|
|
3025
|
+
inputSchema: zod.z.object({}),
|
|
3026
|
+
execute: async () => {
|
|
3027
|
+
const balance = await client.getAccountBalance();
|
|
3028
|
+
return balance;
|
|
3029
|
+
}
|
|
3030
|
+
}),
|
|
3031
|
+
list_account_movements: ai.tool({
|
|
3032
|
+
description: desc("list_account_movements"),
|
|
3033
|
+
inputSchema: zod.z.object({
|
|
3034
|
+
from: zod.z.string().optional().describe("ISO 8601 start date (e.g. 2026-05-01)"),
|
|
3035
|
+
to: zod.z.string().optional().describe("ISO 8601 end date"),
|
|
3036
|
+
limit: zod.z.number().int().min(1).max(100).optional(),
|
|
3037
|
+
offset: zod.z.number().int().min(0).optional()
|
|
3038
|
+
}),
|
|
3039
|
+
execute: async ({ from, to, limit, offset }) => {
|
|
3040
|
+
const params = {};
|
|
3041
|
+
if (from !== void 0) params.from = from;
|
|
3042
|
+
if (to !== void 0) params.to = to;
|
|
3043
|
+
if (limit !== void 0) params.limit = limit;
|
|
3044
|
+
if (offset !== void 0) params.offset = offset;
|
|
3045
|
+
return client.listAccountMovements(params);
|
|
3046
|
+
}
|
|
3047
|
+
}),
|
|
3048
|
+
list_settlements: ai.tool({
|
|
3049
|
+
description: desc("list_settlements"),
|
|
3050
|
+
inputSchema: zod.z.object({
|
|
3051
|
+
from: zod.z.string().optional(),
|
|
3052
|
+
to: zod.z.string().optional(),
|
|
3053
|
+
status: zod.z.string().optional(),
|
|
3054
|
+
limit: zod.z.number().int().min(1).max(100).optional(),
|
|
3055
|
+
offset: zod.z.number().int().min(0).optional()
|
|
3056
|
+
}),
|
|
3057
|
+
execute: async ({ from, to, status, limit, offset }) => {
|
|
3058
|
+
const params = {};
|
|
3059
|
+
if (from !== void 0) params.from = from;
|
|
3060
|
+
if (to !== void 0) params.to = to;
|
|
3061
|
+
if (status !== void 0) params.status = status;
|
|
3062
|
+
if (limit !== void 0) params.limit = limit;
|
|
3063
|
+
if (offset !== void 0) params.offset = offset;
|
|
3064
|
+
return client.listSettlements(params);
|
|
3065
|
+
}
|
|
3066
|
+
}),
|
|
3067
|
+
get_settlement: ai.tool({
|
|
3068
|
+
description: desc("get_settlement"),
|
|
3069
|
+
inputSchema: zod.z.object({ settlement_id: zod.z.string() }),
|
|
3070
|
+
execute: async ({ settlement_id }) => {
|
|
3071
|
+
return client.getSettlement(settlement_id);
|
|
3072
|
+
}
|
|
3073
|
+
}),
|
|
3074
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3075
|
+
// v0.6 — 3DS analyzer (combined: fetch payment + analyze)
|
|
3076
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3077
|
+
analyze_payment_3ds: ai.tool({
|
|
3078
|
+
description: desc("analyze_payment_3ds"),
|
|
3079
|
+
inputSchema: zod.z.object({
|
|
3080
|
+
payment_id: zod.z.string().describe("MP payment id")
|
|
3081
|
+
}),
|
|
3082
|
+
execute: async ({ payment_id }) => {
|
|
3083
|
+
const payment = await client.getPayment(payment_id);
|
|
3084
|
+
const info = analyze3DS(payment);
|
|
3085
|
+
return {
|
|
3086
|
+
payment_id,
|
|
3087
|
+
payment_status: payment.status,
|
|
3088
|
+
payment_status_detail: payment.status_detail ?? null,
|
|
3089
|
+
...info
|
|
3090
|
+
};
|
|
3091
|
+
}
|
|
3092
|
+
}),
|
|
3093
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3094
|
+
// v0.6 — Test cards (pure)
|
|
3095
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3096
|
+
get_test_cards: ai.tool({
|
|
3097
|
+
description: desc("get_test_cards"),
|
|
3098
|
+
inputSchema: zod.z.object({}),
|
|
3099
|
+
execute: async () => {
|
|
3100
|
+
return {
|
|
3101
|
+
site: "MLA",
|
|
3102
|
+
cards: TEST_CARDS_AR,
|
|
3103
|
+
usage: "Pass holderName='APRO' for an approved payment, 'OTHE' for rejected, 'CONT' for pending, 'FUND' for insufficient amount, 'CALL' for call-for-authorize. Use a NEW payer email per call (append a timestamp) to avoid MP idempotency-on-email deduping."
|
|
3104
|
+
};
|
|
3105
|
+
}
|
|
2785
3106
|
})
|
|
2786
3107
|
};
|
|
2787
3108
|
}
|
|
@@ -2817,7 +3138,11 @@ exports.MercadoPagoPaymentRejectedError = MercadoPagoPaymentRejectedError;
|
|
|
2817
3138
|
exports.MercadoPagoRateLimitError = MercadoPagoRateLimitError;
|
|
2818
3139
|
exports.MercadoPagoSelfPaymentError = MercadoPagoSelfPaymentError;
|
|
2819
3140
|
exports.MercadoPagoTimeoutError = MercadoPagoTimeoutError;
|
|
3141
|
+
exports.TEST_CARDS_AR = TEST_CARDS_AR;
|
|
3142
|
+
exports.TEST_PAYERS_AR = TEST_PAYERS_AR;
|
|
3143
|
+
exports.analyze3DS = analyze3DS;
|
|
2820
3144
|
exports.buildAuthorizeUrl = buildAuthorizeUrl;
|
|
3145
|
+
exports.buildTestCardScenario = buildTestCardScenario;
|
|
2821
3146
|
exports.classifyError = classifyError;
|
|
2822
3147
|
exports.exchangeCodeForToken = exchangeCodeForToken;
|
|
2823
3148
|
exports.expirationTimeMs = expirationTimeMs;
|