UNPKG

@fenil265/fundly-payment-sdk

Version:

Fundly Payment SDK for seamless integration with Fundly Pay systems.

133 lines 4.37 kB
/** * SDK Configuration Interface * * This configuration allows the payment SDK to work with any platform * (Flutter, React Native, Web, etc.) by providing callback functions * for platform-specific operations. */ export interface ImageFile { name: string; type: string; data: string; } export interface SDKCallbacks { /** * Called when the user wants to navigate back to home */ onNavigateHome?: () => void; /** * Called when the user wants to open the camera * Should return a Promise with the captured image data */ onOpenCamera?: () => Promise<ImageFile | null>; /** * Called when the user wants to open the gallery/file picker * Should return a Promise with the selected image data */ onOpenGallery?: () => Promise<ImageFile | null>; /** * Called when the user wants to share an image (e.g., receipt) * @param base64Data - The image data in base64 format * @param fileName - The suggested file name * @param fileType - The file type (e.g., 'png', 'jpg') * @param message - Optional text message to share with the image */ onShareImage?: (base64Data: string, fileName: string, fileType: string, message?: string) => void; /** * Called when the user wants to share an image using byte data (data URL) * This is specifically for Android WebView integration where native apps * can handle the image data URL and text together. * * @param byteUrl - The image data as data URL (e.g., 'data:image/png;base64,...') * @param receiptText - The text message to accompany the image * * Example Android WebView integration: * ```kotlin * @JavascriptInterface * fun shareByteImage(byteUrl: String, receiptText: String) { * // Android native sharing implementation * } * ``` */ onShareByteImage?: (byteUrl: string, receiptText: string) => void; /** * Called when the user wants to share a text string (e.g., payment link) * @param text - The text to share */ onShareString?: (text: string) => void; /** * Called when the SDK wants to show a toast/snackbar message * @param message - The message to display * @param type - The type of toast ('success' | 'error' | 'warning' | 'info') */ onShowToast?: (message: string, type?: 'success' | 'error' | 'warning' | 'info') => void; } declare class PaymentSDKConfig { private static instance; private callbacks; private source; private constructor(); static getInstance(): PaymentSDKConfig; /** * Initialize the SDK with platform-specific callbacks */ configure(callbacks: SDKCallbacks): void; /** * Get the configured callbacks */ getCallbacks(): SDKCallbacks; /** * Set the source/typeOfApp value */ setSource(source: string | null): void; /** * Get the source/typeOfApp value */ getSource(): string | null; /** * Navigate to home */ navigateHome(): Promise<void>; /** * Open camera to capture image */ openCamera(): Promise<ImageFile | null>; /** * Open gallery to select image */ openGallery(): Promise<ImageFile | null>; /** * Share image data */ shareImage(base64Data: string, fileName: string, fileType: string, message?: string): Promise<void>; /** * Share image using byte data (data URL) with text * This method is specifically designed for Android WebView integration * @param byteUrl - The image data as data URL (data:image/png;base64,...) * @param receiptText - The text message to accompany the image */ shareByteImage(byteUrl: string, receiptText?: string): Promise<boolean>; /** * Share text string */ shareString(text: string): Promise<void>; /** * Default file input implementation for web */ private openFileInput; /** * Default image sharing implementation for web */ private defaultShareImage; /** * Default byte image sharing implementation for web */ private defaultShareByteImage; /** * Default text sharing implementation for web */ private defaultShareText; } export declare const sdkConfig: PaymentSDKConfig; export {}; //# sourceMappingURL=sdk.config.d.ts.map