@inflow_pay/sdk 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.d.ts CHANGED
@@ -1,11 +1,327 @@
1
- declare interface PaymentConfig {
1
+ declare interface ButtonBaseStyles {
2
+ backgroundColor?: string;
3
+ textColor?: string;
4
+ borderRadius?: string;
5
+ borderColor?: string;
6
+ borderEnabled?: boolean;
7
+ fontSize?: string;
8
+ fontWeight?: FontWeight;
9
+ opacity?: Opacity;
10
+ }
11
+
12
+ declare interface ButtonStyles extends ButtonBaseStyles {
13
+ hover?: ButtonBaseStyles;
14
+ disabled?: ButtonBaseStyles;
15
+ loaderColor?: string;
16
+ }
17
+
18
+ export declare class CardElement {
19
+ private sdk;
20
+ private container;
21
+ private mounted;
22
+ constructor(config: InternalSDKConfig, options: CardElementOptions);
23
+ /**
24
+ * Mount the CardElement to the DOM
25
+ * This will create and display the iframe
26
+ */
27
+ mount(): void;
28
+ /**
29
+ * Destroy the CardElement and cleanup
30
+ */
31
+ destroy(): void;
32
+ }
33
+
34
+ export declare interface CardElementOptions {
35
+ /** Container element or CSS selector where the iframe will be mounted */
36
+ container: string | HTMLElement;
37
+ /** Payment ID for this transaction */
38
+ paymentId: string;
39
+ /** Callback when payment completes */
40
+ onComplete?: (result: {
41
+ status: string;
42
+ data?: any;
43
+ error?: any;
44
+ }) => void;
45
+ /** Callback when payment fails */
46
+ onError?: (error: any) => void;
47
+ /** Callback when user closes the payment */
48
+ onClose?: () => void;
49
+ /** Custom styling for the card element */
50
+ style?: CSSProperties;
51
+ /** Custom button text (default: "Complete Payment") */
52
+ buttonText?: string;
53
+ /** Custom placeholder text for inputs */
54
+ placeholders?: {
55
+ cardNumber?: string;
56
+ expiry?: string;
57
+ cvc?: string;
58
+ };
59
+ }
60
+
61
+ export declare interface CardElementProps {
62
+ paymentId: string;
63
+ container?: string | HTMLElement;
64
+ onComplete?: (result: {
65
+ status: string;
66
+ data?: any;
67
+ error?: any;
68
+ }) => void;
69
+ onError?: (error: any) => void;
70
+ onClose?: () => void;
71
+ onReady?: () => void;
72
+ onChange?: (state: {
73
+ complete: boolean;
74
+ }) => void;
75
+ buttonText?: string;
76
+ buttonStyle?: any;
77
+ style?: any;
78
+ placeholders?: {
79
+ cardNumber?: string;
80
+ expiry?: string;
81
+ cvc?: string;
82
+ };
83
+ }
84
+
85
+ export declare type CardElementState = {
86
+ complete: boolean;
87
+ };
88
+
89
+ declare interface CSSProperties {
90
+ fontFamily?: FontFamily;
91
+ fillParent?: boolean;
92
+ inputContainer?: InputContainerStyles;
93
+ input?: InputStyles;
94
+ button?: ButtonStyles;
95
+ disclaimerColor?: string;
96
+ fieldErrorColor?: string;
97
+ generalError?: GeneralMessageStyles;
98
+ generalSuccess?: GeneralMessageStyles;
99
+ light?: ThemeStyles;
100
+ dark?: ThemeStyles;
101
+ }
102
+
103
+ /**
104
+ * Type definitions for SDK v2
105
+ */
106
+ declare type FontFamily = 'DM Sans' | 'Inter' | 'Poppins' | 'Nunito' | 'Work Sans' | 'Manrope' | 'Rubik' | 'Karla' | 'Figtree' | 'Outfit' | 'Space Grotesk' | 'Urbanist';
107
+
108
+ declare type FontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 'normal' | 'bold' | 'lighter' | 'bolder';
109
+
110
+ declare interface GeneralMessageStyles {
111
+ textColor?: string;
112
+ backgroundColor?: string;
113
+ borderEnabled?: boolean;
114
+ borderRadius?: string;
115
+ borderColor?: string;
116
+ }
117
+
118
+ export declare interface IframeMessage {
119
+ type: 'sdkData' | 'success' | 'error' | 'close' | '3ds-required' | '3ds-result' | 'iframe-ready';
120
+ data?: any;
121
+ config?: PaymentConfig;
122
+ threeDsSessionUrl?: string;
123
+ paymentId?: string;
124
+ success?: boolean;
125
+ }
126
+
127
+ /**
128
+ * InflowPayProvider - Global SDK configuration
129
+ *
130
+ * Similar to React's InflowPayProvider but for vanilla JS
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const provider = new InflowPayProvider({
135
+ * config: { apiKey: 'inflow_pub_xxx' }
136
+ * });
137
+ *
138
+ * const cardElement = provider.createCardElement({
139
+ * paymentId: 'pay_xxx',
140
+ * onComplete: (result) => {
141
+ * if (result.status === 'CHECKOUT_SUCCESS') {
142
+ * window.location.href = '/success';
143
+ * }
144
+ * }
145
+ * });
146
+ *
147
+ * cardElement.mount();
148
+ * ```
149
+ */
150
+ export declare class InflowPayProvider {
151
+ private sdk;
152
+ constructor(options: {
153
+ config: InflowPayProviderConfig;
154
+ });
155
+ /**
156
+ * Create a CardElement (similar to React's <CardElement />)
157
+ *
158
+ * @param props - CardElement props (same as React SDK)
159
+ * @returns CardElement instance
160
+ */
161
+ createCardElement(props: CardElementProps): CardElement;
162
+ /**
163
+ * Get the underlying PaymentSDK instance
164
+ */
165
+ getSDK(): PaymentSDK;
166
+ }
167
+
168
+ export declare interface InflowPayProviderConfig {
169
+ apiKey: string;
170
+ iframeUrl?: string;
171
+ timeout?: number;
172
+ /** Enable debug logging (default: false, only allowed in local/dev environments) */
173
+ debug?: boolean;
174
+ }
175
+
176
+ declare interface InputContainerStyles {
177
+ backgroundColor?: string;
178
+ borderColor?: string;
179
+ borderEnabled?: boolean;
180
+ borderRadius?: string;
181
+ }
182
+
183
+ declare interface InputStyles {
184
+ backgroundColor?: string;
185
+ borderColor?: string;
186
+ borderEnabled?: boolean;
187
+ borderRadius?: string;
188
+ textColor?: string;
189
+ placeholderColor?: string;
190
+ }
191
+
192
+ declare interface InternalSDKConfig {
193
+ apiKey: string;
194
+ iframeUrl: string;
195
+ timeout: number;
196
+ debug: boolean;
197
+ }
198
+
199
+ declare type Opacity = number | string;
200
+
201
+ export declare interface PaymentConfig {
2
202
  name?: string;
3
203
  amount?: number;
4
204
  currency?: string;
5
205
  paymentId?: string;
206
+ /** Custom styling for the card element */
207
+ style?: CSSProperties;
208
+ /** Custom button text (default: "Complete Payment") */
209
+ buttonText?: string;
210
+ /** Custom placeholder text for inputs */
211
+ placeholders?: {
212
+ cardNumber?: string;
213
+ expiry?: string;
214
+ cvc?: string;
215
+ };
6
216
  [key: string]: any;
7
217
  }
8
218
 
219
+ export declare type PaymentError = {
220
+ code: string;
221
+ message: string;
222
+ retryable: boolean;
223
+ };
224
+
225
+ export declare type PaymentResult = {
226
+ status: string;
227
+ data?: any;
228
+ error?: {
229
+ code: string;
230
+ message: string;
231
+ retryable: boolean;
232
+ };
233
+ };
234
+
235
+ export declare class PaymentSDK {
236
+ private config;
237
+ /**
238
+ * Initialize the InflowPay Payment SDK
239
+ *
240
+ * @param config - SDK configuration
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * const sdk = new PaymentSDK({
245
+ * apiKey: 'inflow_pub_local_xxx'
246
+ * });
247
+ * ```
248
+ */
249
+ constructor(config: PaymentSDKConfig);
250
+ /**
251
+ * Create a CardElement for iframe-based payment UI
252
+ *
253
+ * @param options - CardElement configuration
254
+ * @returns CardElement instance
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * const cardElement = sdk.createCardElement({
259
+ * container: '#card-container',
260
+ * paymentId: 'pay_123',
261
+ * onComplete: (result) => {
262
+ * if (result.status === 'CHECKOUT_SUCCESS') {
263
+ * window.location.href = '/success';
264
+ * }
265
+ * }
266
+ * });
267
+ *
268
+ * cardElement.mount();
269
+ * ```
270
+ */
271
+ createCardElement(options: {
272
+ container: string | HTMLElement;
273
+ paymentId: string;
274
+ style?: CSSProperties;
275
+ buttonText?: string;
276
+ placeholders?: {
277
+ cardNumber?: string;
278
+ expiry?: string;
279
+ cvc?: string;
280
+ };
281
+ onComplete?: (result: {
282
+ status: string;
283
+ data?: any;
284
+ error?: any;
285
+ }) => void;
286
+ onError?: (error: any) => void;
287
+ onClose?: () => void;
288
+ }): CardElement;
289
+ /**
290
+ * Get the iframe URL being used
291
+ */
292
+ getIframeUrl(): string;
293
+ /**
294
+ * Get the API key
295
+ */
296
+ getApiKey(): string;
297
+ /**
298
+ * Auto-detect environment from API key
299
+ */
300
+ private getEnvironmentFromApiKey;
301
+ }
302
+
303
+ export declare interface PaymentSDKConfig {
304
+ /** Public API key */
305
+ apiKey: string;
306
+ /** Backend API URL (optional, auto-detected from API key) */
307
+ iframeUrl?: string;
308
+ /** Request timeout in milliseconds (default: 30000) */
309
+ timeout?: number;
310
+ /** Enable debug logging (default: false, only allowed in local/dev environments) */
311
+ debug?: boolean;
312
+ }
313
+
314
+ export declare enum PaymentStatus {
315
+ INITIATION = "INITIATION",
316
+ CHECKOUT_PENDING = "CHECKOUT_PENDING",
317
+ CHECKOUT_SUCCESS = "CHECKOUT_SUCCESS",
318
+ CHECKOUT_CANCELED = "CHECKOUT_CANCELED",
319
+ CANCELED = "CANCELED",
320
+ PAYMENT_RECEIVED = "PAYMENT_RECEIVED",
321
+ PAYMENT_SUCCESS = "PAYMENT_SUCCESS",
322
+ PAYMENT_FAILED = "PAYMENT_FAILED"
323
+ }
324
+
9
325
  export declare class SDK {
10
326
  private iframe;
11
327
  private iframeUrl;
@@ -31,6 +347,14 @@ export declare class SDK {
31
347
  * Send configuration to the iframe
32
348
  */
33
349
  private sendConfigToIframe;
350
+ /**
351
+ * Show skeleton loader while iframe is connecting
352
+ */
353
+ private showLoader;
354
+ /**
355
+ * Hide loader
356
+ */
357
+ private hideLoader;
34
358
  /**
35
359
  * Close the iframe and cleanup
36
360
  */
@@ -56,9 +380,6 @@ export declare class SDK {
56
380
  destroy(): void;
57
381
  }
58
382
 
59
- /**
60
- * Type definitions for SDK v2
61
- */
62
383
  declare interface SDKConfig {
63
384
  /** URL of the payment application to load in iframe */
64
385
  iframeUrl?: string;
@@ -78,7 +399,17 @@ declare interface SDKConfig {
78
399
  debug?: boolean;
79
400
  }
80
401
 
81
- declare interface TransactionData {
402
+ declare interface ThemeStyles {
403
+ inputContainer?: InputContainerStyles;
404
+ input?: InputStyles;
405
+ button?: ButtonStyles;
406
+ disclaimerColor?: string;
407
+ fieldErrorColor?: string;
408
+ generalError?: GeneralMessageStyles;
409
+ generalSuccess?: GeneralMessageStyles;
410
+ }
411
+
412
+ export declare interface TransactionData {
82
413
  transaction?: {
83
414
  id: string;
84
415
  amount: number;
@@ -90,4 +421,6 @@ declare interface TransactionData {
90
421
  [key: string]: any;
91
422
  }
92
423
 
424
+ export declare const VERSION = "0.0.1";
425
+
93
426
  export { }