UNPKG

vue3-stripe-kit

Version:

Complete Vue 3 Stripe integration with Payment Elements, Checkout, Subscriptions. TypeScript support, composables, components, modular architecture for payments, billing, and e-commerce

484 lines (443 loc) 15.9 kB
import { ComponentOptionsMixin } from 'vue'; import { ComponentProvideOptions } from 'vue'; import { DefineComponent } from 'vue'; import { ExtractPropTypes } from 'vue'; import { PropType } from 'vue'; import { PublicProps } from 'vue'; import { Ref } from 'vue'; import { StripeElements } from '@stripe/stripe-js'; declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, { elementId: string; autoSetup: boolean; showSubmitButton: boolean; submitButtonText: string; }>>, { setupElements: (options?: ElementsOptions) => Promise<void>; mountPaymentElement: (elementId: string, options?: PaymentElementOptions) => Promise<void>; submitPayment: () => Promise<any>; paymentElement: Ref<any, any>; elements: Ref<StripeElements | null, StripeElements | null>; loading: Ref<boolean, boolean>; error: Ref<StripeError | null, StripeError | null>; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, { change: (event: any) => void; ready: (elementId: string) => void; error: (error: any) => void; mounted: (element: any) => void; "payment-success": (result: any) => void; "payment-error": (error: any) => void; }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, { elementId: string; autoSetup: boolean; showSubmitButton: boolean; submitButtonText: string; }>>> & Readonly<{ onChange?: ((event: any) => any) | undefined; onReady?: ((elementId: string) => any) | undefined; onError?: ((error: any) => any) | undefined; onMounted?: ((element: any) => any) | undefined; "onPayment-success"?: ((result: any) => any) | undefined; "onPayment-error"?: ((error: any) => any) | undefined; }>, { elementId: string; autoSetup: boolean; showSubmitButton: boolean; submitButtonText: string; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; declare const __VLS_component_2: DefineComponent<ExtractPropTypes<__VLS_WithDefaults_2<__VLS_TypePropsToRuntimeProps_2<Props_2>, { elementId: string; autoSetup: boolean; showFallback: boolean; }>>, { setupElements: (options?: ElementsOptions) => Promise<void>; mountExpressCheckout: (elementId: string, options?: ExpressCheckoutElementOptions) => Promise<void>; expressCheckoutElement: Ref<any, any>; elements: Ref<StripeElements | null, StripeElements | null>; loading: Ref<boolean, boolean>; error: Ref<StripeError | null, StripeError | null>; showElement: Ref<boolean, boolean>; availableMethods: Ref<string[], string[]>; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, { ready: (elementId: string, availableMethods: string[]) => void; click: (event: any) => void; error: (error: any) => void; cancel: (event: any) => void; mounted: (element: any) => void; }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_2<__VLS_TypePropsToRuntimeProps_2<Props_2>, { elementId: string; autoSetup: boolean; showFallback: boolean; }>>> & Readonly<{ onReady?: ((elementId: string, availableMethods: string[]) => any) | undefined; onClick?: ((event: any) => any) | undefined; onError?: ((error: any) => any) | undefined; onCancel?: ((event: any) => any) | undefined; onMounted?: ((element: any) => any) | undefined; }>, { elementId: string; autoSetup: boolean; showFallback: boolean; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T; declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T; declare type __VLS_NonUndefinedable_3<T> = T extends undefined ? never : T; declare type __VLS_NonUndefinedable_4<T> = T extends undefined ? never : T; declare type __VLS_Prettify<T> = { [K in keyof T]: T[K]; } & {}; declare type __VLS_Prettify_2<T> = { [K in keyof T]: T[K]; } & {}; declare type __VLS_Prettify_3<T> = { [K in keyof T]: T[K]; } & {}; declare type __VLS_Prettify_4<T> = { [K in keyof T]: T[K]; } & {}; declare function __VLS_template(): { "submit-button"?(_: {}): any; loading?(_: {}): any; }; declare function __VLS_template_2(): { fallback?(_: {}): any; }; declare type __VLS_TypePropsToRuntimeProps<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? { type: PropType<__VLS_NonUndefinedable<T[K]>>; } : { type: PropType<T[K]>; required: true; }; }; declare type __VLS_TypePropsToRuntimeProps_2<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? { type: PropType<__VLS_NonUndefinedable_2<T[K]>>; } : { type: PropType<T[K]>; required: true; }; }; declare type __VLS_TypePropsToRuntimeProps_3<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? { type: PropType<__VLS_NonUndefinedable_3<T[K]>>; } : { type: PropType<T[K]>; required: true; }; }; declare type __VLS_TypePropsToRuntimeProps_4<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? { type: PropType<__VLS_NonUndefinedable_4<T[K]>>; } : { type: PropType<T[K]>; required: true; }; }; declare type __VLS_WithDefaults<P, D> = { [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & { default: D[K]; }> : P[K]; }; declare type __VLS_WithDefaults_2<P, D> = { [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify_2<P[K] & { default: D[K]; }> : P[K]; }; declare type __VLS_WithDefaults_3<P, D> = { [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify_3<P[K] & { default: D[K]; }> : P[K]; }; declare type __VLS_WithDefaults_4<P, D> = { [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify_4<P[K] & { default: D[K]; }> : P[K]; }; declare type __VLS_WithTemplateSlots<T, S> = T & { new (): { $slots: S; }; }; declare type __VLS_WithTemplateSlots_2<T, S> = T & { new (): { $slots: S; }; }; declare interface ElementsAppearance { theme?: 'stripe' | 'night' | 'flat' | 'none'; variables?: ElementsTheme; rules?: Record<string, any>; } export declare interface ElementsOptions { fonts?: Array<{ family?: string; src?: string; style?: string; weight?: string; }>; locale?: string; appearance?: ElementsAppearance; clientSecret?: string; mode?: 'payment' | 'setup' | 'subscription'; currency?: string; amount?: number; setupFutureUsage?: 'on_session' | 'off_session'; paymentMethodCreation?: 'manual' | 'automatic'; paymentMethodOptions?: Record<string, any>; paymentMethodTypes?: string[]; wallets?: { applePay?: 'auto' | 'always' | 'never'; googlePay?: 'auto' | 'always' | 'never'; link?: 'auto' | 'always' | 'never'; }; } declare interface ElementsTheme { colorPrimary?: string; colorBackground?: string; colorText?: string; colorDanger?: string; fontFamily?: string; fontSizeBase?: string; borderRadius?: string; fontSmoothing?: 'auto' | 'never' | 'always'; } export declare interface ExpressCheckoutElementOptions { paymentMethods?: { applePay?: 'auto' | 'always' | 'never'; googlePay?: 'auto' | 'always' | 'never'; link?: 'auto' | 'always' | 'never'; paypal?: 'auto' | 'always' | 'never'; }; layout?: { maxColumns?: number; maxRows?: number; overflow?: 'auto' | 'hidden'; }; buttonTheme?: { applePay?: 'black' | 'white' | 'white-outline'; googlePay?: 'black' | 'white' | 'white-outline'; }; buttonType?: { applePay?: 'plain' | 'buy' | 'set-up' | 'donate' | 'check-out' | 'book' | 'subscribe'; googlePay?: 'book' | 'buy' | 'checkout' | 'donate' | 'order' | 'pay' | 'plain' | 'subscribe'; }; buttonHeight?: string; } export declare interface PaymentElementOptions { layout?: 'tabs' | 'accordion' | 'auto'; defaultValues?: { billingDetails?: { name?: string; email?: string; phone?: string; address?: { line1?: string; line2?: string; city?: string; state?: string; postal_code?: string; country?: string; }; }; }; business?: { name?: string; }; paymentMethodOrder?: string[]; fields?: { billingDetails?: 'auto' | 'never' | { name?: 'auto' | 'never'; email?: 'auto' | 'never'; phone?: 'auto' | 'never'; address?: 'auto' | 'never' | { line1?: 'auto' | 'never'; line2?: 'auto' | 'never'; city?: 'auto' | 'never'; state?: 'auto' | 'never'; postal_code?: 'auto' | 'never'; country?: 'auto' | 'never'; }; }; }; terms?: { card?: 'auto' | 'always' | 'never'; ideal?: 'auto' | 'always' | 'never'; sepaDebit?: 'auto' | 'always' | 'never'; sofort?: 'auto' | 'always' | 'never'; bancontact?: 'auto' | 'always' | 'never'; }; wallets?: { applePay?: 'auto' | 'always' | 'never'; googlePay?: 'auto' | 'always' | 'never'; }; } declare interface Props { clientSecret: string; elementId?: string; elementsOptions?: ElementsOptions; paymentElementOptions?: PaymentElementOptions; autoSetup?: boolean; showSubmitButton?: boolean; submitButtonText?: string; } declare interface Props_2 { clientSecret: string; elementId?: string; elementsOptions?: ElementsOptions; expressCheckoutOptions?: ExpressCheckoutElementOptions; autoSetup?: boolean; showFallback?: boolean; } declare interface Props_3 { subscriptionId?: string; customerId?: string; title?: string; config?: Partial<SubscriptionConfig>; availablePlans?: any[]; showChangePlan?: boolean; showUpdatePayment?: boolean; showPauseOption?: boolean; allowTrialExtension?: boolean; autoRefresh?: boolean; refreshInterval?: number; } declare interface Props_4 { config?: any; maxEvents?: number; autoStart?: boolean; showTesting?: boolean; } declare interface RequestConfig { apiEndpoint?: string; timeout?: number; headers?: Record<string, string>; retries?: number; } export declare interface StripeError { type: string; code?: string; message: string; param?: string; } export declare const StripeExpressCheckout: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, ReturnType<typeof __VLS_template_2>>; export declare const StripePaymentElement: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>; export declare const StripeSubscriptionManager: DefineComponent<ExtractPropTypes<__VLS_WithDefaults_3<__VLS_TypePropsToRuntimeProps_3<Props_3>, { title: string; availablePlans: () => never[]; showChangePlan: boolean; showUpdatePayment: boolean; showPauseOption: boolean; allowTrialExtension: boolean; autoRefresh: boolean; refreshInterval: number; }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, { error: (error: any) => void; subscriptionUpdated: (subscription: SubscriptionStatus) => void; subscriptionCanceled: (subscription: SubscriptionStatus) => void; planChanged: (subscription: SubscriptionStatus, oldPlan: string, newPlan: string) => void; trialExtended: (subscription: SubscriptionStatus, additionalDays: number) => void; }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_3<__VLS_TypePropsToRuntimeProps_3<Props_3>, { title: string; availablePlans: () => never[]; showChangePlan: boolean; showUpdatePayment: boolean; showPauseOption: boolean; allowTrialExtension: boolean; autoRefresh: boolean; refreshInterval: number; }>>> & Readonly<{ onError?: ((error: any) => any) | undefined; onSubscriptionUpdated?: ((subscription: SubscriptionStatus) => any) | undefined; onSubscriptionCanceled?: ((subscription: SubscriptionStatus) => any) | undefined; onPlanChanged?: ((subscription: SubscriptionStatus, oldPlan: string, newPlan: string) => any) | undefined; onTrialExtended?: ((subscription: SubscriptionStatus, additionalDays: number) => any) | undefined; }>, { allowTrialExtension: boolean; title: string; availablePlans: any[]; showChangePlan: boolean; showUpdatePayment: boolean; showPauseOption: boolean; autoRefresh: boolean; refreshInterval: number; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export declare const StripeWebhookMonitor: DefineComponent<ExtractPropTypes<__VLS_WithDefaults_4<__VLS_TypePropsToRuntimeProps_4<Props_4>, { maxEvents: number; autoStart: boolean; showTesting: boolean; }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_4<__VLS_TypePropsToRuntimeProps_4<Props_4>, { maxEvents: number; autoStart: boolean; showTesting: boolean; }>>> & Readonly<{}>, { maxEvents: number; autoStart: boolean; showTesting: boolean; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; declare interface SubscriptionConfig extends RequestConfig { createEndpoint?: string; updateEndpoint?: string; cancelEndpoint?: string; retrieveEndpoint?: string; listEndpoint?: string; pauseEndpoint?: string; resumeEndpoint?: string; createCustomerEndpoint?: string; updateCustomerEndpoint?: string; retrieveCustomerEndpoint?: string; createPriceEndpoint?: string; createProductEndpoint?: string; listPricesEndpoint?: string; listProductsEndpoint?: string; retrievePriceEndpoint?: string; retrieveProductEndpoint?: string; retrieveUpcomingInvoiceEndpoint?: string; retrieveInvoiceEndpoint?: string; payInvoiceEndpoint?: string; listInvoicesEndpoint?: string; attachPaymentMethodEndpoint?: string; detachPaymentMethodEndpoint?: string; listPaymentMethodsEndpoint?: string; retrievePaymentMethodEndpoint?: string; defaultPaymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete'; defaultCollectionMethod?: 'charge_automatically' | 'send_invoice'; defaultProrationBehavior?: 'create_prorations' | 'none' | 'always_invoice'; defaultTrialDays?: number; allowTrialExtension?: boolean; cancelAtPeriodEnd?: boolean; cancellationReason?: string; webhookEndpointSecret?: string; } declare interface SubscriptionStatus { id: string; status: 'incomplete' | 'incomplete_expired' | 'trialing' | 'active' | 'past_due' | 'canceled' | 'unpaid'; customer: string; current_period_start: number; current_period_end: number; trial_start?: number; trial_end?: number; canceled_at?: number; cancel_at?: number; cancel_at_period_end: boolean; items: { data: Array<{ id: string; price: { id: string; nickname?: string; unit_amount: number; currency: string; recurring: { interval: string; interval_count: number; }; }; quantity: number; }>; }; latest_invoice?: string; pending_setup_intent?: string; default_payment_method?: string; metadata: Record<string, string>; } export { }