@ar-agents/mercadopago 0.3.0 → 0.4.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 +9 -0
- package/CHANGELOG.md +71 -0
- package/dist/index.cjs +689 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +279 -2
- package/dist/index.d.ts +279 -2
- package/dist/index.js +689 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -619,6 +619,186 @@ declare const AccountInfoSchema: z.ZodObject<{
|
|
|
619
619
|
}, z.core.$loose>>>;
|
|
620
620
|
}, z.core.$loose>;
|
|
621
621
|
type AccountInfo = z.infer<typeof AccountInfoSchema>;
|
|
622
|
+
/**
|
|
623
|
+
* A reusable subscription plan. Different from a per-customer subscription:
|
|
624
|
+
* a plan defines the price + frequency once, then customers subscribe to it
|
|
625
|
+
* via `subscribe_to_plan` (which creates a preapproval pointing at the plan).
|
|
626
|
+
*
|
|
627
|
+
* Use plans for SaaS-style billing where you have a fixed set of tiers
|
|
628
|
+
* (Básico/Pro/Enterprise) instead of negotiating amounts per customer.
|
|
629
|
+
*/
|
|
630
|
+
declare const SubscriptionPlanSchema: z.ZodObject<{
|
|
631
|
+
id: z.ZodString;
|
|
632
|
+
status: z.ZodString;
|
|
633
|
+
reason: z.ZodString;
|
|
634
|
+
back_url: z.ZodOptional<z.ZodString>;
|
|
635
|
+
external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
636
|
+
date_created: z.ZodString;
|
|
637
|
+
last_modified: z.ZodString;
|
|
638
|
+
auto_recurring: z.ZodObject<{
|
|
639
|
+
frequency: z.ZodNumber;
|
|
640
|
+
frequency_type: z.ZodEnum<{
|
|
641
|
+
months: "months";
|
|
642
|
+
days: "days";
|
|
643
|
+
}>;
|
|
644
|
+
transaction_amount: z.ZodNumber;
|
|
645
|
+
currency_id: z.ZodEnum<{
|
|
646
|
+
ARS: "ARS";
|
|
647
|
+
USD: "USD";
|
|
648
|
+
BRL: "BRL";
|
|
649
|
+
MXN: "MXN";
|
|
650
|
+
}>;
|
|
651
|
+
start_date: z.ZodOptional<z.ZodString>;
|
|
652
|
+
end_date: z.ZodOptional<z.ZodString>;
|
|
653
|
+
}, z.core.$strip>;
|
|
654
|
+
}, z.core.$loose>;
|
|
655
|
+
type SubscriptionPlan = z.infer<typeof SubscriptionPlanSchema>;
|
|
656
|
+
interface CreateSubscriptionPlanParams {
|
|
657
|
+
/** Customer-facing plan name shown at checkout. */
|
|
658
|
+
reason: string;
|
|
659
|
+
/** Where MP redirects buyer after first payment. HTTPS only. */
|
|
660
|
+
backUrl: string;
|
|
661
|
+
/** Recurrence (e.g., 1 + months = monthly). */
|
|
662
|
+
frequency: number;
|
|
663
|
+
frequencyType: FrequencyType;
|
|
664
|
+
/** Amount per cycle. */
|
|
665
|
+
amount: number;
|
|
666
|
+
/** ARS for AR. */
|
|
667
|
+
currency: CurrencyId;
|
|
668
|
+
/** Optional plan-level identifier from your system. */
|
|
669
|
+
externalReference?: string;
|
|
670
|
+
/** Free trial days before first charge. */
|
|
671
|
+
freeTrialFrequency?: number;
|
|
672
|
+
freeTrialFrequencyType?: FrequencyType;
|
|
673
|
+
}
|
|
674
|
+
declare const StoreSchema: z.ZodObject<{
|
|
675
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
676
|
+
name: z.ZodOptional<z.ZodString>;
|
|
677
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
678
|
+
date_creation: z.ZodOptional<z.ZodString>;
|
|
679
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
680
|
+
address_line: z.ZodOptional<z.ZodString>;
|
|
681
|
+
city_name: z.ZodOptional<z.ZodString>;
|
|
682
|
+
state_name: z.ZodOptional<z.ZodString>;
|
|
683
|
+
country_id: z.ZodOptional<z.ZodString>;
|
|
684
|
+
latitude: z.ZodOptional<z.ZodNumber>;
|
|
685
|
+
longitude: z.ZodOptional<z.ZodNumber>;
|
|
686
|
+
}, z.core.$loose>>;
|
|
687
|
+
}, z.core.$loose>;
|
|
688
|
+
type Store = z.infer<typeof StoreSchema>;
|
|
689
|
+
interface CreateStoreParams {
|
|
690
|
+
/** Display name for the store. */
|
|
691
|
+
name: string;
|
|
692
|
+
/** Caller-defined identifier (must be unique within the seller's stores). */
|
|
693
|
+
externalId: string;
|
|
694
|
+
/** Optional physical location. */
|
|
695
|
+
location?: {
|
|
696
|
+
addressLine?: string;
|
|
697
|
+
cityName?: string;
|
|
698
|
+
stateName?: string;
|
|
699
|
+
countryId?: string;
|
|
700
|
+
latitude?: number;
|
|
701
|
+
longitude?: number;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
declare const PosSchema: z.ZodObject<{
|
|
705
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
706
|
+
name: z.ZodOptional<z.ZodString>;
|
|
707
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
708
|
+
store_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
709
|
+
category: z.ZodOptional<z.ZodNumber>;
|
|
710
|
+
fixed_amount: z.ZodOptional<z.ZodBoolean>;
|
|
711
|
+
qr: z.ZodOptional<z.ZodObject<{
|
|
712
|
+
template_image: z.ZodOptional<z.ZodString>;
|
|
713
|
+
image: z.ZodOptional<z.ZodString>;
|
|
714
|
+
}, z.core.$loose>>;
|
|
715
|
+
date_creation: z.ZodOptional<z.ZodString>;
|
|
716
|
+
}, z.core.$loose>;
|
|
717
|
+
type Pos = z.infer<typeof PosSchema>;
|
|
718
|
+
interface CreatePosParams {
|
|
719
|
+
/** Display name. */
|
|
720
|
+
name: string;
|
|
721
|
+
/** Caller-defined POS id (used in QR endpoints; unique within store). */
|
|
722
|
+
externalId: string;
|
|
723
|
+
/** Parent store id (number from createStore). */
|
|
724
|
+
storeId: string | number;
|
|
725
|
+
/** MP category code (default 621102 = Other Food and Beverage Services). */
|
|
726
|
+
category?: number;
|
|
727
|
+
/** If true, the QR has a fixed amount; if false, dynamic per-order. */
|
|
728
|
+
fixedAmount?: boolean;
|
|
729
|
+
}
|
|
730
|
+
declare const DisputeSchema: z.ZodObject<{
|
|
731
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
732
|
+
status: z.ZodString;
|
|
733
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
734
|
+
resource_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
735
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
736
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
737
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
738
|
+
resolution: z.ZodOptional<z.ZodObject<{
|
|
739
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
740
|
+
result: z.ZodOptional<z.ZodString>;
|
|
741
|
+
date: z.ZodOptional<z.ZodString>;
|
|
742
|
+
}, z.core.$loose>>;
|
|
743
|
+
documents: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
744
|
+
reason_description: z.ZodOptional<z.ZodString>;
|
|
745
|
+
}, z.core.$loose>;
|
|
746
|
+
type Dispute = z.infer<typeof DisputeSchema>;
|
|
747
|
+
declare const SubscriptionPaymentSchema: z.ZodObject<{
|
|
748
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
749
|
+
preapproval_id: z.ZodOptional<z.ZodString>;
|
|
750
|
+
status: z.ZodString;
|
|
751
|
+
payment_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
752
|
+
transaction_amount: z.ZodOptional<z.ZodNumber>;
|
|
753
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
754
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
755
|
+
debit_date: z.ZodOptional<z.ZodString>;
|
|
756
|
+
next_retry_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
757
|
+
retry_attempt: z.ZodOptional<z.ZodNumber>;
|
|
758
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
759
|
+
}, z.core.$loose>;
|
|
760
|
+
type SubscriptionPayment = z.infer<typeof SubscriptionPaymentSchema>;
|
|
761
|
+
declare const IdentificationTypeSchema: z.ZodObject<{
|
|
762
|
+
id: z.ZodString;
|
|
763
|
+
name: z.ZodString;
|
|
764
|
+
type: z.ZodString;
|
|
765
|
+
min_length: z.ZodOptional<z.ZodNumber>;
|
|
766
|
+
max_length: z.ZodOptional<z.ZodNumber>;
|
|
767
|
+
}, z.core.$loose>;
|
|
768
|
+
type IdentificationType = z.infer<typeof IdentificationTypeSchema>;
|
|
769
|
+
declare const IssuerSchema: z.ZodObject<{
|
|
770
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
771
|
+
name: z.ZodString;
|
|
772
|
+
secure_thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
773
|
+
thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
774
|
+
processing_mode: z.ZodOptional<z.ZodString>;
|
|
775
|
+
status: z.ZodOptional<z.ZodString>;
|
|
776
|
+
}, z.core.$loose>;
|
|
777
|
+
type Issuer = z.infer<typeof IssuerSchema>;
|
|
778
|
+
/** Topics MP can fire webhooks for. Add more as MP exposes them. */
|
|
779
|
+
declare const WebhookTopicSchema: z.ZodEnum<{
|
|
780
|
+
payment: "payment";
|
|
781
|
+
subscription_authorized_payment: "subscription_authorized_payment";
|
|
782
|
+
subscription_preapproval: "subscription_preapproval";
|
|
783
|
+
merchant_order: "merchant_order";
|
|
784
|
+
point_integration_wh: "point_integration_wh";
|
|
785
|
+
stop_delivery_op_wh: "stop_delivery_op_wh";
|
|
786
|
+
}>;
|
|
787
|
+
type WebhookTopic = z.infer<typeof WebhookTopicSchema>;
|
|
788
|
+
declare const WebhookConfigSchema: z.ZodObject<{
|
|
789
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
790
|
+
url: z.ZodOptional<z.ZodString>;
|
|
791
|
+
status: z.ZodOptional<z.ZodString>;
|
|
792
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
793
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
794
|
+
date_modified: z.ZodOptional<z.ZodString>;
|
|
795
|
+
}, z.core.$loose>;
|
|
796
|
+
type WebhookConfig = z.infer<typeof WebhookConfigSchema>;
|
|
797
|
+
interface CreateWebhookParams {
|
|
798
|
+
url: string;
|
|
799
|
+
/** Topic to subscribe to. */
|
|
800
|
+
topic: WebhookTopic | string;
|
|
801
|
+
}
|
|
622
802
|
|
|
623
803
|
interface MercadoPagoClientOptions {
|
|
624
804
|
/** Access token. TEST- prefix for sandbox, APP_USR- for production. */
|
|
@@ -820,6 +1000,103 @@ declare class MercadoPagoClient {
|
|
|
820
1000
|
* — otherwise the next `createQrPayment` on the same POS returns 409.
|
|
821
1001
|
*/
|
|
822
1002
|
cancelQrPayment(userId: string, externalPosId: string): Promise<void>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Create a reusable subscription plan. Customers later subscribe to it via
|
|
1005
|
+
* `subscribeToPlan` (which creates a preapproval pointing at the plan).
|
|
1006
|
+
*
|
|
1007
|
+
* Use this when you have fixed tiers (Básico/Pro/Enterprise). For custom
|
|
1008
|
+
* per-customer amounts, skip plans and use `createPreapproval` directly.
|
|
1009
|
+
*/
|
|
1010
|
+
createSubscriptionPlan(params: CreateSubscriptionPlanParams): Promise<SubscriptionPlan>;
|
|
1011
|
+
getSubscriptionPlan(id: string): Promise<SubscriptionPlan>;
|
|
1012
|
+
listSubscriptionPlans(params?: {
|
|
1013
|
+
limit?: number;
|
|
1014
|
+
offset?: number;
|
|
1015
|
+
status?: string;
|
|
1016
|
+
}): Promise<{
|
|
1017
|
+
paging: {
|
|
1018
|
+
total: number;
|
|
1019
|
+
limit: number;
|
|
1020
|
+
offset: number;
|
|
1021
|
+
};
|
|
1022
|
+
results: SubscriptionPlan[];
|
|
1023
|
+
}>;
|
|
1024
|
+
updateSubscriptionPlan(id: string, patch: {
|
|
1025
|
+
reason?: string;
|
|
1026
|
+
status?: "active" | "cancelled";
|
|
1027
|
+
amount?: number;
|
|
1028
|
+
backUrl?: string;
|
|
1029
|
+
}): Promise<SubscriptionPlan>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Subscribe a customer to an existing plan. Returns a Preapproval with
|
|
1032
|
+
* `init_point` URL where the buyer completes the first payment.
|
|
1033
|
+
*/
|
|
1034
|
+
subscribeToPlan(params: {
|
|
1035
|
+
planId: string;
|
|
1036
|
+
payerEmail: string;
|
|
1037
|
+
cardTokenId?: string;
|
|
1038
|
+
externalReference?: string;
|
|
1039
|
+
}): Promise<Preapproval>;
|
|
1040
|
+
/**
|
|
1041
|
+
* List the auto-charge attempts (authorized_payments) under a preapproval.
|
|
1042
|
+
* Useful for "show me the cobros of the last 6 months for this client".
|
|
1043
|
+
*/
|
|
1044
|
+
listSubscriptionPayments(preapprovalId: string, params?: {
|
|
1045
|
+
limit?: number;
|
|
1046
|
+
offset?: number;
|
|
1047
|
+
}): Promise<{
|
|
1048
|
+
paging: {
|
|
1049
|
+
total: number;
|
|
1050
|
+
limit: number;
|
|
1051
|
+
offset: number;
|
|
1052
|
+
};
|
|
1053
|
+
results: SubscriptionPayment[];
|
|
1054
|
+
}>;
|
|
1055
|
+
/** Create a store for the seller. POSes (for QR) live under stores. */
|
|
1056
|
+
createStore(userId: string, params: CreateStoreParams): Promise<Store>;
|
|
1057
|
+
listStores(userId: string, params?: {
|
|
1058
|
+
limit?: number;
|
|
1059
|
+
offset?: number;
|
|
1060
|
+
}): Promise<{
|
|
1061
|
+
paging: {
|
|
1062
|
+
total: number;
|
|
1063
|
+
limit: number;
|
|
1064
|
+
offset: number;
|
|
1065
|
+
};
|
|
1066
|
+
results: Store[];
|
|
1067
|
+
}>;
|
|
1068
|
+
/** Create a POS under a store. The POS's `external_id` is what `createQrPayment` uses. */
|
|
1069
|
+
createPos(params: CreatePosParams): Promise<Pos>;
|
|
1070
|
+
listPos(params?: {
|
|
1071
|
+
storeId?: string | number;
|
|
1072
|
+
limit?: number;
|
|
1073
|
+
offset?: number;
|
|
1074
|
+
}): Promise<{
|
|
1075
|
+
paging: {
|
|
1076
|
+
total: number;
|
|
1077
|
+
limit: number;
|
|
1078
|
+
offset: number;
|
|
1079
|
+
};
|
|
1080
|
+
results: Pos[];
|
|
1081
|
+
}>;
|
|
1082
|
+
listPaymentDisputes(paymentId: string): Promise<Dispute[]>;
|
|
1083
|
+
getDispute(paymentId: string, disputeId: string): Promise<Dispute>;
|
|
1084
|
+
/** List valid identification types for the seller's site. AR returns DNI/CI/LE/LC/Otro/Pasaporte/CUIT/CUIL. */
|
|
1085
|
+
listIdentificationTypes(): Promise<IdentificationType[]>;
|
|
1086
|
+
/** List card issuers for a payment method. Useful with `bin` for installments. */
|
|
1087
|
+
listIssuers(params: {
|
|
1088
|
+
paymentMethodId: string;
|
|
1089
|
+
bin?: string;
|
|
1090
|
+
}): Promise<Issuer[]>;
|
|
1091
|
+
/** List configured webhook subscriptions. */
|
|
1092
|
+
listWebhooks(): Promise<WebhookConfig[]>;
|
|
1093
|
+
/** Create a webhook subscription for a topic. */
|
|
1094
|
+
createWebhook(params: CreateWebhookParams): Promise<WebhookConfig>;
|
|
1095
|
+
updateWebhook(id: string, patch: {
|
|
1096
|
+
url?: string;
|
|
1097
|
+
topic?: string;
|
|
1098
|
+
}): Promise<WebhookConfig>;
|
|
1099
|
+
deleteWebhook(id: string): Promise<void>;
|
|
823
1100
|
}
|
|
824
1101
|
|
|
825
1102
|
/**
|
|
@@ -888,7 +1165,7 @@ interface MercadoPagoToolsOptions {
|
|
|
888
1165
|
*/
|
|
889
1166
|
notificationUrl?: string;
|
|
890
1167
|
}
|
|
891
|
-
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";
|
|
1168
|
+
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";
|
|
892
1169
|
/**
|
|
893
1170
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
894
1171
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -954,4 +1231,4 @@ declare function verifyWebhookSignature(params: {
|
|
|
954
1231
|
secret: string;
|
|
955
1232
|
}): boolean;
|
|
956
1233
|
|
|
957
|
-
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreatePaymentParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CurrencyId, type Customer, type CustomerCard, type FrequencyType, InMemoryStateAdapter, type InstallmentOffer, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|
|
1234
|
+
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, 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, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, 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 SiteId, type Store, type SubscriptionPayment, type SubscriptionPlan, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, type WebhookConfig, type WebhookTopic, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -619,6 +619,186 @@ declare const AccountInfoSchema: z.ZodObject<{
|
|
|
619
619
|
}, z.core.$loose>>>;
|
|
620
620
|
}, z.core.$loose>;
|
|
621
621
|
type AccountInfo = z.infer<typeof AccountInfoSchema>;
|
|
622
|
+
/**
|
|
623
|
+
* A reusable subscription plan. Different from a per-customer subscription:
|
|
624
|
+
* a plan defines the price + frequency once, then customers subscribe to it
|
|
625
|
+
* via `subscribe_to_plan` (which creates a preapproval pointing at the plan).
|
|
626
|
+
*
|
|
627
|
+
* Use plans for SaaS-style billing where you have a fixed set of tiers
|
|
628
|
+
* (Básico/Pro/Enterprise) instead of negotiating amounts per customer.
|
|
629
|
+
*/
|
|
630
|
+
declare const SubscriptionPlanSchema: z.ZodObject<{
|
|
631
|
+
id: z.ZodString;
|
|
632
|
+
status: z.ZodString;
|
|
633
|
+
reason: z.ZodString;
|
|
634
|
+
back_url: z.ZodOptional<z.ZodString>;
|
|
635
|
+
external_reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
636
|
+
date_created: z.ZodString;
|
|
637
|
+
last_modified: z.ZodString;
|
|
638
|
+
auto_recurring: z.ZodObject<{
|
|
639
|
+
frequency: z.ZodNumber;
|
|
640
|
+
frequency_type: z.ZodEnum<{
|
|
641
|
+
months: "months";
|
|
642
|
+
days: "days";
|
|
643
|
+
}>;
|
|
644
|
+
transaction_amount: z.ZodNumber;
|
|
645
|
+
currency_id: z.ZodEnum<{
|
|
646
|
+
ARS: "ARS";
|
|
647
|
+
USD: "USD";
|
|
648
|
+
BRL: "BRL";
|
|
649
|
+
MXN: "MXN";
|
|
650
|
+
}>;
|
|
651
|
+
start_date: z.ZodOptional<z.ZodString>;
|
|
652
|
+
end_date: z.ZodOptional<z.ZodString>;
|
|
653
|
+
}, z.core.$strip>;
|
|
654
|
+
}, z.core.$loose>;
|
|
655
|
+
type SubscriptionPlan = z.infer<typeof SubscriptionPlanSchema>;
|
|
656
|
+
interface CreateSubscriptionPlanParams {
|
|
657
|
+
/** Customer-facing plan name shown at checkout. */
|
|
658
|
+
reason: string;
|
|
659
|
+
/** Where MP redirects buyer after first payment. HTTPS only. */
|
|
660
|
+
backUrl: string;
|
|
661
|
+
/** Recurrence (e.g., 1 + months = monthly). */
|
|
662
|
+
frequency: number;
|
|
663
|
+
frequencyType: FrequencyType;
|
|
664
|
+
/** Amount per cycle. */
|
|
665
|
+
amount: number;
|
|
666
|
+
/** ARS for AR. */
|
|
667
|
+
currency: CurrencyId;
|
|
668
|
+
/** Optional plan-level identifier from your system. */
|
|
669
|
+
externalReference?: string;
|
|
670
|
+
/** Free trial days before first charge. */
|
|
671
|
+
freeTrialFrequency?: number;
|
|
672
|
+
freeTrialFrequencyType?: FrequencyType;
|
|
673
|
+
}
|
|
674
|
+
declare const StoreSchema: z.ZodObject<{
|
|
675
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
676
|
+
name: z.ZodOptional<z.ZodString>;
|
|
677
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
678
|
+
date_creation: z.ZodOptional<z.ZodString>;
|
|
679
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
680
|
+
address_line: z.ZodOptional<z.ZodString>;
|
|
681
|
+
city_name: z.ZodOptional<z.ZodString>;
|
|
682
|
+
state_name: z.ZodOptional<z.ZodString>;
|
|
683
|
+
country_id: z.ZodOptional<z.ZodString>;
|
|
684
|
+
latitude: z.ZodOptional<z.ZodNumber>;
|
|
685
|
+
longitude: z.ZodOptional<z.ZodNumber>;
|
|
686
|
+
}, z.core.$loose>>;
|
|
687
|
+
}, z.core.$loose>;
|
|
688
|
+
type Store = z.infer<typeof StoreSchema>;
|
|
689
|
+
interface CreateStoreParams {
|
|
690
|
+
/** Display name for the store. */
|
|
691
|
+
name: string;
|
|
692
|
+
/** Caller-defined identifier (must be unique within the seller's stores). */
|
|
693
|
+
externalId: string;
|
|
694
|
+
/** Optional physical location. */
|
|
695
|
+
location?: {
|
|
696
|
+
addressLine?: string;
|
|
697
|
+
cityName?: string;
|
|
698
|
+
stateName?: string;
|
|
699
|
+
countryId?: string;
|
|
700
|
+
latitude?: number;
|
|
701
|
+
longitude?: number;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
declare const PosSchema: z.ZodObject<{
|
|
705
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
706
|
+
name: z.ZodOptional<z.ZodString>;
|
|
707
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
708
|
+
store_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
709
|
+
category: z.ZodOptional<z.ZodNumber>;
|
|
710
|
+
fixed_amount: z.ZodOptional<z.ZodBoolean>;
|
|
711
|
+
qr: z.ZodOptional<z.ZodObject<{
|
|
712
|
+
template_image: z.ZodOptional<z.ZodString>;
|
|
713
|
+
image: z.ZodOptional<z.ZodString>;
|
|
714
|
+
}, z.core.$loose>>;
|
|
715
|
+
date_creation: z.ZodOptional<z.ZodString>;
|
|
716
|
+
}, z.core.$loose>;
|
|
717
|
+
type Pos = z.infer<typeof PosSchema>;
|
|
718
|
+
interface CreatePosParams {
|
|
719
|
+
/** Display name. */
|
|
720
|
+
name: string;
|
|
721
|
+
/** Caller-defined POS id (used in QR endpoints; unique within store). */
|
|
722
|
+
externalId: string;
|
|
723
|
+
/** Parent store id (number from createStore). */
|
|
724
|
+
storeId: string | number;
|
|
725
|
+
/** MP category code (default 621102 = Other Food and Beverage Services). */
|
|
726
|
+
category?: number;
|
|
727
|
+
/** If true, the QR has a fixed amount; if false, dynamic per-order. */
|
|
728
|
+
fixedAmount?: boolean;
|
|
729
|
+
}
|
|
730
|
+
declare const DisputeSchema: z.ZodObject<{
|
|
731
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
732
|
+
status: z.ZodString;
|
|
733
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
734
|
+
resource_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
735
|
+
amount: z.ZodOptional<z.ZodNumber>;
|
|
736
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
737
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
738
|
+
resolution: z.ZodOptional<z.ZodObject<{
|
|
739
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
740
|
+
result: z.ZodOptional<z.ZodString>;
|
|
741
|
+
date: z.ZodOptional<z.ZodString>;
|
|
742
|
+
}, z.core.$loose>>;
|
|
743
|
+
documents: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
744
|
+
reason_description: z.ZodOptional<z.ZodString>;
|
|
745
|
+
}, z.core.$loose>;
|
|
746
|
+
type Dispute = z.infer<typeof DisputeSchema>;
|
|
747
|
+
declare const SubscriptionPaymentSchema: z.ZodObject<{
|
|
748
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
749
|
+
preapproval_id: z.ZodOptional<z.ZodString>;
|
|
750
|
+
status: z.ZodString;
|
|
751
|
+
payment_id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
752
|
+
transaction_amount: z.ZodOptional<z.ZodNumber>;
|
|
753
|
+
currency_id: z.ZodOptional<z.ZodString>;
|
|
754
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
755
|
+
debit_date: z.ZodOptional<z.ZodString>;
|
|
756
|
+
next_retry_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
757
|
+
retry_attempt: z.ZodOptional<z.ZodNumber>;
|
|
758
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
759
|
+
}, z.core.$loose>;
|
|
760
|
+
type SubscriptionPayment = z.infer<typeof SubscriptionPaymentSchema>;
|
|
761
|
+
declare const IdentificationTypeSchema: z.ZodObject<{
|
|
762
|
+
id: z.ZodString;
|
|
763
|
+
name: z.ZodString;
|
|
764
|
+
type: z.ZodString;
|
|
765
|
+
min_length: z.ZodOptional<z.ZodNumber>;
|
|
766
|
+
max_length: z.ZodOptional<z.ZodNumber>;
|
|
767
|
+
}, z.core.$loose>;
|
|
768
|
+
type IdentificationType = z.infer<typeof IdentificationTypeSchema>;
|
|
769
|
+
declare const IssuerSchema: z.ZodObject<{
|
|
770
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
771
|
+
name: z.ZodString;
|
|
772
|
+
secure_thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
773
|
+
thumbnail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
774
|
+
processing_mode: z.ZodOptional<z.ZodString>;
|
|
775
|
+
status: z.ZodOptional<z.ZodString>;
|
|
776
|
+
}, z.core.$loose>;
|
|
777
|
+
type Issuer = z.infer<typeof IssuerSchema>;
|
|
778
|
+
/** Topics MP can fire webhooks for. Add more as MP exposes them. */
|
|
779
|
+
declare const WebhookTopicSchema: z.ZodEnum<{
|
|
780
|
+
payment: "payment";
|
|
781
|
+
subscription_authorized_payment: "subscription_authorized_payment";
|
|
782
|
+
subscription_preapproval: "subscription_preapproval";
|
|
783
|
+
merchant_order: "merchant_order";
|
|
784
|
+
point_integration_wh: "point_integration_wh";
|
|
785
|
+
stop_delivery_op_wh: "stop_delivery_op_wh";
|
|
786
|
+
}>;
|
|
787
|
+
type WebhookTopic = z.infer<typeof WebhookTopicSchema>;
|
|
788
|
+
declare const WebhookConfigSchema: z.ZodObject<{
|
|
789
|
+
id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
|
|
790
|
+
url: z.ZodOptional<z.ZodString>;
|
|
791
|
+
status: z.ZodOptional<z.ZodString>;
|
|
792
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
793
|
+
date_created: z.ZodOptional<z.ZodString>;
|
|
794
|
+
date_modified: z.ZodOptional<z.ZodString>;
|
|
795
|
+
}, z.core.$loose>;
|
|
796
|
+
type WebhookConfig = z.infer<typeof WebhookConfigSchema>;
|
|
797
|
+
interface CreateWebhookParams {
|
|
798
|
+
url: string;
|
|
799
|
+
/** Topic to subscribe to. */
|
|
800
|
+
topic: WebhookTopic | string;
|
|
801
|
+
}
|
|
622
802
|
|
|
623
803
|
interface MercadoPagoClientOptions {
|
|
624
804
|
/** Access token. TEST- prefix for sandbox, APP_USR- for production. */
|
|
@@ -820,6 +1000,103 @@ declare class MercadoPagoClient {
|
|
|
820
1000
|
* — otherwise the next `createQrPayment` on the same POS returns 409.
|
|
821
1001
|
*/
|
|
822
1002
|
cancelQrPayment(userId: string, externalPosId: string): Promise<void>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Create a reusable subscription plan. Customers later subscribe to it via
|
|
1005
|
+
* `subscribeToPlan` (which creates a preapproval pointing at the plan).
|
|
1006
|
+
*
|
|
1007
|
+
* Use this when you have fixed tiers (Básico/Pro/Enterprise). For custom
|
|
1008
|
+
* per-customer amounts, skip plans and use `createPreapproval` directly.
|
|
1009
|
+
*/
|
|
1010
|
+
createSubscriptionPlan(params: CreateSubscriptionPlanParams): Promise<SubscriptionPlan>;
|
|
1011
|
+
getSubscriptionPlan(id: string): Promise<SubscriptionPlan>;
|
|
1012
|
+
listSubscriptionPlans(params?: {
|
|
1013
|
+
limit?: number;
|
|
1014
|
+
offset?: number;
|
|
1015
|
+
status?: string;
|
|
1016
|
+
}): Promise<{
|
|
1017
|
+
paging: {
|
|
1018
|
+
total: number;
|
|
1019
|
+
limit: number;
|
|
1020
|
+
offset: number;
|
|
1021
|
+
};
|
|
1022
|
+
results: SubscriptionPlan[];
|
|
1023
|
+
}>;
|
|
1024
|
+
updateSubscriptionPlan(id: string, patch: {
|
|
1025
|
+
reason?: string;
|
|
1026
|
+
status?: "active" | "cancelled";
|
|
1027
|
+
amount?: number;
|
|
1028
|
+
backUrl?: string;
|
|
1029
|
+
}): Promise<SubscriptionPlan>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Subscribe a customer to an existing plan. Returns a Preapproval with
|
|
1032
|
+
* `init_point` URL where the buyer completes the first payment.
|
|
1033
|
+
*/
|
|
1034
|
+
subscribeToPlan(params: {
|
|
1035
|
+
planId: string;
|
|
1036
|
+
payerEmail: string;
|
|
1037
|
+
cardTokenId?: string;
|
|
1038
|
+
externalReference?: string;
|
|
1039
|
+
}): Promise<Preapproval>;
|
|
1040
|
+
/**
|
|
1041
|
+
* List the auto-charge attempts (authorized_payments) under a preapproval.
|
|
1042
|
+
* Useful for "show me the cobros of the last 6 months for this client".
|
|
1043
|
+
*/
|
|
1044
|
+
listSubscriptionPayments(preapprovalId: string, params?: {
|
|
1045
|
+
limit?: number;
|
|
1046
|
+
offset?: number;
|
|
1047
|
+
}): Promise<{
|
|
1048
|
+
paging: {
|
|
1049
|
+
total: number;
|
|
1050
|
+
limit: number;
|
|
1051
|
+
offset: number;
|
|
1052
|
+
};
|
|
1053
|
+
results: SubscriptionPayment[];
|
|
1054
|
+
}>;
|
|
1055
|
+
/** Create a store for the seller. POSes (for QR) live under stores. */
|
|
1056
|
+
createStore(userId: string, params: CreateStoreParams): Promise<Store>;
|
|
1057
|
+
listStores(userId: string, params?: {
|
|
1058
|
+
limit?: number;
|
|
1059
|
+
offset?: number;
|
|
1060
|
+
}): Promise<{
|
|
1061
|
+
paging: {
|
|
1062
|
+
total: number;
|
|
1063
|
+
limit: number;
|
|
1064
|
+
offset: number;
|
|
1065
|
+
};
|
|
1066
|
+
results: Store[];
|
|
1067
|
+
}>;
|
|
1068
|
+
/** Create a POS under a store. The POS's `external_id` is what `createQrPayment` uses. */
|
|
1069
|
+
createPos(params: CreatePosParams): Promise<Pos>;
|
|
1070
|
+
listPos(params?: {
|
|
1071
|
+
storeId?: string | number;
|
|
1072
|
+
limit?: number;
|
|
1073
|
+
offset?: number;
|
|
1074
|
+
}): Promise<{
|
|
1075
|
+
paging: {
|
|
1076
|
+
total: number;
|
|
1077
|
+
limit: number;
|
|
1078
|
+
offset: number;
|
|
1079
|
+
};
|
|
1080
|
+
results: Pos[];
|
|
1081
|
+
}>;
|
|
1082
|
+
listPaymentDisputes(paymentId: string): Promise<Dispute[]>;
|
|
1083
|
+
getDispute(paymentId: string, disputeId: string): Promise<Dispute>;
|
|
1084
|
+
/** List valid identification types for the seller's site. AR returns DNI/CI/LE/LC/Otro/Pasaporte/CUIT/CUIL. */
|
|
1085
|
+
listIdentificationTypes(): Promise<IdentificationType[]>;
|
|
1086
|
+
/** List card issuers for a payment method. Useful with `bin` for installments. */
|
|
1087
|
+
listIssuers(params: {
|
|
1088
|
+
paymentMethodId: string;
|
|
1089
|
+
bin?: string;
|
|
1090
|
+
}): Promise<Issuer[]>;
|
|
1091
|
+
/** List configured webhook subscriptions. */
|
|
1092
|
+
listWebhooks(): Promise<WebhookConfig[]>;
|
|
1093
|
+
/** Create a webhook subscription for a topic. */
|
|
1094
|
+
createWebhook(params: CreateWebhookParams): Promise<WebhookConfig>;
|
|
1095
|
+
updateWebhook(id: string, patch: {
|
|
1096
|
+
url?: string;
|
|
1097
|
+
topic?: string;
|
|
1098
|
+
}): Promise<WebhookConfig>;
|
|
1099
|
+
deleteWebhook(id: string): Promise<void>;
|
|
823
1100
|
}
|
|
824
1101
|
|
|
825
1102
|
/**
|
|
@@ -888,7 +1165,7 @@ interface MercadoPagoToolsOptions {
|
|
|
888
1165
|
*/
|
|
889
1166
|
notificationUrl?: string;
|
|
890
1167
|
}
|
|
891
|
-
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";
|
|
1168
|
+
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";
|
|
892
1169
|
/**
|
|
893
1170
|
* Build a tool set for the Vercel AI SDK that exposes Mercado Pago to an
|
|
894
1171
|
* agent. Pass directly to `Experimental_Agent`'s `tools` option, or merge with
|
|
@@ -954,4 +1231,4 @@ declare function verifyWebhookSignature(params: {
|
|
|
954
1231
|
secret: string;
|
|
955
1232
|
}): boolean;
|
|
956
1233
|
|
|
957
|
-
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, type CreatePaymentParams, type CreatePreapprovalParams, type CreatePreferenceParams, type CreateQrPaymentParams, type CreateRefundParams, type CurrencyId, type Customer, type CustomerCard, type FrequencyType, InMemoryStateAdapter, type InstallmentOffer, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, type ParsedWebhookEvent, type Payment, type PaymentMethod, type PaymentStatus, type PaymentsSearchResult, type Preapproval, type PreapprovalStatus, type Preference, type PreferenceItem, type QrOrder, type Refund, type SearchPaymentsParams, type SiteId, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|
|
1234
|
+
export { type AccountInfo, type AutoRecurring, type CardToken, type CreateCardTokenParams, type CreateCustomerParams, 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, MercadoPagoAccountTypeMismatchError, MercadoPagoAuthError, MercadoPagoAuthorizeForbiddenError, MercadoPagoBackUrlInvalidError, MercadoPagoClient, type MercadoPagoClientOptions, MercadoPagoError, MercadoPagoOverloadedError, MercadoPagoPaymentRejectedError, MercadoPagoRateLimitError, MercadoPagoSelfPaymentError, MercadoPagoTimeoutError, type MercadoPagoToolsOptions, 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 SiteId, type Store, type SubscriptionPayment, type SubscriptionPlan, type SubscriptionStateAdapter, type SubscriptionStateRecord, type WebhookBody, type WebhookConfig, type WebhookTopic, classifyError, mercadoPagoTools, parseWebhookEvent, verifyWebhookSignature };
|