@ar-agents/mercadopago 0.5.0 → 0.7.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/AGENTS.md +10 -1
- package/CHANGELOG.md +67 -0
- package/README.md +1 -1
- package/dist/index.cjs +1255 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +533 -2
- package/dist/index.d.ts +533 -2
- package/dist/index.js +1250 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/tools.manifest.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -951,6 +951,145 @@ 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
|
+
}
|
|
1020
|
+
declare const MerchantOrderSchema: z.ZodObject<{
|
|
1021
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
1022
|
+
status: z.ZodOptional<z.ZodString>;
|
|
1023
|
+
external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1024
|
+
preference_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
1025
|
+
payments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
1026
|
+
shipments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
1027
|
+
payer: z.ZodOptional<z.ZodUnknown>;
|
|
1028
|
+
collector: z.ZodOptional<z.ZodUnknown>;
|
|
1029
|
+
marketplace: z.ZodOptional<z.ZodString>;
|
|
1030
|
+
total_amount: z.ZodOptional<z.ZodNumber>;
|
|
1031
|
+
paid_amount: z.ZodOptional<z.ZodNumber>;
|
|
1032
|
+
refunded_amount: z.ZodOptional<z.ZodNumber>;
|
|
1033
|
+
shipping_cost: z.ZodOptional<z.ZodNumber>;
|
|
1034
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
1035
|
+
last_updated: z.ZodOptional<z.ZodString>;
|
|
1036
|
+
site_id: z.ZodOptional<z.ZodString>;
|
|
1037
|
+
order_status: z.ZodOptional<z.ZodString>;
|
|
1038
|
+
}, z.core.$loose>;
|
|
1039
|
+
type MerchantOrder = z.infer<typeof MerchantOrderSchema>;
|
|
1040
|
+
declare const BankAccountSchema: z.ZodObject<{
|
|
1041
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
1042
|
+
cbu: z.ZodOptional<z.ZodString>;
|
|
1043
|
+
alias: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1044
|
+
bank_name: z.ZodOptional<z.ZodString>;
|
|
1045
|
+
account_type: z.ZodOptional<z.ZodString>;
|
|
1046
|
+
status: z.ZodOptional<z.ZodString>;
|
|
1047
|
+
is_default: z.ZodOptional<z.ZodBoolean>;
|
|
1048
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
1049
|
+
}, z.core.$loose>;
|
|
1050
|
+
type BankAccount = z.infer<typeof BankAccountSchema>;
|
|
1051
|
+
declare const PointDeviceSchema: z.ZodObject<{
|
|
1052
|
+
id: z.ZodString;
|
|
1053
|
+
pos_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
1054
|
+
store_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
1055
|
+
external_pos_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1056
|
+
operating_mode: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"PDV">, z.ZodLiteral<"STANDALONE">, z.ZodString]>>;
|
|
1057
|
+
}, z.core.$loose>;
|
|
1058
|
+
type PointDevice = z.infer<typeof PointDeviceSchema>;
|
|
1059
|
+
type PointPaymentIntentState = "OPEN" | "PROCESSING" | "FINISHED" | "CANCELED" | "ERROR" | string;
|
|
1060
|
+
declare const PointPaymentIntentSchema: z.ZodObject<{
|
|
1061
|
+
id: z.ZodString;
|
|
1062
|
+
device_id: z.ZodOptional<z.ZodString>;
|
|
1063
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
1064
|
+
state: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"OPEN">, z.ZodLiteral<"PROCESSING">, z.ZodLiteral<"FINISHED">, z.ZodLiteral<"CANCELED">, z.ZodLiteral<"ERROR">, z.ZodString]>>;
|
|
1065
|
+
payment: z.ZodOptional<z.ZodObject<{
|
|
1066
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
1067
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1068
|
+
installments: z.ZodOptional<z.ZodNumber>;
|
|
1069
|
+
installments_cost: z.ZodOptional<z.ZodString>;
|
|
1070
|
+
print_on_terminal: z.ZodOptional<z.ZodBoolean>;
|
|
1071
|
+
}, z.core.$loose>>;
|
|
1072
|
+
additional_info: z.ZodOptional<z.ZodUnknown>;
|
|
1073
|
+
}, z.core.$loose>;
|
|
1074
|
+
type PointPaymentIntent = z.infer<typeof PointPaymentIntentSchema>;
|
|
1075
|
+
interface CreatePointPaymentIntentParams {
|
|
1076
|
+
/** Amount in centavos (yes, centavos — Point API differs from Payments API). */
|
|
1077
|
+
amount: number;
|
|
1078
|
+
/** Description shown on the device screen + the buyer's receipt. */
|
|
1079
|
+
description?: string;
|
|
1080
|
+
/** Your-system reference (echoed back in the resulting Payment). */
|
|
1081
|
+
externalReference?: string;
|
|
1082
|
+
/** Number of installments (default 1). */
|
|
1083
|
+
installments?: number;
|
|
1084
|
+
/** "seller" or "buyer" — who pays the installment cost. */
|
|
1085
|
+
installmentsCost?: "seller" | "buyer";
|
|
1086
|
+
/**
|
|
1087
|
+
* Print receipt on the terminal (default true). Some kiosks set false.
|
|
1088
|
+
*/
|
|
1089
|
+
printOnTerminal?: boolean;
|
|
1090
|
+
/** Ticket number (your sequential receipt number). */
|
|
1091
|
+
ticketNumber?: string;
|
|
1092
|
+
}
|
|
954
1093
|
|
|
955
1094
|
interface MercadoPagoClientOptions {
|
|
956
1095
|
/** Access token. TEST- prefix for sandbox, APP_USR- for production. */
|
|
@@ -1284,6 +1423,206 @@ declare class MercadoPagoClient {
|
|
|
1284
1423
|
* For orders that have already been captured, use `createRefund` instead.
|
|
1285
1424
|
*/
|
|
1286
1425
|
cancelOrder(id: string): Promise<Order>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Get the seller's current MP wallet balance (available + unavailable).
|
|
1428
|
+
* - `available_balance`: spendable / withdrawable right now.
|
|
1429
|
+
* - `unavailable_balance`: in retention (e.g., 14-21 days for new sellers).
|
|
1430
|
+
* - `total_amount` = sum of both.
|
|
1431
|
+
*/
|
|
1432
|
+
getAccountBalance(): Promise<AccountBalance>;
|
|
1433
|
+
/**
|
|
1434
|
+
* List wallet movements (incoming payments, transfers, refunds, holdings).
|
|
1435
|
+
* Defaults to most-recent-first, paginated. Filter by date range with
|
|
1436
|
+
* `from`/`to` (ISO 8601).
|
|
1437
|
+
*/
|
|
1438
|
+
listAccountMovements(params?: {
|
|
1439
|
+
from?: string;
|
|
1440
|
+
to?: string;
|
|
1441
|
+
limit?: number;
|
|
1442
|
+
offset?: number;
|
|
1443
|
+
}): Promise<{
|
|
1444
|
+
movements: AccountMovement[];
|
|
1445
|
+
paging: {
|
|
1446
|
+
limit: number;
|
|
1447
|
+
offset: number;
|
|
1448
|
+
total: number;
|
|
1449
|
+
};
|
|
1450
|
+
}>;
|
|
1451
|
+
/**
|
|
1452
|
+
* List settlements (transfers from MP wallet to your bank account).
|
|
1453
|
+
* Useful for monthly conciliation reports.
|
|
1454
|
+
*/
|
|
1455
|
+
listSettlements(params?: {
|
|
1456
|
+
from?: string;
|
|
1457
|
+
to?: string;
|
|
1458
|
+
status?: string;
|
|
1459
|
+
limit?: number;
|
|
1460
|
+
offset?: number;
|
|
1461
|
+
}): Promise<{
|
|
1462
|
+
settlements: Settlement[];
|
|
1463
|
+
paging: {
|
|
1464
|
+
limit: number;
|
|
1465
|
+
offset: number;
|
|
1466
|
+
total: number;
|
|
1467
|
+
};
|
|
1468
|
+
}>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Get a single settlement by id. Returns the full Settlement object
|
|
1471
|
+
* including bank_account info (CBU, bank name).
|
|
1472
|
+
*/
|
|
1473
|
+
getSettlement(id: string): Promise<Settlement>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Update a customer's profile (name, last name, address, etc.). MP merges
|
|
1476
|
+
* the patch — fields you don't send remain unchanged.
|
|
1477
|
+
*/
|
|
1478
|
+
updateCustomer(id: string, patch: Partial<{
|
|
1479
|
+
first_name: string;
|
|
1480
|
+
last_name: string;
|
|
1481
|
+
phone: {
|
|
1482
|
+
area_code?: string;
|
|
1483
|
+
number?: string;
|
|
1484
|
+
};
|
|
1485
|
+
identification: {
|
|
1486
|
+
type: string;
|
|
1487
|
+
number: string;
|
|
1488
|
+
};
|
|
1489
|
+
address: {
|
|
1490
|
+
street_name?: string;
|
|
1491
|
+
street_number?: number;
|
|
1492
|
+
zip_code?: string;
|
|
1493
|
+
};
|
|
1494
|
+
description: string;
|
|
1495
|
+
default_card?: string;
|
|
1496
|
+
}>): Promise<Customer>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Add a saved card to a customer using a card token (one-time, get from
|
|
1499
|
+
* MP's frontend Cardform). The card is then chargeable with charge_saved_card.
|
|
1500
|
+
*/
|
|
1501
|
+
createCustomerCard(customerId: string, cardToken: string): Promise<CustomerCard>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Update an existing subscription. Common patches:
|
|
1504
|
+
* - `transaction_amount` to change the recurring amount
|
|
1505
|
+
* - `card_token_id` to switch payment method (e.g., expired card)
|
|
1506
|
+
* - `status: "cancelled" | "paused"` (alternative to dedicated cancel/pause endpoints)
|
|
1507
|
+
* - `reason` to update the description shown to the buyer
|
|
1508
|
+
*/
|
|
1509
|
+
updatePreapproval(id: string, patch: Partial<{
|
|
1510
|
+
transaction_amount: number;
|
|
1511
|
+
card_token_id: string;
|
|
1512
|
+
status: "authorized" | "paused" | "cancelled";
|
|
1513
|
+
reason: string;
|
|
1514
|
+
external_reference: string;
|
|
1515
|
+
}>): Promise<Preapproval>;
|
|
1516
|
+
/**
|
|
1517
|
+
* Search subscriptions across the seller's account. Common filters:
|
|
1518
|
+
* `status` (pending/authorized/paused/cancelled), `payer_email`,
|
|
1519
|
+
* `external_reference`. Paginated.
|
|
1520
|
+
*/
|
|
1521
|
+
searchPreapprovals(params?: {
|
|
1522
|
+
status?: string;
|
|
1523
|
+
payerEmail?: string;
|
|
1524
|
+
externalReference?: string;
|
|
1525
|
+
preapproval_plan_id?: string;
|
|
1526
|
+
limit?: number;
|
|
1527
|
+
offset?: number;
|
|
1528
|
+
}): Promise<{
|
|
1529
|
+
results: Preapproval[];
|
|
1530
|
+
paging: {
|
|
1531
|
+
limit: number;
|
|
1532
|
+
offset: number;
|
|
1533
|
+
total: number;
|
|
1534
|
+
};
|
|
1535
|
+
}>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Get a merchant_order with all its associated payments + shipments.
|
|
1538
|
+
* Useful for reconciling "which payments belong to which preference"
|
|
1539
|
+
* — typical webhook handler use case.
|
|
1540
|
+
*/
|
|
1541
|
+
getMerchantOrder(id: string): Promise<MerchantOrder>;
|
|
1542
|
+
/**
|
|
1543
|
+
* Search merchant_orders by external_reference, preference_id, or status.
|
|
1544
|
+
*/
|
|
1545
|
+
searchMerchantOrders(params?: {
|
|
1546
|
+
preferenceId?: string;
|
|
1547
|
+
externalReference?: string;
|
|
1548
|
+
status?: string;
|
|
1549
|
+
limit?: number;
|
|
1550
|
+
offset?: number;
|
|
1551
|
+
}): Promise<{
|
|
1552
|
+
elements: MerchantOrder[];
|
|
1553
|
+
paging: {
|
|
1554
|
+
limit: number;
|
|
1555
|
+
offset: number;
|
|
1556
|
+
total: number;
|
|
1557
|
+
};
|
|
1558
|
+
}>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Update a merchant_order — typically to add items or update shipping.
|
|
1561
|
+
*/
|
|
1562
|
+
updateMerchantOrder(id: string, patch: Record<string, unknown>): Promise<MerchantOrder>;
|
|
1563
|
+
getStore(userId: string, storeId: string): Promise<Store>;
|
|
1564
|
+
updateStore(userId: string, storeId: string, patch: Partial<CreateStoreParams>): Promise<Store>;
|
|
1565
|
+
deleteStore(userId: string, storeId: string): Promise<void>;
|
|
1566
|
+
getPos(posId: string): Promise<Pos>;
|
|
1567
|
+
updatePos(posId: string, patch: Partial<CreatePosParams>): Promise<Pos>;
|
|
1568
|
+
deletePos(posId: string): Promise<void>;
|
|
1569
|
+
/**
|
|
1570
|
+
* List bank accounts registered by the seller. The default is the one
|
|
1571
|
+
* that receives `release_money` settlements.
|
|
1572
|
+
*/
|
|
1573
|
+
listBankAccounts(): Promise<BankAccount[]>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Register a new bank account (CBU) for the seller. Note: MP usually
|
|
1576
|
+
* requires this through the dashboard for compliance — this endpoint may
|
|
1577
|
+
* not work for all sellers.
|
|
1578
|
+
*/
|
|
1579
|
+
registerBankAccount(params: {
|
|
1580
|
+
cbu: string;
|
|
1581
|
+
alias?: string;
|
|
1582
|
+
}): Promise<BankAccount>;
|
|
1583
|
+
/**
|
|
1584
|
+
* List the Point devices linked to the seller's MP account. Each device
|
|
1585
|
+
* has an id (the device serial), an operating_mode (PDV vs STANDALONE),
|
|
1586
|
+
* and an optional pos_id (when bound to a logical POS).
|
|
1587
|
+
*/
|
|
1588
|
+
listPointDevices(params?: {
|
|
1589
|
+
posId?: string | number;
|
|
1590
|
+
limit?: number;
|
|
1591
|
+
offset?: number;
|
|
1592
|
+
}): Promise<{
|
|
1593
|
+
devices: PointDevice[];
|
|
1594
|
+
paging: {
|
|
1595
|
+
total: number;
|
|
1596
|
+
limit: number;
|
|
1597
|
+
offset: number;
|
|
1598
|
+
};
|
|
1599
|
+
}>;
|
|
1600
|
+
/**
|
|
1601
|
+
* Switch a Point device's operating mode:
|
|
1602
|
+
* - "PDV": device is bound to a logical Pos and only takes payments
|
|
1603
|
+
* triggered through that Pos (typical for cash-register integrations).
|
|
1604
|
+
* - "STANDALONE": device works independently, accepts any payment.
|
|
1605
|
+
*/
|
|
1606
|
+
updatePointDeviceOperatingMode(deviceId: string, operatingMode: "PDV" | "STANDALONE"): Promise<PointDevice>;
|
|
1607
|
+
/**
|
|
1608
|
+
* Create a payment intent on a Point device — the device prompts the buyer
|
|
1609
|
+
* to tap/insert/swipe. Returns immediately with intent id; query state via
|
|
1610
|
+
* `getPointPaymentIntent()` or wait for `point_integration_wh` webhook.
|
|
1611
|
+
*
|
|
1612
|
+
* NOTE: amount is in CENTAVOS (Point API differs from Payments API which
|
|
1613
|
+
* uses pesos). 100 = $1 ARS, 1000 = $10, 10000 = $100, etc.
|
|
1614
|
+
*/
|
|
1615
|
+
createPointPaymentIntent(deviceId: string, params: CreatePointPaymentIntentParams): Promise<PointPaymentIntent>;
|
|
1616
|
+
/** Get the current state of a Point payment intent. */
|
|
1617
|
+
getPointPaymentIntent(intentId: string): Promise<PointPaymentIntent>;
|
|
1618
|
+
/**
|
|
1619
|
+
* Cancel an OPEN payment intent before the buyer interacts with the device.
|
|
1620
|
+
* Only works while state is "OPEN" — once the buyer taps, you can't cancel.
|
|
1621
|
+
*/
|
|
1622
|
+
cancelPointPaymentIntent(deviceId: string, intentId: string): Promise<{
|
|
1623
|
+
id: string;
|
|
1624
|
+
canceled: true;
|
|
1625
|
+
}>;
|
|
1287
1626
|
}
|
|
1288
1627
|
|
|
1289
1628
|
/**
|
|
@@ -1370,7 +1709,7 @@ interface MercadoPagoToolsOptions {
|
|
|
1370
1709
|
clientSecret: string;
|
|
1371
1710
|
};
|
|
1372
1711
|
}
|
|
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";
|
|
1712
|
+
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" | "get_customer" | "update_customer" | "create_customer_card" | "get_customer_card" | "get_subscription_plan" | "update_subscription" | "search_subscriptions" | "get_refund" | "update_payment_preference" | "get_merchant_order" | "search_merchant_orders" | "update_merchant_order" | "get_store" | "update_store" | "delete_store" | "get_pos" | "update_pos" | "delete_pos" | "list_bank_accounts" | "register_bank_account" | "list_point_devices" | "update_point_device_mode" | "create_point_payment_intent" | "get_point_payment_intent" | "cancel_point_payment_intent" | "compute_marketplace_fee" | "explain_payment_status";
|
|
1374
1713
|
/**
|
|
1375
1714
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
1376
1715
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -1548,4 +1887,196 @@ declare function expirationTimeMs(issuedAtMs: number, expiresInSeconds: number |
|
|
|
1548
1887
|
*/
|
|
1549
1888
|
declare function isExpiringSoon(expirationMs: number, skewSeconds?: number): boolean;
|
|
1550
1889
|
|
|
1551
|
-
|
|
1890
|
+
/**
|
|
1891
|
+
* MP sandbox test cards for AR (MLA) — the official numbers MP publishes for
|
|
1892
|
+
* its TEST environment. Use these in unit tests + integration tests to
|
|
1893
|
+
* exercise the create_payment / charge_saved_card flows without touching a
|
|
1894
|
+
* real card.
|
|
1895
|
+
*
|
|
1896
|
+
* # When this matters
|
|
1897
|
+
*
|
|
1898
|
+
* Most non-trivial dev flows hit the issue of "I want to test approved /
|
|
1899
|
+
* rejected / pending paths" but MP's docs scatter the test card numbers
|
|
1900
|
+
* across multiple pages. This module collects them so you can `import { TEST_CARDS_AR }`
|
|
1901
|
+
* and pick the scenario you need.
|
|
1902
|
+
*
|
|
1903
|
+
* # Source
|
|
1904
|
+
*
|
|
1905
|
+
* AR (MLA) test cards published at
|
|
1906
|
+
* https://www.mercadopago.com.ar/developers/es/docs/checkout-api/additional-content/test-cards
|
|
1907
|
+
*
|
|
1908
|
+
* Last sync: 2026-05.
|
|
1909
|
+
*/
|
|
1910
|
+
/**
|
|
1911
|
+
* The full data needed to test a payment:
|
|
1912
|
+
* - `number` — 16 digits
|
|
1913
|
+
* - `cvv` — 3 digits
|
|
1914
|
+
* - `exp` — MM/YY (use any future date in TEST mode)
|
|
1915
|
+
* - `paymentMethodId` — what to pass as `payment_method_id` to create_payment
|
|
1916
|
+
* - `holderName` — special string that triggers the desired status
|
|
1917
|
+
* (e.g. "APRO" → approved, "OTHE" → rejected with bad CVV)
|
|
1918
|
+
*/
|
|
1919
|
+
interface TestCard {
|
|
1920
|
+
brand: string;
|
|
1921
|
+
number: string;
|
|
1922
|
+
cvv: string;
|
|
1923
|
+
exp: string;
|
|
1924
|
+
paymentMethodId: string;
|
|
1925
|
+
/**
|
|
1926
|
+
* Holder-name "magic strings" — MP routes the payment to a specific
|
|
1927
|
+
* status_detail based on this:
|
|
1928
|
+
* - `APRO` → status: approved
|
|
1929
|
+
* - `OTHE` → rejected (status_detail: cc_rejected_other_reason)
|
|
1930
|
+
* - `CONT` → pending (status_detail: pending_contingency)
|
|
1931
|
+
* - `CALL` → rejected (status_detail: cc_rejected_call_for_authorize)
|
|
1932
|
+
* - `FUND` → rejected (status_detail: cc_rejected_insufficient_amount)
|
|
1933
|
+
* - `SECU` → rejected (status_detail: cc_rejected_bad_filled_security_code)
|
|
1934
|
+
* - `EXPI` → rejected (status_detail: cc_rejected_bad_filled_date)
|
|
1935
|
+
* - `FORM` → rejected (status_detail: cc_rejected_bad_filled_other)
|
|
1936
|
+
*/
|
|
1937
|
+
holderNameToTest: Record<string, string>;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* The MP-published test cards for AR. Pass `holderName: "APRO"` for an
|
|
1941
|
+
* approved payment, `"OTHE"` for a rejected one, etc.
|
|
1942
|
+
*/
|
|
1943
|
+
declare const TEST_CARDS_AR: Record<string, TestCard>;
|
|
1944
|
+
/**
|
|
1945
|
+
* Pre-built payer objects that MP recognizes as test buyers. Pair with
|
|
1946
|
+
* an APRO test card → status: approved.
|
|
1947
|
+
*
|
|
1948
|
+
* **Use a NEW email per call** if you don't want MP's idempotency-on-email
|
|
1949
|
+
* to dedupe — append a timestamp.
|
|
1950
|
+
*/
|
|
1951
|
+
declare const TEST_PAYERS_AR: {
|
|
1952
|
+
readonly approvedBuyer: () => {
|
|
1953
|
+
email: string;
|
|
1954
|
+
identification: {
|
|
1955
|
+
type: string;
|
|
1956
|
+
number: string;
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
};
|
|
1960
|
+
/**
|
|
1961
|
+
* Resolve a `(card, scenario)` pair to a ready-to-use `CreatePaymentParams`-like
|
|
1962
|
+
* object. Reduces boilerplate in test files.
|
|
1963
|
+
*
|
|
1964
|
+
* @example
|
|
1965
|
+
* ```ts
|
|
1966
|
+
* const card = buildTestCardScenario("VISA_CREDIT", "APRO", 1500);
|
|
1967
|
+
* await client.createPayment({ ...card, externalReference: "test-1" });
|
|
1968
|
+
* ```
|
|
1969
|
+
*/
|
|
1970
|
+
declare function buildTestCardScenario(cardKey: keyof typeof TEST_CARDS_AR, scenario: string, amountArs: number): {
|
|
1971
|
+
transactionAmount: number;
|
|
1972
|
+
paymentMethodId: string;
|
|
1973
|
+
payerEmail: string;
|
|
1974
|
+
description: string;
|
|
1975
|
+
installments: number;
|
|
1976
|
+
/**
|
|
1977
|
+
* Magic holder name — pass to MP frontend's CardForm `cardholderName`
|
|
1978
|
+
* field. (For server-side create_payment, pass via additional_info.)
|
|
1979
|
+
*/
|
|
1980
|
+
holderName: string;
|
|
1981
|
+
};
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* 3DS (Strong Customer Authentication) analyzer for Mercado Pago Payments.
|
|
1985
|
+
*
|
|
1986
|
+
* # Background
|
|
1987
|
+
*
|
|
1988
|
+
* 3DS (3-D Secure / "verified by Visa", "Mastercard SecureCode") is the
|
|
1989
|
+
* issuer-side 2FA layer for card payments. MP triggers it automatically when:
|
|
1990
|
+
* - The card's issuer requires it (driven by MCC + amount + risk).
|
|
1991
|
+
* - The buyer's country mandates it (MX, BR, several EU countries).
|
|
1992
|
+
*
|
|
1993
|
+
* In Argentina (MLA), 3DS is OPTIONAL but strongly recommended for
|
|
1994
|
+
* high-value transactions and is required for some FCE MiPyMEs flows.
|
|
1995
|
+
*
|
|
1996
|
+
* # What this module does
|
|
1997
|
+
*
|
|
1998
|
+
* Given a `Payment` returned by `getPayment()` or `createPayment()`, derive
|
|
1999
|
+
* a normalized `ThreeDSInfo` telling you:
|
|
2000
|
+
* - Whether 3DS was triggered at all
|
|
2001
|
+
* - Whether it was frictionless (no buyer interaction) or required a challenge
|
|
2002
|
+
* - The challenge URL (if any) you must redirect the buyer to
|
|
2003
|
+
* - A human-readable description suitable for surfacing to the user
|
|
2004
|
+
*
|
|
2005
|
+
* # When to use
|
|
2006
|
+
*
|
|
2007
|
+
* Call `analyze3DS(payment)` after EVERY `createPayment()` for credit cards.
|
|
2008
|
+
* If `info.challengeUrl !== null`, you MUST redirect the buyer there before
|
|
2009
|
+
* the payment can complete — otherwise it stays in `pending` forever.
|
|
2010
|
+
*/
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* Analyze a Payment's 3DS state. Pure function, no I/O.
|
|
2014
|
+
*/
|
|
2015
|
+
declare function analyze3DS(payment: Payment): ThreeDSInfo;
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* Pure helpers — no I/O, deterministic, fast. Importable directly from the
|
|
2019
|
+
* package root or used via the agent tools (`compute_marketplace_fee`,
|
|
2020
|
+
* `explain_payment_status`).
|
|
2021
|
+
*/
|
|
2022
|
+
|
|
2023
|
+
interface MarketplaceFeeRule {
|
|
2024
|
+
/** Fixed fee in ARS (added on top of percentage). */
|
|
2025
|
+
flatArs?: number;
|
|
2026
|
+
/** Percentage of the transaction amount (0-100). */
|
|
2027
|
+
percent?: number;
|
|
2028
|
+
/** Minimum fee floor in ARS. */
|
|
2029
|
+
minArs?: number;
|
|
2030
|
+
/** Maximum fee cap in ARS. */
|
|
2031
|
+
maxArs?: number;
|
|
2032
|
+
/** Round to nearest peso (default true). */
|
|
2033
|
+
round?: boolean;
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
2036
|
+
* Compute the exact `marketplace_fee` (in ARS) to pass to `create_order` /
|
|
2037
|
+
* `create_payment_preference` for a given transaction amount and fee rule.
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* // 5% fee with $50 floor and $5000 cap
|
|
2041
|
+
* computeMarketplaceFee(10000, { percent: 5, minArs: 50, maxArs: 5000 })
|
|
2042
|
+
* // → 500
|
|
2043
|
+
*
|
|
2044
|
+
* computeMarketplaceFee(500, { percent: 5, minArs: 50 })
|
|
2045
|
+
* // → 50 (would be 25 by percent, floor lifts to 50)
|
|
2046
|
+
*
|
|
2047
|
+
* @example
|
|
2048
|
+
* // Flat $200 + 2%
|
|
2049
|
+
* computeMarketplaceFee(10000, { flatArs: 200, percent: 2 })
|
|
2050
|
+
* // → 400
|
|
2051
|
+
*/
|
|
2052
|
+
declare function computeMarketplaceFee(amountArs: number, rule: MarketplaceFeeRule): number;
|
|
2053
|
+
interface PaymentStatusExplanation {
|
|
2054
|
+
/** Spanish summary of the current state — surface to user. */
|
|
2055
|
+
summary: string;
|
|
2056
|
+
/** What the agent should do next. Actionable guidance. */
|
|
2057
|
+
recommendedAction: string;
|
|
2058
|
+
/**
|
|
2059
|
+
* Whether this state is FINAL (no further changes) or transient
|
|
2060
|
+
* (can still flip with another webhook).
|
|
2061
|
+
*/
|
|
2062
|
+
final: boolean;
|
|
2063
|
+
/** Whether the buyer paid successfully (approved). */
|
|
2064
|
+
paid: boolean;
|
|
2065
|
+
/**
|
|
2066
|
+
* Whether this is a recoverable rejection (user can retry with another
|
|
2067
|
+
* card / different installments) vs a hard rejection (stop trying).
|
|
2068
|
+
*/
|
|
2069
|
+
retryable: boolean;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Human-readable explanation of a Payment's current state — derives summary,
|
|
2073
|
+
* recommended action, finality, and whether the rejection is retryable from
|
|
2074
|
+
* `payment.status` + `payment.status_detail`.
|
|
2075
|
+
*
|
|
2076
|
+
* Pure function. Use the output to drive agent decisions ("¿reintento?
|
|
2077
|
+
* ¿le digo al cliente que cambie de tarjeta?") without having to memorize
|
|
2078
|
+
* every MP status_detail code.
|
|
2079
|
+
*/
|
|
2080
|
+
declare function explainPaymentStatus(payment: Payment): PaymentStatusExplanation;
|
|
2081
|
+
|
|
2082
|
+
export { type AccountBalance, type AccountInfo, type AccountMovement, type AutoRecurring, type BankAccount, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreateOrderParams, type CreatePaymentParams, type CreatePointPaymentIntentParams, 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 MarketplaceFeeRule, type MarketplaceParams, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type MerchantOrder, type OAuthToken, type Order, type OrderItem, type OrderStatus, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentStatusExplanation, type PaymentsSearchResult, type PointDevice, type PointPaymentIntent, type PointPaymentIntentState, 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, computeMarketplaceFee, exchangeCodeForToken, expirationTimeMs, explainPaymentStatus, isExpiringSoon, mercadoPagoTools, parseWebhookEvent, refreshAccessToken, verifyWebhookSignature };
|