UNPKG

vexor

Version:

A single SDK to integrate Stripe, Paypal, Mercadopago, Talo, Square and more with the same code. Vexor makes integrations painless: simplify checkouts, subscriptions, marketplaces, connect accounts, webhooks and more. Integrate payment gateways in minutes

415 lines (402 loc) 14.1 kB
declare const vexorPay: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorPaymentBody) => any) & { mercadopago: (body: VexorPaymentBody) => any; stripe: (body: VexorPaymentBody) => any; paypal: (body: VexorPaymentBody) => any; talo: (body: VexorPaymentBody) => any; square: (body: VexorPaymentBody) => any; }; declare const vexorWebhook: (vexor: any) => ((req: Request) => any) & { mercadopago: (req: Request) => any; stripe: (req: Request) => any; paypal: (req: Request) => any; talo: (req: Request) => any; square: (req: Request) => any; }; type SupportedVexorPlatform = 'mercadopago' | 'stripe' | 'paypal' | 'talo' | 'square'; type SupportedVexorPaymentMethods = Array<'transfer' | 'crypto'>; interface VexorPaymentBody { items: Array<{ id?: string; title: string; description: string; quantity: number; unit_price: number; }>; options?: { successRedirect?: string; pendingRedirect?: string; failureRedirect?: string; paymentMethods?: SupportedVexorPaymentMethods; currency?: string; allow_promotion_codes?: boolean; }; } interface VexorPortalBody { identifier: string; returnUrl: string; } interface VexorSubscriptionBody { name: string; description?: string; interval: string; price: number; currency: string; successRedirect: string; failureRedirect?: string; customer?: { email: string; name?: string; }; free_trial_days?: number; allow_promotion_codes?: boolean; } interface VexorConnectBody { redirectUrl: string; countryCode?: string; express?: boolean; } interface VexorConnectAuthBody { url: string; } interface VexorConnectAuthRefreshBody { identifier: string; } interface VexorConnectPayBody { redirectUrl: string; seller: { identifier: string; fee?: string | number; }; items: Array<{ id?: string; title: string; description: string; quantity: number; unit_price: number; }>; currency?: string; options?: { successRedirect?: string; pendingRedirect?: string; failureRedirect?: string; }; } interface VexorConnectDashboardBody { account_identifier: string; } interface VexorConnectRefundRequest { identifier: string; seller: { identifier: string; }; } interface VexorRefundBody { identifier: string; } interface VexorRetrieveBody { identifier: string; } interface VexorPaymentResponse { message: string; payment_url: string; identifier: string; raw: any; } interface VexorSubscriptionResponse { message: string; payment_url: string; identifier: string; raw: any; } interface VexorPortalResponse { message: string; portal_url: string; raw?: any; identifier: string; } interface VexorConnectDashboardResponse { message: string; dashboard_url: string; identifier: string; raw: any; } interface VexorConnectResponse { message: string; connect_url?: string; payment_url?: string; dashboard_url?: string; identifier: string; raw: any; } interface VexorRefundResponse { message: string; raw: any; identifier: string; error?: any; } interface VexorRetrieveResponse { message: string; identifier: string; raw: any; } declare const vexorSubscribe: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorSubscriptionBody) => any) & { mercadopago: (body: VexorSubscriptionBody) => any; stripe: (body: VexorSubscriptionBody) => any; paypal: (body: VexorSubscriptionBody) => any; }; declare const vexorPortal: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorPortalBody) => any) & { mercadopago: (body: VexorPortalBody) => any; stripe: (body: VexorPortalBody) => any; paypal: (body: VexorPortalBody) => any; }; declare const vexorConnect: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorConnectBody) => any) & { mercadopago: (body: VexorConnectBody) => any; stripe: (body: VexorConnectBody) => any; auth: (body: VexorConnectAuthBody) => any; refresh: (body: VexorConnectAuthRefreshBody) => any; pay: ((params: { platform: SupportedVexorPlatform; } & VexorConnectPayBody) => any) & { mercadopago: (body: VexorConnectPayBody) => any; stripe: (body: VexorConnectPayBody) => any; }; dashboard: (body: VexorConnectDashboardBody) => any; refund: ((params: { platform: SupportedVexorPlatform; } & VexorConnectRefundRequest) => any) & { mercadopago: (body: VexorConnectRefundRequest) => any; stripe: (body: VexorConnectRefundRequest) => any; }; }; declare const vexorRefund: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorRefundBody) => any) & { mercadopago: (body: VexorRefundBody) => any; stripe: (body: VexorRefundBody) => any; paypal: (body: VexorRefundBody) => any; }; interface OpenSourceConfig { platforms: { mercadopago?: { public_key: string; access_token: string; client_id?: string; client_secret?: string; webhook_secret?: string; webhooks_url?: string; sandbox?: boolean; }; stripe?: { public_key: string; secret_key: string; webhook_secrets?: string[]; sandbox?: boolean; }; paypal?: { client_id: string; secret_key: string; webhook_id?: string; sandbox?: boolean; }; talo?: { user_id: string; client_id: string; client_secret: string; webhooks_url?: string; sandbox?: boolean; }; square?: { access_token: string; application_id: string; webhooks_url?: string; webhook_signature_key?: string; sandbox?: boolean; }; }; } interface VexorConfig { publishableKey?: string; projectId?: string; secretKey?: string; openSource?: OpenSourceConfig; } declare const vexorRetrieve: (vexor: any) => ((params: { platform: SupportedVexorPlatform; } & VexorRetrieveBody) => any) & { mercadopago: (body: VexorRetrieveBody) => any; stripe: (body: VexorRetrieveBody) => any; paypal: (body: VexorRetrieveBody) => any; talo: (body: VexorRetrieveBody) => any; square: (body: VexorRetrieveBody) => any; }; declare class Vexor { private static instance; private publishableKey?; private secretKey?; private projectId?; private apiUrl; openSource?: OpenSourceConfig; custom: (url: string) => Vexor; constructor(params: VexorConfig); static fromEnv(): Vexor & { custom: (url: string) => Vexor; }; static init(params: VexorConfig): Vexor & { custom: (url: string) => Vexor; }; /** * Pay method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago payments. * @property {Function} stripe - Shortcut for Stripe payments. * @property {Function} paypal - Shortcut for PayPal payments. * @property {Function} talo - Shortcut for Talo payments. * @example * // Generic usage * vexor.pay({ platform: 'mercadopago', items: [...] }); * * // Platform-specific shortcut * vexor.pay.mercadopago({ items: [...] }); * * @description * Facilitates simple checkout scenarios for various payment platforms. */ pay: ReturnType<typeof vexorPay>; createCheckout(platform: SupportedVexorPlatform, body: VexorPaymentBody): Promise<VexorPaymentResponse>; /** * Webhook method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago webhooks. * @property {Function} stripe - Shortcut for Stripe webhooks. * @property {Function} paypal - Shortcut for PayPal webhooks. * @property {Function} talo - Shortcut for Talo webhooks. * @property {Function} square - Shortcut for Square webhooks. * @example * // Generic usage * vexor.webhook(req); * * // Platform-specific shortcut * vexor.webhook.mercadopago(req); * vexor.webhook.talo(req); * vexor.webhook.paypal(req); * vexor.webhook.stripe(req); * vexor.webhook.square(req); * @description * Facilitates webhook handling for various payment platforms. */ webhook: ReturnType<typeof vexorWebhook>; handleWebhook(req: Request): Promise<any>; /** * Subscription method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago subscriptions. * @property {Function} stripe - Shortcut for Stripe subscriptions. * @property {Function} paypal - Shortcut for PayPal subscriptions. * * @example * // Generic usage * vexor.subscribe({ platform: 'mercadopago', body }); * * // Platform-specific shortcut * vexor.subscribe.mercadopago({ body }); * * @description * Facilitates simple subscription scenarios for various payment platforms. */ subscribe: ReturnType<typeof vexorSubscribe>; createSubscription(platform: SupportedVexorPlatform, body: VexorSubscriptionBody): Promise<VexorSubscriptionResponse>; /** * Billing portal method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago portals. * @property {Function} stripe - Shortcut for Stripe portals. * @property {Function} paypal - Shortcut for PayPal portals. * * @example * // Generic usage * vexor.portal({ platform: 'mercadopago', body }); * * // Platform-specific shortcut * vexor.portal.mercadopago({ body }); * * @description * Facilitates creation of billing portals for various payment platforms. */ portal: ReturnType<typeof vexorPortal>; createPortal(platform: SupportedVexorPlatform, body: VexorPortalBody): Promise<VexorPortalResponse>; /** * Connect method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago connect. * @property {Function} stripe - Shortcut for Stripe connect. * @property {Function} auth - Shortcut for MercadoPago auth. * @property {Object} pay - Object with payment methods for connected accounts. * @property {Function} dashboard - Shortcut for Stripe dashboard link. * @property {Function} refund - Shortcut for Stripe refund. * * @example * // Generic usage * vexor.connect({ platform: 'stripe', redirectUrl: 'www.example.com', countryCode: 'US', express: true }); * * // Platform-specific shortcut * vexor.connect.mercadopago({ redirectUrl: 'www.example.com', countryCode: 'AR' }); * * @description * Facilitates account connection for various payment platforms. */ connect: ReturnType<typeof vexorConnect>; createConnect(platform: SupportedVexorPlatform, body: VexorConnectBody): Promise<VexorConnectResponse>; createConnectAuth(platform: SupportedVexorPlatform, body: VexorConnectAuthBody): Promise<VexorConnectResponse>; createConnectPay(platform: SupportedVexorPlatform, body: VexorConnectPayBody): Promise<VexorConnectResponse>; createConnectDashboard(platform: SupportedVexorPlatform, body: VexorConnectDashboardBody): Promise<VexorConnectResponse>; createConnectAuthRefresh(body: VexorConnectAuthRefreshBody): Promise<VexorConnectResponse>; createConnectRefund(platform: SupportedVexorPlatform, body: VexorConnectRefundRequest): Promise<VexorConnectResponse>; /** * Refund method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago refunds. * @property {Function} stripe - Shortcut for Stripe refunds. * @property {Function} paypal - Shortcut for PayPal refunds. * * @example * // Generic usage * vexor.refund({ platform: 'mercadopago', paymentId: 'payment_123' }); * * // Platform-specific shortcut * vexor.refund.mercadopago({ paymentId: 'payment_123' }); * * @description * Facilitates refund processing for various payment platforms. */ refund: ReturnType<typeof vexorRefund>; createRefund(platform: SupportedVexorPlatform, body: VexorRefundBody): Promise<VexorRefundResponse>; /** * Refund method with platform-specific shortcuts. * @type {Object} * @property {Function} mercadopago - Shortcut for MercadoPago refunds. * @property {Function} stripe - Shortcut for Stripe refunds. * @property {Function} paypal - Shortcut for PayPal refunds. * * @example * // Generic usage * vexor.refund({ platform: 'mercadopago', paymentId: 'payment_123' }); * * // Platform-specific shortcut * vexor.refund.mercadopago({ paymentId: 'payment_123' }); * * @description * Facilitates refund processing for various payment platforms. */ retrieve: ReturnType<typeof vexorRetrieve>; createRetrieve(platform: SupportedVexorPlatform, body: VexorRetrieveBody): Promise<VexorRetrieveResponse>; private setApiUrl; } export { type SupportedVexorPlatform, Vexor, type VexorConfig, type VexorConnectAuthBody, type VexorConnectAuthRefreshBody, type VexorConnectBody, type VexorConnectDashboardBody, type VexorConnectDashboardResponse, type VexorConnectPayBody, type VexorConnectRefundRequest, type VexorConnectResponse, type VexorPaymentBody, type VexorPaymentResponse, type VexorPortalBody, type VexorPortalResponse, type VexorRefundBody, type VexorRefundResponse, type VexorSubscriptionBody, type VexorSubscriptionResponse };