@inflow_pay/sdk 0.0.1 → 0.1.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/README.md +105 -83
- package/dist/payment-sdk-BWb7DDT1.js +88 -0
- package/dist/payment-sdk-BWb7DDT1.js.map +1 -0
- package/dist/payment-sdk-CH8ugKck.mjs +411 -0
- package/dist/payment-sdk-CH8ugKck.mjs.map +1 -0
- package/dist/react/index.d.ts +310 -0
- package/dist/react.cjs +2 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.esm.js +64 -719
- package/dist/react.esm.js.map +1 -1
- package/dist/react.umd.js +30 -13
- package/dist/react.umd.js.map +1 -1
- package/dist/sdk.cjs +2 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.ts +326 -5
- package/dist/sdk.esm.js +29 -420
- package/dist/sdk.esm.js.map +1 -1
- package/dist/sdk.umd.js +13 -12
- package/dist/sdk.umd.js.map +1 -1
- package/package.json +21 -28
- package/dist/react.d.ts +0 -104
- package/dist/react.d.ts.map +0 -1
package/dist/sdk.d.ts
CHANGED
|
@@ -1,11 +1,323 @@
|
|
|
1
|
-
declare interface
|
|
1
|
+
declare interface ButtonBaseStyles {
|
|
2
|
+
backgroundColor?: string;
|
|
3
|
+
textColor?: string;
|
|
4
|
+
borderRadius?: string;
|
|
5
|
+
borderColor?: string;
|
|
6
|
+
borderEnabled?: boolean;
|
|
7
|
+
fontSize?: string;
|
|
8
|
+
fontWeight?: string;
|
|
9
|
+
opacity?: string;
|
|
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 interface GeneralMessageStyles {
|
|
109
|
+
textColor?: string;
|
|
110
|
+
backgroundColor?: string;
|
|
111
|
+
borderEnabled?: boolean;
|
|
112
|
+
borderRadius?: string;
|
|
113
|
+
borderColor?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export declare interface IframeMessage {
|
|
117
|
+
type: 'sdkData' | 'success' | 'error' | 'close' | '3ds-required' | '3ds-result' | 'iframe-ready';
|
|
118
|
+
data?: any;
|
|
119
|
+
config?: PaymentConfig;
|
|
120
|
+
threeDsSessionUrl?: string;
|
|
121
|
+
paymentId?: string;
|
|
122
|
+
success?: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* InflowPayProvider - Global SDK configuration
|
|
127
|
+
*
|
|
128
|
+
* Similar to React's InflowPayProvider but for vanilla JS
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const provider = new InflowPayProvider({
|
|
133
|
+
* config: { apiKey: 'inflow_pub_xxx' }
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* const cardElement = provider.createCardElement({
|
|
137
|
+
* paymentId: 'pay_xxx',
|
|
138
|
+
* onComplete: (result) => {
|
|
139
|
+
* if (result.status === 'CHECKOUT_SUCCESS') {
|
|
140
|
+
* window.location.href = '/success';
|
|
141
|
+
* }
|
|
142
|
+
* }
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* cardElement.mount();
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare class InflowPayProvider {
|
|
149
|
+
private sdk;
|
|
150
|
+
constructor(options: {
|
|
151
|
+
config: InflowPayProviderConfig;
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* Create a CardElement (similar to React's <CardElement />)
|
|
155
|
+
*
|
|
156
|
+
* @param props - CardElement props (same as React SDK)
|
|
157
|
+
* @returns CardElement instance
|
|
158
|
+
*/
|
|
159
|
+
createCardElement(props: CardElementProps): CardElement;
|
|
160
|
+
/**
|
|
161
|
+
* Get the underlying PaymentSDK instance
|
|
162
|
+
*/
|
|
163
|
+
getSDK(): PaymentSDK;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export declare interface InflowPayProviderConfig {
|
|
167
|
+
apiKey: string;
|
|
168
|
+
iframeUrl?: string;
|
|
169
|
+
timeout?: number;
|
|
170
|
+
/** Enable debug logging (default: false, only allowed in local/dev environments) */
|
|
171
|
+
debug?: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
declare interface InputContainerStyles {
|
|
175
|
+
backgroundColor?: string;
|
|
176
|
+
borderColor?: string;
|
|
177
|
+
borderEnabled?: boolean;
|
|
178
|
+
borderRadius?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare interface InputStyles {
|
|
182
|
+
backgroundColor?: string;
|
|
183
|
+
borderColor?: string;
|
|
184
|
+
borderEnabled?: boolean;
|
|
185
|
+
borderRadius?: string;
|
|
186
|
+
textColor?: string;
|
|
187
|
+
placeholderColor?: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare interface InternalSDKConfig {
|
|
191
|
+
apiKey: string;
|
|
192
|
+
iframeUrl: string;
|
|
193
|
+
timeout: number;
|
|
194
|
+
debug: boolean;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export declare interface PaymentConfig {
|
|
2
198
|
name?: string;
|
|
3
199
|
amount?: number;
|
|
4
200
|
currency?: string;
|
|
5
201
|
paymentId?: string;
|
|
202
|
+
/** Custom styling for the card element */
|
|
203
|
+
style?: CSSProperties;
|
|
204
|
+
/** Custom button text (default: "Complete Payment") */
|
|
205
|
+
buttonText?: string;
|
|
206
|
+
/** Custom placeholder text for inputs */
|
|
207
|
+
placeholders?: {
|
|
208
|
+
cardNumber?: string;
|
|
209
|
+
expiry?: string;
|
|
210
|
+
cvc?: string;
|
|
211
|
+
};
|
|
6
212
|
[key: string]: any;
|
|
7
213
|
}
|
|
8
214
|
|
|
215
|
+
export declare type PaymentError = {
|
|
216
|
+
code: string;
|
|
217
|
+
message: string;
|
|
218
|
+
retryable: boolean;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export declare type PaymentResult = {
|
|
222
|
+
status: string;
|
|
223
|
+
data?: any;
|
|
224
|
+
error?: {
|
|
225
|
+
code: string;
|
|
226
|
+
message: string;
|
|
227
|
+
retryable: boolean;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export declare class PaymentSDK {
|
|
232
|
+
private config;
|
|
233
|
+
/**
|
|
234
|
+
* Initialize the InflowPay Payment SDK
|
|
235
|
+
*
|
|
236
|
+
* @param config - SDK configuration
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const sdk = new PaymentSDK({
|
|
241
|
+
* apiKey: 'inflow_pub_local_xxx'
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
constructor(config: PaymentSDKConfig);
|
|
246
|
+
/**
|
|
247
|
+
* Create a CardElement for iframe-based payment UI
|
|
248
|
+
*
|
|
249
|
+
* @param options - CardElement configuration
|
|
250
|
+
* @returns CardElement instance
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const cardElement = sdk.createCardElement({
|
|
255
|
+
* container: '#card-container',
|
|
256
|
+
* paymentId: 'pay_123',
|
|
257
|
+
* onComplete: (result) => {
|
|
258
|
+
* if (result.status === 'CHECKOUT_SUCCESS') {
|
|
259
|
+
* window.location.href = '/success';
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* cardElement.mount();
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
createCardElement(options: {
|
|
268
|
+
container: string | HTMLElement;
|
|
269
|
+
paymentId: string;
|
|
270
|
+
style?: CSSProperties;
|
|
271
|
+
buttonText?: string;
|
|
272
|
+
placeholders?: {
|
|
273
|
+
cardNumber?: string;
|
|
274
|
+
expiry?: string;
|
|
275
|
+
cvc?: string;
|
|
276
|
+
};
|
|
277
|
+
onComplete?: (result: {
|
|
278
|
+
status: string;
|
|
279
|
+
data?: any;
|
|
280
|
+
error?: any;
|
|
281
|
+
}) => void;
|
|
282
|
+
onError?: (error: any) => void;
|
|
283
|
+
onClose?: () => void;
|
|
284
|
+
}): CardElement;
|
|
285
|
+
/**
|
|
286
|
+
* Get the iframe URL being used
|
|
287
|
+
*/
|
|
288
|
+
getIframeUrl(): string;
|
|
289
|
+
/**
|
|
290
|
+
* Get the API key
|
|
291
|
+
*/
|
|
292
|
+
getApiKey(): string;
|
|
293
|
+
/**
|
|
294
|
+
* Auto-detect environment from API key
|
|
295
|
+
*/
|
|
296
|
+
private getEnvironmentFromApiKey;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export declare interface PaymentSDKConfig {
|
|
300
|
+
/** Public API key */
|
|
301
|
+
apiKey: string;
|
|
302
|
+
/** Backend API URL (optional, auto-detected from API key) */
|
|
303
|
+
iframeUrl?: string;
|
|
304
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
305
|
+
timeout?: number;
|
|
306
|
+
/** Enable debug logging (default: false, only allowed in local/dev environments) */
|
|
307
|
+
debug?: boolean;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export declare enum PaymentStatus {
|
|
311
|
+
INITIATION = "INITIATION",
|
|
312
|
+
CHECKOUT_PENDING = "CHECKOUT_PENDING",
|
|
313
|
+
CHECKOUT_SUCCESS = "CHECKOUT_SUCCESS",
|
|
314
|
+
CHECKOUT_CANCELED = "CHECKOUT_CANCELED",
|
|
315
|
+
CANCELED = "CANCELED",
|
|
316
|
+
PAYMENT_RECEIVED = "PAYMENT_RECEIVED",
|
|
317
|
+
PAYMENT_SUCCESS = "PAYMENT_SUCCESS",
|
|
318
|
+
PAYMENT_FAILED = "PAYMENT_FAILED"
|
|
319
|
+
}
|
|
320
|
+
|
|
9
321
|
export declare class SDK {
|
|
10
322
|
private iframe;
|
|
11
323
|
private iframeUrl;
|
|
@@ -56,9 +368,6 @@ export declare class SDK {
|
|
|
56
368
|
destroy(): void;
|
|
57
369
|
}
|
|
58
370
|
|
|
59
|
-
/**
|
|
60
|
-
* Type definitions for SDK v2
|
|
61
|
-
*/
|
|
62
371
|
declare interface SDKConfig {
|
|
63
372
|
/** URL of the payment application to load in iframe */
|
|
64
373
|
iframeUrl?: string;
|
|
@@ -78,7 +387,17 @@ declare interface SDKConfig {
|
|
|
78
387
|
debug?: boolean;
|
|
79
388
|
}
|
|
80
389
|
|
|
81
|
-
declare interface
|
|
390
|
+
declare interface ThemeStyles {
|
|
391
|
+
inputContainer?: InputContainerStyles;
|
|
392
|
+
input?: InputStyles;
|
|
393
|
+
button?: ButtonStyles;
|
|
394
|
+
disclaimerColor?: string;
|
|
395
|
+
fieldErrorColor?: string;
|
|
396
|
+
generalError?: GeneralMessageStyles;
|
|
397
|
+
generalSuccess?: GeneralMessageStyles;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export declare interface TransactionData {
|
|
82
401
|
transaction?: {
|
|
83
402
|
id: string;
|
|
84
403
|
amount: number;
|
|
@@ -90,4 +409,6 @@ declare interface TransactionData {
|
|
|
90
409
|
[key: string]: any;
|
|
91
410
|
}
|
|
92
411
|
|
|
412
|
+
export declare const VERSION = "0.0.1";
|
|
413
|
+
|
|
93
414
|
export { }
|