@plandalf/react
Version:
React checkout components for Plandalf Checkout — an embedded and popup checkout alternative to Stripe Checkout and SamCart, with a built-in billing portal.
91 lines (90 loc) • 2.56 kB
TypeScript
import { FC } from 'react';
export interface CheckoutItem {
lookup_key: string;
quantity: number;
}
export interface CheckoutConfig {
host?: string;
redirect?: boolean;
redirectUrl?: string;
}
export interface CheckoutHookReturn {
checkout: (checkoutItems?: CheckoutItem[]) => void;
isOpen: boolean;
items: CheckoutItem[];
Modal: FC;
close: () => void;
}
export interface CustomerInfo {
email?: string;
first_name?: string;
last_name?: string;
phone?: string;
company?: string;
address?: {
line1?: string;
line2?: string;
city?: string;
state?: string;
postal_code?: string;
country?: string;
};
}
export interface EmbedEventCallbacks {
onInit?: (checkoutId: string) => void;
onPageChange?: (checkoutId: string, pageId: string) => void;
onPaymentInit?: (checkoutId: string) => void;
onSubmit?: (checkoutId: string) => void;
onSuccess?: (data: any) => void;
onComplete?: (checkout: any) => void;
onCancel?: (data: any) => void;
onClosed?: (data: any) => void;
onLineItemChange?: (data: any) => void;
onResize?: (data: any) => void;
onError?: (error: any) => void;
}
export interface BaseEmbedProps {
offerId: string;
domain?: string;
inheritParameters?: boolean;
parameters?: Record<string, any>;
customer?: CustomerInfo;
}
export interface PopupEmbedProps extends BaseEmbedProps, EmbedEventCallbacks {
isOpen: boolean;
onClose: () => void;
width?: string;
height?: string;
size?: 'small' | 'medium' | 'large';
}
export interface StandardEmbedProps extends BaseEmbedProps, EmbedEventCallbacks {
offer: string;
dynamicResize?: boolean;
}
export interface FullScreenEmbedProps extends BaseEmbedProps, EmbedEventCallbacks {
isOpen: boolean;
onClose: () => void;
}
export interface PortalBaseProps {
domain?: string;
inheritParameters?: boolean;
parameters?: Record<string, any>;
customerToken?: string;
returnUrl?: string;
}
export interface PortalEmbedEvents {
onInit?: (data?: any) => void;
onClosed?: (data?: any) => void;
onResize?: (data?: any) => void;
onError?: (error: any) => void;
}
export interface PortalEmbedProps extends PortalBaseProps, PortalEmbedEvents {
dynamicResize?: boolean;
}
export interface PortalPopupProps extends PortalBaseProps, PortalEmbedEvents {
isOpen: boolean;
onClose: () => void;
width?: string;
height?: string;
size?: 'small' | 'medium' | 'large';
}