@ar-agents/mercadopago 0.18.6 → 0.18.7
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 +9 -32
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/tools.manifest.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.18.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#155](https://github.com/ar-agents/ar-agents/pull/155) [`f0bbf80`](https://github.com/ar-agents/ar-agents/commit/f0bbf804c96461f642a72e774c9207ed88e19daa) Thanks [@naza00000](https://github.com/naza00000)! - OAuth token responses with a malformed (non-JSON) body now throw the typed
|
|
8
|
+
`MercadoPagoError` with a 300-char body snippet for context, instead of
|
|
9
|
+
leaking a raw `SyntaxError` from `JSON.parse`. Applies to
|
|
10
|
+
`exchangeCodeForToken()` and `refreshAccessToken()`.
|
|
11
|
+
|
|
3
12
|
## 0.18.6
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -78,7 +87,6 @@
|
|
|
78
87
|
### Patch Changes
|
|
79
88
|
|
|
80
89
|
- [`9b8e83c`](https://github.com/ar-agents/ar-agents/commit/9b8e83ce6f291a24e00101830a49afceb0102920) - Add 2 cookbook recipes that demonstrate the cross-package thesis:
|
|
81
|
-
|
|
82
90
|
- **16-acp-checkout-with-factura.ts** — the headline ACP-with-factura pattern. A ChatGPT Instant Checkout / Claude / Gemini agent POSTs an ACP `checkout_session`, the bridge mints a Mercado Pago preference, the buyer pays, and the bridge auto-emits an AFIP/ARCA Factura A/B/C/E via the `facturacionHook` — selecting the comprobante type based on the buyer's IVA condition. No other OSS implementation in LATAM ships this end-to-end.
|
|
83
91
|
- **17-usa-llc-companion.ts** — pattern for a USA-LLC agent (ClawBank, doola Agentic, MIDAO) operating in Argentina via an AR-resident facade. The USA agent declares `@ar-agents/mcp` in its MCP host config; all 89+6+2+10+5+6+5 tools become available without the USA agent ever holding AR credentials. Walks through the operator-of-record split + sample agent prompt that drives charge → factura → WhatsApp confirmation.
|
|
84
92
|
|
|
@@ -89,7 +97,6 @@
|
|
|
89
97
|
### Patch Changes
|
|
90
98
|
|
|
91
99
|
- [`687aa10`](https://github.com/ar-agents/ar-agents/commit/687aa1017a665ed9b3414b9f92db634a9329ac4e) - Add 3 production-grade cookbook recipes:
|
|
92
|
-
|
|
93
100
|
- **13-anti-fraud-middleware.ts** — pre-charge heuristics chain: CUIT validity (algorithm-only), payer email history (searchPayments + status_detail flags for `cc_rejected_call_for_authorize` / `_high_risk` / `_blacklist`), 1-hour velocity tracker, AR issuer-promo stacking detector. Combined risk score (`approve` / `review` / `reject`), with high-value charges (>$100k) getting a 1.5x multiplier.
|
|
94
101
|
- **14-marketplace-onboarding.ts** — end-to-end flow: CUIT validation → AFIP padron lookup (resolves legal name + IVA condition + monotributo category) → OAuth redirect with PKCE round-tripped via state → callback handler exchanging code for tokens → $1 ARS test charge → marketplace fee setup with `computeMarketplaceFee`.
|
|
95
102
|
- **15-prorated-pause-resume.ts** — pause a subscription with prorated refund for the unused period (`createRefund` against the most recent charge), resume with an adjusted next-billing date so the customer doesn't double-pay. Uses `pausePreapproval` + `resumePreapproval` + a local `pauseStore` (Vercel KV in prod) to remember the credit.
|
|
@@ -108,7 +115,6 @@
|
|
|
108
115
|
```
|
|
109
116
|
|
|
110
117
|
Reports:
|
|
111
|
-
|
|
112
118
|
- Node version (must be ≥ 20)
|
|
113
119
|
- `MP_ACCESS_TOKEN` presence + format + sandbox/prod prefix detection
|
|
114
120
|
- Live token validation against `GET /users/me` (free, no charge)
|
|
@@ -137,7 +143,6 @@
|
|
|
137
143
|
- Add `@ar-agents/mercadopago/testing` subpath: factories + a mock client for tests.
|
|
138
144
|
|
|
139
145
|
What ships:
|
|
140
|
-
|
|
141
146
|
- **Factories**: `mockPayment`, `mockPreapproval`, `mockSubscriptionPayment`, `mockPreference`, `mockRefund`, `mockCustomer`. Each takes a partial overrides object so test setup is one line.
|
|
142
147
|
- **`MockMercadoPagoClient`**: in-memory client with the most-common create/get/cancel/refund paths. Read-only methods that don't fit a clean store model throw `MockNotImplementedError` to nudge users toward MSW or a real sandbox token rather than silently growing the mock.
|
|
143
148
|
- **`mockSignedWebhook`**: produces a `{ headers, searchParams, body }` triple whose `x-signature` header is a real HMAC-SHA256 against the secret you pass. Drops directly into `verifyWebhookSignature` — test the full webhook stack without hand-rolling the signature manifest.
|
|
@@ -544,34 +549,28 @@ Architectural features for at-scale deployment.
|
|
|
544
549
|
- MP v0.7: +25 new tools (81 total).
|
|
545
550
|
|
|
546
551
|
**Cierre de gaps obvios (8 tools)**:
|
|
547
|
-
|
|
548
552
|
- `get_customer`, `update_customer`, `create_customer_card`, `get_customer_card`
|
|
549
553
|
- `get_subscription_plan`, `update_subscription`, `search_subscriptions`
|
|
550
554
|
- `get_refund`, `update_payment_preference`
|
|
551
555
|
|
|
552
556
|
**Merchant Orders (3 tools — categoría completa nueva)**:
|
|
553
|
-
|
|
554
557
|
- `get_merchant_order`, `search_merchant_orders`, `update_merchant_order`
|
|
555
558
|
- MerchantOrder agrupa Payments asociados a una Preference — clave para reconciliar webhooks con `topic='merchant_order'`.
|
|
556
559
|
|
|
557
560
|
**Stores + POS CRUD completion (6 tools)**:
|
|
558
|
-
|
|
559
561
|
- `get_store`, `update_store`, `delete_store`
|
|
560
562
|
- `get_pos`, `update_pos`, `delete_pos`
|
|
561
563
|
|
|
562
564
|
**Bank Accounts (2 tools)**:
|
|
563
|
-
|
|
564
565
|
- `list_bank_accounts`, `register_bank_account`
|
|
565
566
|
|
|
566
567
|
**Point Devices físicos (5 tools — categoría nueva)**:
|
|
567
|
-
|
|
568
568
|
- `list_point_devices` (terminales físicas: Smart, Tap to Pay)
|
|
569
569
|
- `update_point_device_mode` (PDV vs STANDALONE)
|
|
570
570
|
- `create_point_payment_intent` (push payment al device — amount en CENTAVOS)
|
|
571
571
|
- `get_point_payment_intent`, `cancel_point_payment_intent`
|
|
572
572
|
|
|
573
573
|
**Pure helpers (2 tools, high-leverage)**:
|
|
574
|
-
|
|
575
574
|
- `compute_marketplace_fee` — given amount + (% o flat ARS, con min/max), returns exact `marketplace_fee`
|
|
576
575
|
- `explain_payment_status` — dado un Payment, traduce los 30+ status_detail codes a `{ summary, recommendedAction, final, paid, retryable }` en español
|
|
577
576
|
|
|
@@ -592,19 +591,16 @@ Architectural features for at-scale deployment.
|
|
|
592
591
|
- MP v0.6: account/balance + settlements + 3DS analyzer + test cards. **+6 tools (56 total)**.
|
|
593
592
|
|
|
594
593
|
**Account / Balance / Settlements (4 tools)**:
|
|
595
|
-
|
|
596
594
|
- `get_account_balance` — current MP wallet `{ available, unavailable, total, currency_id }`. Per-seller in marketplace setups.
|
|
597
595
|
- `list_account_movements({ from?, to?, limit?, offset? })` — wallet movement log (incoming payments, refunds, holdings, transfers).
|
|
598
596
|
- `list_settlements({ from?, to?, status? })` — `release_money` transfers from MP wallet → registered CBU.
|
|
599
597
|
- `get_settlement(id)` — single settlement detail with bank_account info.
|
|
600
598
|
|
|
601
599
|
**3DS analyzer (1 tool + 1 helper)**:
|
|
602
|
-
|
|
603
600
|
- `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.
|
|
604
601
|
- `analyze3DS(payment)` exported as a pure helper for callers who already have a Payment object.
|
|
605
602
|
|
|
606
603
|
**Test cards (1 tool + helpers)**:
|
|
607
|
-
|
|
608
604
|
- `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).
|
|
609
605
|
- `TEST_CARDS_AR`, `TEST_PAYERS_AR`, `buildTestCardScenario(card, scenario, amount)` exported for direct use in test files.
|
|
610
606
|
|
|
@@ -617,13 +613,11 @@ Architectural features for at-scale deployment.
|
|
|
617
613
|
- MP v0.5: production hardening + marketplace flows. **+9 tools (50 total)**.
|
|
618
614
|
|
|
619
615
|
**Webhook handler combo (1 tool)**:
|
|
620
|
-
|
|
621
616
|
- `handle_webhook` — verifies HMAC-SHA256 signature, parses the event, and (optionally) auto-fetches the underlying resource (Payment, Subscription) in ONE call. Replaces the manual chain of verify_webhook_signature + parse_webhook_event + get_payment.
|
|
622
617
|
- `mercadoPagoTools({ webhookSecret })` to enable.
|
|
623
618
|
- Returns `{ verified, event, resource, resource_error }`. Reject with HTTP 401 when `verified: false`.
|
|
624
619
|
|
|
625
620
|
**OAuth Marketplace flow (3 tools + 5 helper functions)**:
|
|
626
|
-
|
|
627
621
|
- `oauth_authorize_url` — pure function, builds the URL the seller visits to authorize your marketplace app.
|
|
628
622
|
- `oauth_exchange_code` — server-side exchange of the OAuth code for an `OAuthToken` (`access_token` + `refresh_token` + `user_id` + `expires_in`).
|
|
629
623
|
- `oauth_refresh_token` — refresh a per-seller token before it expires (~6h).
|
|
@@ -631,12 +625,10 @@ Architectural features for at-scale deployment.
|
|
|
631
625
|
- `mercadoPagoTools({ oauth: { clientId, clientSecret } })` to enable.
|
|
632
626
|
|
|
633
627
|
**Order Management API (5 tools)**:
|
|
634
|
-
|
|
635
628
|
- `create_order`, `get_order`, `update_order`, `capture_order`, `cancel_order` — MP's modern Order API. Distinct from Preference: explicit lifecycle, manual-capture support (auth-only flows for ride-share, hotels, marketplaces), multi-payment-per-order semantics.
|
|
636
629
|
- `capture_mode: "manual"` enables the auth-only flow → `capture_order(id, amount?)` later.
|
|
637
630
|
|
|
638
631
|
**Marketplace split payments**:
|
|
639
|
-
|
|
640
632
|
- `marketplace`, `marketplace_fee` (in ARS), `collector_id` (seller MP user_id) supported on BOTH `create_order` AND `create_payment_preference`.
|
|
641
633
|
- Funds route to the seller; `marketplace_fee` is split off to the marketplace's MP account.
|
|
642
634
|
|
|
@@ -655,7 +647,6 @@ Architectural features for at-scale deployment.
|
|
|
655
647
|
# New: Subscription Plans (5 tools)
|
|
656
648
|
|
|
657
649
|
For SaaS-style billing where you have fixed tiers (Básico/Pro/Enterprise), use plans instead of per-customer preapprovals.
|
|
658
|
-
|
|
659
650
|
- `create_subscription_plan` — define reusable plan (price + frequency + optional free trial)
|
|
660
651
|
- `list_subscription_plans` — list all plans
|
|
661
652
|
- `update_subscription_plan` — change reason / amount / status / back_url (existing subs keep old amount)
|
|
@@ -665,42 +656,36 @@ Architectural features for at-scale deployment.
|
|
|
665
656
|
# New: Stores + POS management (4 tools)
|
|
666
657
|
|
|
667
658
|
Self-serve setup for in-store QR payments. Eliminates the previous one-time MP dashboard step.
|
|
668
|
-
|
|
669
659
|
- `create_store` — create a store under the seller
|
|
670
660
|
- `list_stores` — list configured stores
|
|
671
661
|
- `create_pos` — create a POS under a store (the `external_id` is what `create_qr_payment` uses)
|
|
672
662
|
- `list_pos` — list POSes (optionally filtered by store_id)
|
|
673
663
|
|
|
674
664
|
# New: Disputes / Chargebacks (2 tools, read-only)
|
|
675
|
-
|
|
676
665
|
- `list_payment_disputes` — list disputes raised against a payment (surfaces `dashboard_url`)
|
|
677
666
|
- `get_dispute` — full dispute details (reason, amount, resolution status)
|
|
678
667
|
|
|
679
668
|
Resolution remains dashboard-only; the lib surfaces the right URL.
|
|
680
669
|
|
|
681
670
|
# New: Lookup helpers (2 tools)
|
|
682
|
-
|
|
683
671
|
- `list_identification_types` — AR returns DNI/CI/LE/LC/Otro/Pasaporte/CUIT/CUIL with min/max length
|
|
684
672
|
- `list_issuers` — banks issuing a card type. Pass `bin` (first 6-8 digits) for precise issuer detection — needed for issuer-specific cuotas promos like Naranja Galicia 6 cuotas sin interés
|
|
685
673
|
|
|
686
674
|
# New: Webhooks management (4 tools)
|
|
687
675
|
|
|
688
676
|
Programmatically configure webhook subscriptions instead of clicking around the MP dashboard.
|
|
689
|
-
|
|
690
677
|
- `list_webhooks` — see what's configured
|
|
691
678
|
- `create_webhook` — subscribe a URL to a topic (`payment`, `subscription_authorized_payment`, `merchant_order`, `point_integration_wh`, etc.)
|
|
692
679
|
- `update_webhook` — change URL or topic
|
|
693
680
|
- `delete_webhook` — unsubscribe
|
|
694
681
|
|
|
695
682
|
# Quality
|
|
696
|
-
|
|
697
683
|
- 81/81 tests pass (was 61 in v0.3) — added 20 tests for v0.4 endpoints
|
|
698
684
|
- 21.72 KB ESM brotli'd (under 32 KB budget)
|
|
699
685
|
- publint + arethetypeswrong all 🟢
|
|
700
686
|
- Type-safe end-to-end; new types: SubscriptionPlan, Store, Pos, Dispute, IdentificationType, Issuer, WebhookConfig, SubscriptionPayment
|
|
701
687
|
|
|
702
688
|
# Cumulative tool inventory (41 total)
|
|
703
|
-
|
|
704
689
|
- Subscriptions: 5 (create, get, cancel, pause, resume)
|
|
705
690
|
- Subscription Plans: 5 (create, list, update, subscribe, list_payments)
|
|
706
691
|
- Payments: 5 (create, get, search, cancel, capture)
|
|
@@ -724,7 +709,6 @@ Architectural features for at-scale deployment.
|
|
|
724
709
|
# `@ar-agents/mercadopago@0.3.0`
|
|
725
710
|
|
|
726
711
|
**Robustness (Section 6 of v0.3 spec)**
|
|
727
|
-
|
|
728
712
|
- Per-request timeout via `AbortSignal` (default 30s, configurable via `requestTimeoutMs`).
|
|
729
713
|
- Auto-retry on 5xx + 429 with exponential backoff (default 1 retry, configurable via `maxRetries`). Honors `Retry-After` header on rate-limit. **Never retries on 4xx** (deterministic user/config errors).
|
|
730
714
|
- New typed errors: `MercadoPagoTimeoutError`, `MercadoPagoOverloadedError` (HTML 503 detection — when MP returns HTML instead of JSON).
|
|
@@ -732,7 +716,6 @@ Architectural features for at-scale deployment.
|
|
|
732
716
|
- **Deterministic idempotency keys** — `create_payment` and `refund_payment` now use `sha256(meaningful_fields)` instead of `Date.now()`. Retries dedupe correctly on MP's side.
|
|
733
717
|
|
|
734
718
|
**New tools (3)**
|
|
735
|
-
|
|
736
719
|
- **`charge_saved_card`** — server-side retokenize + charge for returning customers. Requires CVV (AR MP doesn't support CVV-less via public API). Idempotent on (card_id, amount, external_reference).
|
|
737
720
|
- **`create_qr_payment`** — dynamic in-store QR via MP Point. Returns raw `qr_data` (EMVCo) + ready-to-display base64 PNG `qr_data_url`. Compatible with all AR wallets (Modo, BNA+, Cuenta DNI, Naranja X) via Transferencias 3.0 interop.
|
|
738
721
|
- **`cancel_qr_payment`** — clear a pending QR order on a POS so the next `create_qr_payment` doesn't 409.
|
|
@@ -742,26 +725,22 @@ Architectural features for at-scale deployment.
|
|
|
742
725
|
# `@ar-agents/identity-attest@0.2.0`
|
|
743
726
|
|
|
744
727
|
**3 new adapters bringing total to 5**
|
|
745
|
-
|
|
746
728
|
- **`Auth0Adapter`** (trust 0.7, or 0.85 with MFA) — OAuth2 Authorization Code flow with PKCE. Server-side `id_token` verification via `jose` JWKS. Optional MFA step-up via `acr_values` — when MFA is completed, `effective_trust_level` bumps to 0.85.
|
|
747
729
|
- **`MagicLinkSdkAdapter`** (trust 0.7) — Magic.link DIDToken validation via `@magic-sdk/admin` (optional peer dep). Lazy-loaded so users without Magic don't pay cold-start cost. Returns DID + email/phone/wallet claims.
|
|
748
730
|
- **`MercadoPagoIdentityAdapter`** (trust 0.5) — partial KYC via $1 micro-charge. MP doesn't expose a public KYC API, so we use payment-payer attestation: a successful payment proves MP validated the buyer's CUIT/DNI against their internal database. Auto-refunds the $1 by default. Returns `identification_type` + `identification_number` + email + name claims.
|
|
749
731
|
|
|
750
732
|
**New client methods**
|
|
751
|
-
|
|
752
733
|
- `submitOauthCode(requestId, code)` — for OAuth callbacks (Auth0)
|
|
753
734
|
- `submitMagicDidToken(requestId, didToken)` — for Magic.link
|
|
754
735
|
- `submitMercadoPagoPaymentId(requestId, paymentId)` — for MP webhook callbacks
|
|
755
736
|
|
|
756
737
|
**Quality**
|
|
757
|
-
|
|
758
738
|
- 28/28 tests pass (was 15 in v0.1)
|
|
759
739
|
- 12.93 KB ESM brotli'd (jose is treeshakeable; was 4.44 KB without OAuth adapter)
|
|
760
740
|
- publint + arethetypeswrong all 🟢
|
|
761
741
|
- `jose` is a dep (used by Auth0Adapter); `@magic-sdk/admin` is optional peer dep
|
|
762
742
|
|
|
763
743
|
**Trust levels reference (current)**
|
|
764
|
-
|
|
765
744
|
- 0.3 — `WhatsAppOtpAdapter` (phone-owned)
|
|
766
745
|
- 0.5 — `EmailMagicLinkAdapter` (email-owned), `MercadoPagoIdentityAdapter` (partial KYC)
|
|
767
746
|
- 0.7 — `Auth0Adapter` (federated identity), `MagicLinkSdkAdapter` (Magic-managed)
|
|
@@ -795,7 +774,6 @@ Architectural features for at-scale deployment.
|
|
|
795
774
|
Verified end-to-end against MP sandbox: account info, payment methods (21 AR methods returned), installments (81 visa offers with proper `recommended_message`), preference creation (returns real init_point + sandbox_init_point URLs).
|
|
796
775
|
|
|
797
776
|
# Documentation
|
|
798
|
-
|
|
799
777
|
- AGENTS.md updated with decision tree, status_detail recovery actions (top 12 values), AR-specific gotchas (statement_descriptor 13-char limit, sandbox cardholder name selects outcome, test cards reference, account_money instant settlement vs T+14 card hold, etc.).
|
|
800
778
|
- tools.manifest.json updated to v0.2 with all 21 tools documented (purity, sideEffects, latency, input/output schemas, whenToUse, whenNotToUse).
|
|
801
779
|
|
|
@@ -804,7 +782,6 @@ Architectural features for at-scale deployment.
|
|
|
804
782
|
8.07 KB ESM brotli'd (under 22 KB budget). Doubled tool count, still half the size limit.
|
|
805
783
|
|
|
806
784
|
# What's NOT in v0.2 (deferred to v0.3+)
|
|
807
|
-
|
|
808
785
|
- `charge_saved_card` (retokenize + charge in one call) — coming v0.3
|
|
809
786
|
- `create_qr_payment` (in-store dynamic QR) — coming v0.3
|
|
810
787
|
- Marketplace splits (OAuth, application_fee) — v0.4
|
package/dist/index.cjs
CHANGED
|
@@ -1944,7 +1944,17 @@ async function parseTokenResponse(res) {
|
|
|
1944
1944
|
`MP OAuth ${res.status}: ${text.slice(0, 300)}`
|
|
1945
1945
|
);
|
|
1946
1946
|
}
|
|
1947
|
-
|
|
1947
|
+
let json;
|
|
1948
|
+
try {
|
|
1949
|
+
json = JSON.parse(text);
|
|
1950
|
+
} catch {
|
|
1951
|
+
throw new MercadoPagoError(
|
|
1952
|
+
`MP OAuth ${res.status}: token response is not valid JSON: ${text.slice(0, 300)}`,
|
|
1953
|
+
res.status,
|
|
1954
|
+
"/oauth/token",
|
|
1955
|
+
text.slice(0, 300)
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1948
1958
|
return OAuthTokenSchema.parse(json);
|
|
1949
1959
|
}
|
|
1950
1960
|
function expirationTimeMs(issuedAtMs, expiresInSeconds) {
|