UNPKG

@fenil265/fundly-payment-sdk

Version:

Fundly Payment SDK for seamless integration with Fundly Pay systems.

169 lines (167 loc) 5.66 kB
import { PaymentProvider } from "./context/PaymentContext"; export type { PaymentInvoice } from "./context/PaymentContext"; export { PaymentProvider }; 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; } export 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 { setAccessToken, getAccessToken } from "./authToken"; export { analyticsService, CleverTapProvider } from "./services/analytics"; export type { IAnalyticsProvider, AnalyticsConfig, PaymentEventData, PaymentLinkGeneratedEventData, PaymentQRGeneratedEventData, PaymentFailedEventData, PaymentMode, PaymentStatus, } from "./services/analytics"; /** * Partner credentials for SDK authentication */ export interface PartnerCredentials { username: string; password: string; } /** * Payment configuration options */ export interface PaymentConfig { sandbox?: boolean; partnerCredentials: PartnerCredentials; distributorIdnum: string; chemistId: string; typeOfApp: string; paymentInvoice: { invoiceId: string; paidAmount: number; }[]; payableValue: string; paymentType: string; salesmanId?: number; payerMobileNumber?: string; redirectionUrl?: string; transactionId?: string; showResultOnly?: boolean; } /** * Props for PaymentOptionPage component */ export interface PaymentOptionPageProps { config: PaymentConfig; onPaymentCollected?: (response?: Record<string, unknown>) => void; onPaymentFailed?: (response?: Record<string, unknown>) => void; } export declare function PaymentOptionPage({ config, onPaymentCollected, onPaymentFailed }: PaymentOptionPageProps): import("react/jsx-runtime").JSX.Element;