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
173 lines (152 loc) • 6.38 kB
TypeScript
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';
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
declare type __VLS_Prettify<T> = {
[K in keyof T]: T[K];
} & {};
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_WithDefaults<P, D> = {
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
default: D[K];
}> : P[K];
};
export declare function getGlobalConfig(): StripeConfig | null;
declare interface Props {
config?: any;
maxEvents?: number;
autoStart?: boolean;
showTesting?: boolean;
}
declare interface RequestConfig {
apiEndpoint?: string;
timeout?: number;
headers?: Record<string, string>;
retries?: number;
}
export declare function setGlobalConfig(config: StripeConfig): void;
declare interface StripeConfig {
publishableKey: string;
apiVersion?: string;
locale?: string;
stripeAccount?: string;
apiBaseUrl?: string;
checkoutEndpoint?: string;
requestTimeout?: number;
headers?: Record<string, string>;
}
export declare interface StripeError {
type: string;
code?: string;
message: string;
param?: string;
}
export declare const StripeWebhookMonitor: DefineComponent<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
maxEvents: number;
autoStart: boolean;
showTesting: boolean;
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
maxEvents: number;
autoStart: boolean;
showTesting: boolean;
}>>> & Readonly<{}>, {
maxEvents: number;
autoStart: boolean;
showTesting: boolean;
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
export declare function useWebhooks(config?: Partial<WebhookConfig>): UseWebhooksReturn;
export declare interface UseWebhooksReturn {
loading: Ref<boolean>;
error: Ref<StripeError | null>;
events: Ref<WebhookEvent[]>;
stats: Ref<WebhookStats>;
isMonitoring: Ref<boolean>;
createWebhookEndpoint: (url: string, enabledEvents: WebhookEventType[], config?: Partial<WebhookConfig>) => Promise<WebhookEndpoint>;
updateWebhookEndpoint: (endpointId: string, updates: Partial<WebhookEndpoint>, config?: Partial<WebhookConfig>) => Promise<WebhookEndpoint>;
deleteWebhookEndpoint: (endpointId: string, config?: Partial<WebhookConfig>) => Promise<void>;
listWebhookEndpoints: (config?: Partial<WebhookConfig>) => Promise<WebhookEndpoint[]>;
startMonitoring: (config?: Partial<WebhookConfig>) => void;
stopMonitoring: () => void;
fetchEvents: (limit?: number, config?: Partial<WebhookConfig>) => Promise<WebhookEvent[]>;
fetchEvent: (eventId: string, config?: Partial<WebhookConfig>) => Promise<WebhookEvent>;
resendEvent: (eventId: string, endpointId: string, config?: Partial<WebhookConfig>) => Promise<void>;
registerEventHandler: (handler: WebhookEventHandler) => void;
unregisterEventHandler: (eventType: WebhookEventType) => void;
clearEventHandlers: () => void;
simulateEvent: (eventType: WebhookEventType, testData?: any) => Promise<WebhookEvent>;
testWebhookEndpoint: (endpointId: string, eventType: WebhookEventType) => Promise<boolean>;
validateWebhookSignature: (payload: string, signature: string, secret: string) => boolean;
clearEvents: () => void;
exportEvents: (format: 'json' | 'csv') => string;
filterEvents: (filter: {
type?: WebhookEventType;
dateFrom?: Date;
dateTo?: Date;
}) => WebhookEvent[];
}
export declare interface WebhookConfig extends RequestConfig {
createWebhookEndpoint?: string;
updateWebhookEndpoint?: string;
deleteWebhookEndpoint?: string;
listWebhookEndpoint?: string;
retrieveWebhookEndpoint?: string;
listEventsEndpoint?: string;
retrieveEventEndpoint?: string;
resendEventEndpoint?: string;
webhookSecret?: string;
enabledEvents?: WebhookEventType[];
webhookUrl?: string;
enableRealTimeMonitoring?: boolean;
pollingInterval?: number;
maxEvents?: number;
}
export declare interface WebhookEndpoint {
id: string;
url: string;
enabled_events: WebhookEventType[];
status: 'enabled' | 'disabled';
description?: string;
metadata?: Record<string, string>;
created: number;
}
export declare interface WebhookEvent {
id: string;
object: 'event';
type: WebhookEventType;
created: number;
data: {
object: any;
previous_attributes?: Record<string, any>;
};
livemode: boolean;
pending_webhooks: number;
request?: {
id: string;
idempotency_key?: string;
};
}
export declare interface WebhookEventHandler {
eventType: WebhookEventType;
handler: (event: WebhookEvent) => void | Promise<void>;
description?: string;
}
export declare type WebhookEventType = 'customer.created' | 'customer.updated' | 'customer.deleted' | 'customer.subscription.created' | 'customer.subscription.updated' | 'customer.subscription.deleted' | 'customer.subscription.trial_will_end' | 'customer.subscription.paused' | 'customer.subscription.resumed' | 'invoice.created' | 'invoice.finalized' | 'invoice.payment_succeeded' | 'invoice.payment_failed' | 'invoice.payment_action_required' | 'payment_intent.created' | 'payment_intent.succeeded' | 'payment_intent.payment_failed' | 'payment_method.attached' | 'payment_method.detached' | 'checkout.session.completed' | 'checkout.session.expired' | 'setup_intent.created' | 'setup_intent.succeeded';
export declare interface WebhookStats {
totalEvents: number;
successfulEvents: number;
failedEvents: number;
lastEventTime?: number;
eventsByType: Record<WebhookEventType, number>;
}
export { }