@ar-agents/mercadopago 0.6.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/dist/index.d.cts CHANGED
@@ -1017,6 +1017,79 @@ interface ThreeDSInfo {
1017
1017
  /** Human-readable explanation suitable for surfacing to the user. */
1018
1018
  description: string;
1019
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
+ }
1020
1093
 
1021
1094
  interface MercadoPagoClientOptions {
1022
1095
  /** Access token. TEST- prefix for sandbox, APP_USR- for production. */
@@ -1398,6 +1471,158 @@ declare class MercadoPagoClient {
1398
1471
  * including bank_account info (CBU, bank name).
1399
1472
  */
1400
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
+ }>;
1401
1626
  }
1402
1627
 
1403
1628
  /**
@@ -1484,7 +1709,7 @@ interface MercadoPagoToolsOptions {
1484
1709
  clientSecret: string;
1485
1710
  };
1486
1711
  }
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";
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";
1488
1713
  /**
1489
1714
  * Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
1490
1715
  * agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
@@ -1789,4 +2014,69 @@ declare function buildTestCardScenario(cardKey: keyof typeof TEST_CARDS_AR, scen
1789
2014
  */
1790
2015
  declare function analyze3DS(payment: Payment): ThreeDSInfo;
1791
2016
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1017,6 +1017,79 @@ interface ThreeDSInfo {
1017
1017
  /** Human-readable explanation suitable for surfacing to the user. */
1018
1018
  description: string;
1019
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
+ }
1020
1093
 
1021
1094
  interface MercadoPagoClientOptions {
1022
1095
  /** Access token. TEST- prefix for sandbox, APP_USR- for production. */
@@ -1398,6 +1471,158 @@ declare class MercadoPagoClient {
1398
1471
  * including bank_account info (CBU, bank name).
1399
1472
  */
1400
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
+ }>;
1401
1626
  }
1402
1627
 
1403
1628
  /**
@@ -1484,7 +1709,7 @@ interface MercadoPagoToolsOptions {
1484
1709
  clientSecret: string;
1485
1710
  };
1486
1711
  }
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";
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";
1488
1713
  /**
1489
1714
  * Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
1490
1715
  * agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
@@ -1789,4 +2014,69 @@ declare function buildTestCardScenario(cardKey: keyof typeof TEST_CARDS_AR, scen
1789
2014
  */
1790
2015
  declare function analyze3DS(payment: Payment): ThreeDSInfo;
1791
2016
 
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 };
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 };