flintn-checkout 0.0.8 → 0.0.9

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 CHANGED
@@ -1,13 +1,15 @@
1
1
  # flintn-checkout
2
2
 
3
- FlintN Payment SDK — Iframe-based payment widget with postMessage communication.
3
+ FlintN Payment SDK — Embed payment forms via iframe checkout or headless hosted fields.
4
4
 
5
5
  ## Installation
6
6
  ```bash
7
7
  npm install flintn-checkout
8
8
  ```
9
9
 
10
- ## Quick Start
10
+ ## Iframe Checkout
11
+
12
+ Full checkout UI rendered inside a single iframe. Includes card form, express payments (Apple Pay, Google Pay, PayPal), and 3DS handling.
11
13
 
12
14
  ### React
13
15
  ```tsx
@@ -25,9 +27,6 @@ function Checkout() {
25
27
  console.log('Payment failed:', result.error);
26
28
  }
27
29
  },
28
- onExpressPayment: (result) => {
29
- console.log('Express payment:', result);
30
- },
31
30
  });
32
31
 
33
32
  return (
@@ -53,9 +52,6 @@ const payment = new FlintNPayment({
53
52
  console.log('Payment failed:', result.error);
54
53
  }
55
54
  },
56
- onExpressPayment: (result) => {
57
- console.log('Express payment:', result);
58
- },
59
55
  onReady: () => {
60
56
  console.log('Widget ready');
61
57
  },
@@ -110,23 +106,22 @@ Do **not** set a fixed `height` on the container — it will leave empty space b
110
106
 
111
107
  | Option | Type | Required | Default | Description |
112
108
  |--------|------|----------|---------|-------------|
113
- | `clientSessionId` | `string` | | — | Client session ID from backend |
114
- | `formFields` | `FormFields` | | — | Form field visibility and requirements |
115
- | `styles` | `FormStyles` | | — | Custom styles for the checkout form |
116
- | `successRedirectUrl` | `string` | | — | Redirect URL after successful payment |
109
+ | `config` | `FlintNConfig` | Yes | — | Checkout configuration |
110
+ | `onPayment` | `(result: PaymentResult) => void` | No | — | Card payment result callback |
111
+ | `onReady` | `() => void` | No | — | Widget loaded and ready |
112
+ | `onError` | `(error: PaymentError) => void` | No | — | SDK initialization error |
113
+ | `debug` | `boolean` | No | `false` | Enable console debug logs |
117
114
 
118
- > **Note:** `formFields` only applies when using Primer as the payment provider.
115
+ ### FlintNConfig
119
116
 
120
- ## Callbacks
117
+ | Property | Type | Required | Description |
118
+ |----------|------|----------|-------------|
119
+ | `clientSessionId` | `string` | Yes | Client session ID from backend |
120
+ | `formFields` | `FormFields` | No | Form field visibility and requirements |
121
+ | `styles` | `FormStyles` | No | Custom styles for the checkout form |
122
+ | `successRedirectUrl` | `string` | No | Redirect URL after successful payment |
121
123
 
122
- | Callback | Description |
123
- |----------|-------------|
124
- | `onPayment` | Fired when card payment completes (success or error) |
125
- | `onExpressPayment` | Fired when express payment completes (Apple Pay, Google Pay, PayPal) |
126
- | `onReady` | Fired when widget is loaded and ready |
127
- | `onError` | Fired on SDK initialization error |
128
-
129
- ## React Hook Return Values
124
+ ### React Hook Return Values
130
125
 
131
126
  | Value | Type | Description |
132
127
  |-------|------|-------------|
@@ -135,7 +130,227 @@ Do **not** set a fixed `height` on the container — it will leave empty space b
135
130
  | `paymentResult` | `PaymentResult \| null` | Result after payment attempt |
136
131
  | `error` | `PaymentError \| null` | SDK error if any |
137
132
 
138
- ## Types
133
+ ---
134
+
135
+ ## Hosted Fields
136
+
137
+ Individual PCI-compliant input fields rendered as separate iframes. You control the layout, labels, and error display — the SDK handles card data securely.
138
+
139
+ Each field (card number, expiry, CVV) is a separate iframe. Raw card data never touches your page.
140
+
141
+ ### React
142
+ ```tsx
143
+ import { useState } from 'react';
144
+ import { useFlintNFields } from 'flintn-checkout/react';
145
+
146
+ function CheckoutForm() {
147
+ const [cardholderName, setCardholderName] = useState('');
148
+
149
+ const {
150
+ cardNumberRef,
151
+ expiryRef,
152
+ cvvRef,
153
+ isReady,
154
+ fieldErrors,
155
+ cardBrand,
156
+ paymentResult,
157
+ submit,
158
+ error,
159
+ } = useFlintNFields({
160
+ config: {
161
+ clientSessionId: 'your_client_session_id',
162
+ styles: {
163
+ inputBorderRadius: '8px',
164
+ inputBorderFocusColor: '#6366f1',
165
+ },
166
+ },
167
+ onPayment: (result) => {
168
+ if (result.status === 'PAYMENT_SUCCESS') {
169
+ console.log('Payment succeeded:', result.data);
170
+ }
171
+ },
172
+ debug: true,
173
+ });
174
+
175
+ const handleSubmit = async (e: React.FormEvent) => {
176
+ e.preventDefault();
177
+ const result = await submit({ cardholderName });
178
+ console.log('Payment result:', result);
179
+ };
180
+
181
+ return (
182
+ <form onSubmit={handleSubmit}>
183
+ <label>Card Number {cardBrand && `(${cardBrand})`}</label>
184
+ <div ref={cardNumberRef} style={{ height: 40, marginBottom: 4 }} />
185
+ {fieldErrors['card-number'] && (
186
+ <span style={{ color: 'red' }}>{fieldErrors['card-number']}</span>
187
+ )}
188
+
189
+ <div style={{ display: 'flex', gap: 12 }}>
190
+ <div style={{ flex: 1 }}>
191
+ <label>Expiry</label>
192
+ <div ref={expiryRef} style={{ height: 40, marginBottom: 4 }} />
193
+ {fieldErrors['expiry'] && (
194
+ <span style={{ color: 'red' }}>{fieldErrors['expiry']}</span>
195
+ )}
196
+ </div>
197
+ <div style={{ flex: 1 }}>
198
+ <label>CVV</label>
199
+ <div ref={cvvRef} style={{ height: 40, marginBottom: 4 }} />
200
+ {fieldErrors['cvv'] && (
201
+ <span style={{ color: 'red' }}>{fieldErrors['cvv']}</span>
202
+ )}
203
+ </div>
204
+ </div>
205
+
206
+ <label>Cardholder Name</label>
207
+ <input
208
+ value={cardholderName}
209
+ onChange={(e) => setCardholderName(e.target.value)}
210
+ placeholder="John Doe"
211
+ />
212
+
213
+ <button type="submit" disabled={!isReady}>
214
+ {isReady ? 'Pay' : 'Loading...'}
215
+ </button>
216
+
217
+ {error && <div style={{ color: 'red' }}>{error.message}</div>}
218
+ {paymentResult?.status === 'PAYMENT_ERROR' && paymentResult.error && (
219
+ <div style={{ color: 'red' }}>{paymentResult.error.message}</div>
220
+ )}
221
+ </form>
222
+ );
223
+ }
224
+ ```
225
+
226
+ ### Vanilla JavaScript
227
+ ```javascript
228
+ import { FlintNFields } from 'flintn-checkout';
229
+
230
+ const fields = new FlintNFields({
231
+ config: {
232
+ clientSessionId: 'your_client_session_id',
233
+ styles: {
234
+ inputBorderRadius: '8px',
235
+ inputBorderFocusColor: '#6366f1',
236
+ },
237
+ },
238
+ onReady: () => console.log('All fields ready'),
239
+ onPayment: (result) => console.log('Payment result:', result),
240
+ onChange: (event) => console.log(`${event.fieldType}:`, event),
241
+ debug: true,
242
+ });
243
+
244
+ const cardNumber = fields.createField('card-number', { placeholder: '4111 1111 1111 1111' });
245
+ const expiry = fields.createField('expiry', { placeholder: 'MM/YY' });
246
+ const cvv = fields.createField('cvv', { placeholder: 'CVC' });
247
+
248
+ cardNumber.mount('#card-number');
249
+ expiry.mount('#expiry');
250
+ cvv.mount('#cvv');
251
+
252
+ // Validate
253
+ const validation = await fields.validate();
254
+ if (validation.isValid) {
255
+ const result = await fields.submit({ cardholderName: 'John Doe' });
256
+ }
257
+
258
+ // Cleanup
259
+ fields.unmount();
260
+ ```
261
+
262
+ ### Hosted Fields Options (Vanilla JS)
263
+
264
+ | Option | Type | Required | Default | Description |
265
+ |--------|------|----------|---------|-------------|
266
+ | `config` | `FlintNFieldsConfig` | Yes | — | Fields configuration |
267
+ | `onPayment` | `(result: PaymentResult) => void` | No | — | Payment result callback |
268
+ | `onReady` | `() => void` | No | — | All fields loaded and ready |
269
+ | `onChange` | `(event: FieldChangeEvent) => void` | No | — | Field value changed |
270
+ | `onFocus` | `(fieldType: TFieldType) => void` | No | — | Field gained focus |
271
+ | `onBlur` | `(fieldType: TFieldType, state: FieldState) => void` | No | — | Field lost focus |
272
+ | `onError` | `(error: PaymentError) => void` | No | — | SDK initialization error |
273
+ | `debug` | `boolean` | No | `false` | Enable console debug logs |
274
+
275
+ ### FlintNFieldsConfig
276
+
277
+ | Property | Type | Required | Description |
278
+ |----------|------|----------|-------------|
279
+ | `clientSessionId` | `string` | Yes | Client session ID from backend |
280
+ | `styles` | `FormStyles` | No | Styles applied to all hosted field inputs |
281
+
282
+ ### React Hook Options
283
+
284
+ The `useFlintNFields` hook accepts `config`, `onPayment`, and `debug` from the options above. It manages `onReady`, `onChange`, `onFocus`, `onBlur`, and `onError` internally and exposes them as return values instead.
285
+
286
+ Additional React-only options:
287
+
288
+ | Option | Type | Description |
289
+ |--------|------|-------------|
290
+ | `fields.cardNumber` | `FieldOptions \| false` | Card number field options, or `false` to skip |
291
+ | `fields.expiry` | `FieldOptions \| false` | Expiry field options, or `false` to skip |
292
+ | `fields.cvv` | `FieldOptions \| false` | CVV field options, or `false` to skip |
293
+ | `onChange` | `(event: FieldChangeEvent) => void` | Optional additional callback |
294
+ | `onFocus` | `(fieldType: TFieldType) => void` | Optional additional callback |
295
+ | `onBlur` | `(fieldType: TFieldType, state: FieldState) => void` | Optional additional callback |
296
+
297
+ ### FieldOptions
298
+
299
+ | Property | Type | Default | Description |
300
+ |----------|------|---------|-------------|
301
+ | `placeholder` | `string` | Field-specific default | Input placeholder text |
302
+ | `disabled` | `boolean` | `false` | Disable the input |
303
+
304
+ ### React Hook Return Values
305
+
306
+ | Value | Type | Description |
307
+ |-------|------|-------------|
308
+ | `cardNumberRef` | `RefObject<HTMLDivElement>` | Ref for card number container |
309
+ | `expiryRef` | `RefObject<HTMLDivElement>` | Ref for expiry container |
310
+ | `cvvRef` | `RefObject<HTMLDivElement>` | Ref for CVV container |
311
+ | `isReady` | `boolean` | All fields loaded and ready |
312
+ | `fieldErrors` | `Partial<Record<TFieldType, string \| null>>` | Per-field validation errors (populated after first submit) |
313
+ | `fieldStates` | `Partial<Record<TFieldType, FieldState>>` | Per-field state (always up to date) |
314
+ | `cardBrand` | `string \| null` | Detected card brand (e.g. `"visa"`, `"mastercard"`) |
315
+ | `paymentResult` | `PaymentResult \| null` | Result after payment attempt |
316
+ | `error` | `PaymentError \| null` | SDK error if any |
317
+ | `validate` | `() => Promise<FieldsValidationResult>` | Validate all fields |
318
+ | `submit` | `(options?: SubmitOptions) => Promise<PaymentResult>` | Validate and submit payment |
319
+ | `focusField` | `(fieldType: TFieldType) => void` | Focus a field programmatically |
320
+ | `clearField` | `(fieldType: TFieldType) => void` | Clear a field |
321
+ | `clearAll` | `() => void` | Clear all fields |
322
+
323
+ ### Validation Behavior
324
+
325
+ Validation mirrors react-hook-form `mode: 'onSubmit'`:
326
+
327
+ - Before first submit: `fieldErrors` is always `{}`
328
+ - After first submit: errors update on every field change (revalidation)
329
+ - Card number changes trigger CVV revalidation (CVV length depends on card brand)
330
+ - All three fields (card number, expiry, CVV) are required — submitting with a missing field returns a `MISSING_FIELDS` error
331
+
332
+ ### Field Types
333
+
334
+ | Value | Description |
335
+ |-------|-------------|
336
+ | `'card-number'` | Card number input with automatic formatting and brand detection |
337
+ | `'expiry'` | Expiry date input (MM/YY format) |
338
+ | `'cvv'` | CVV/CVC input (3 or 4 digits depending on card brand) |
339
+
340
+ ### Individual Field Methods (Vanilla JS)
341
+
342
+ | Method | Description |
343
+ |--------|-------------|
344
+ | `field.mount(selector)` | Mount field into a DOM element |
345
+ | `field.unmount()` | Remove field from DOM |
346
+ | `field.focus()` | Focus the field |
347
+ | `field.clear()` | Clear the field value |
348
+ | `field.getState()` | Get current field state |
349
+ | `field.getFieldType()` | Get the field type |
350
+
351
+ ---
352
+
353
+ ## Shared Types
139
354
 
140
355
  ### PaymentResult
141
356
  ```typescript
@@ -157,12 +372,42 @@ interface PaymentError {
157
372
  }
158
373
  ```
159
374
 
375
+ ### FieldState
376
+ ```typescript
377
+ interface FieldState {
378
+ isEmpty: boolean;
379
+ isValid: boolean;
380
+ isFocused: boolean;
381
+ error: string | null;
382
+ }
383
+ ```
384
+
385
+ ### FieldChangeEvent
386
+ ```typescript
387
+ interface FieldChangeEvent {
388
+ fieldType: 'card-number' | 'expiry' | 'cvv';
389
+ isEmpty: boolean;
390
+ isValid: boolean;
391
+ isFocused: boolean;
392
+ error: string | null;
393
+ cardBrand?: string; // Only for card-number
394
+ }
395
+ ```
396
+
397
+ ### FieldsValidationResult
398
+ ```typescript
399
+ interface FieldsValidationResult {
400
+ isValid: boolean;
401
+ errors: Partial<Record<'card-number' | 'expiry' | 'cvv', string | null>>;
402
+ }
403
+ ```
404
+
160
405
  ### FormFields
161
406
  ```typescript
162
407
  interface FormFields {
163
- isEmailVisible?: boolean; // Primer only
408
+ isEmailVisible?: boolean; // Primer only
164
409
  isCardholderNameRequired?: boolean; // Primer only
165
- formVariant?: 'DEFAULT' | 'LIST';
410
+ formVariant?: 'DEFAULT' | 'LIST' | 'RADIO';
166
411
  }
167
412
  ```
168
413
 
@@ -191,52 +436,59 @@ interface FormStyles {
191
436
 
192
437
  ### FormStyles Reference
193
438
 
194
- | Property | Description |
195
- |----------|-------------|
196
- | `loaderColor` | Color of the loading spinner |
197
- | `backgroundColor` | Background color of the checkout form |
198
- | `expressButtonsSpacing` | Spacing between express payment buttons (Apple Pay, Google Pay, PayPal) |
199
- | `inputBackgroundColor` | Background color of input fields |
200
- | `inputBorderRadius` | Border radius of input fields |
201
- | `inputBorderColor` | Default border color of input fields |
202
- | `inputBorderHoverColor` | Border color of input fields on hover |
203
- | `inputBorderFocusColor` | Border color of input fields on focus |
204
- | `inputBorderErrorColor` | Border color of input fields in error state |
205
- | `errorMessageColor` | Color of error messages below inputs |
206
- | `buttonColor` | Background color of the submit button |
207
- | `buttonHoverColor` | Background color of the submit button on hover/active |
208
- | `buttonBorderRadius` | Border radius of the submit button |
209
- | `buttonText` | Custom text for the submit button (overrides default "Pay $X.XX") |
210
- | `cardButtonColor` | Background color of the "Credit or Debit Card" button (LIST variant only) |
211
- | `cardButtonHoverColor` | Hover/active color of the card button (LIST variant only) |
212
- | `cardButtonText` | Custom text for the card button (LIST variant only) |
439
+ | Property | Iframe Checkout | Hosted Fields | Description |
440
+ |----------|:-:|:-:|-------------|
441
+ | `loaderColor` | | | Loading spinner color |
442
+ | `backgroundColor` | | | Form background color |
443
+ | `expressButtonsSpacing` | ✅ | — | Spacing between express payment buttons |
444
+ | `inputBackgroundColor` | | | Input field background color |
445
+ | `inputBorderRadius` | | | Input field border radius |
446
+ | `inputBorderColor` | | | Default input border color |
447
+ | `inputBorderHoverColor` | | | Input border color on hover |
448
+ | `inputBorderFocusColor` | | | Input border color on focus |
449
+ | `inputBorderErrorColor` | | | Input border color in error state |
450
+ | `errorMessageColor` | | | Error message text color |
451
+ | `buttonColor` | | | Submit button background color |
452
+ | `buttonHoverColor` | | | Submit button hover color |
453
+ | `buttonBorderRadius` | | | Submit button border radius |
454
+ | `buttonText` | | | Custom submit button text |
455
+ | `cardButtonColor` | | | Card button color (LIST variant) |
456
+ | `cardButtonHoverColor` | | | Card button hover color (LIST variant) |
457
+ | `cardButtonText` | | | Custom card button text (LIST variant) |
213
458
 
214
459
  ## Form Variants
215
460
 
216
- The checkout form supports two layout variants via `formFields.formVariant`:
461
+ The iframe checkout supports three layout variants via `formFields.formVariant`:
217
462
 
218
- - **DEFAULT** — Express payment methods shown above the card form with dividers
219
- - **LIST** — Express payment methods shown as a list with a "Credit or Debit Card" button; clicking it navigates to the card form with a back arrow
463
+ - **DEFAULT** — Express payment methods shown above the card form with dividers.
464
+ - **LIST** — Express payment methods shown first; users tap a "Credit or Debit Card" button to navigate to the card form, with a back arrow to return to the express view.
465
+ - **RADIO** — Express payments and the card form are presented as two radio options ("Fast checkout" and "Card payment"). Selecting a radio expands its section and collapses the other. The card payment radio shows accepted card brand logos inline with its label.
466
+
467
+ LIST and RADIO automatically fall back to the DEFAULT layout when no express payment methods are available, since there's nothing to toggle between. The `cardButtonColor`, `cardButtonHoverColor`, and `cardButtonText` style overrides apply only to the LIST variant's "Credit or Debit Card" button.
220
468
 
221
469
  ## Supported Payment Methods
222
470
 
223
- - 💳 Credit/Debit Cards (Visa, Mastercard, Amex, Discover)
224
- - 🍎 Apple Pay
225
- - 🔵 Google Pay
226
- - 🟡 PayPal
471
+ ### Iframe Checkout
472
+ - Credit/Debit Cards (Visa, Mastercard, Amex, Discover)
473
+ - Apple Pay
474
+ - Google Pay
475
+ - PayPal
476
+
477
+ ### Hosted Fields
478
+ - Credit/Debit Cards (Visa, Mastercard, Amex, Discover)
227
479
 
228
480
  ## Debug Mode
229
481
 
230
482
  Enable debug logs in console:
231
483
  ```typescript
232
- // React
484
+ // Iframe Checkout
233
485
  useFlintNPayment({
234
486
  config: { clientSessionId: '...' },
235
487
  debug: true,
236
488
  });
237
489
 
238
- // Vanilla JS
239
- new FlintNPayment({
490
+ // Hosted Fields
491
+ useFlintNFields({
240
492
  config: { clientSessionId: '...' },
241
493
  debug: true,
242
494
  });
package/dist/index.d.mts CHANGED
@@ -13,6 +13,7 @@ type TEventType = (typeof EventType)[keyof typeof EventType];
13
13
  declare const CheckoutFormVariant: {
14
14
  readonly DEFAULT: "DEFAULT";
15
15
  readonly LIST: "LIST";
16
+ readonly RADIO: "RADIO";
16
17
  };
17
18
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
18
19
  interface FormFields {
@@ -66,24 +67,109 @@ interface FlintNPaymentOptions {
66
67
  onError?: (error: PaymentError) => void;
67
68
  debug?: boolean;
68
69
  }
70
+ declare const FieldType: {
71
+ readonly CARD_NUMBER: "card-number";
72
+ readonly EXPIRY: "expiry";
73
+ readonly CVV: "cvv";
74
+ };
75
+ type TFieldType = (typeof FieldType)[keyof typeof FieldType];
76
+ declare const FieldEventType: {
77
+ readonly FIELD_CONFIG: "FIELD_CONFIG";
78
+ readonly FIELD_VALIDATE: "FIELD_VALIDATE";
79
+ readonly FIELD_SUBMIT: "FIELD_SUBMIT";
80
+ readonly FIELD_FOCUS_REQUEST: "FIELD_FOCUS_REQUEST";
81
+ readonly FIELD_CLEAR: "FIELD_CLEAR";
82
+ readonly FIELD_READY: "FIELD_READY";
83
+ readonly FIELD_CHANGE: "FIELD_CHANGE";
84
+ readonly FIELD_FOCUS: "FIELD_FOCUS";
85
+ readonly FIELD_BLUR: "FIELD_BLUR";
86
+ readonly FIELD_VALIDATION: "FIELD_VALIDATION";
87
+ readonly FIELD_SUBMIT_RESULT: "FIELD_SUBMIT_RESULT";
88
+ readonly FIELD_HEIGHT: "FIELD_HEIGHT";
89
+ };
90
+ type TFieldEventType = (typeof FieldEventType)[keyof typeof FieldEventType];
91
+ interface FieldOptions {
92
+ placeholder?: string;
93
+ disabled?: boolean;
94
+ }
95
+ interface FieldState {
96
+ isEmpty: boolean;
97
+ isValid: boolean;
98
+ isFocused: boolean;
99
+ error: string | null;
100
+ }
101
+ interface FieldChangeEvent {
102
+ fieldType: TFieldType;
103
+ isEmpty: boolean;
104
+ isValid: boolean;
105
+ isFocused: boolean;
106
+ error: string | null;
107
+ cardBrand?: string;
108
+ }
109
+ interface FieldValidationResult {
110
+ fieldType: TFieldType;
111
+ isValid: boolean;
112
+ error: string | null;
113
+ }
114
+ interface FieldsValidationResult {
115
+ isValid: boolean;
116
+ errors: Partial<Record<TFieldType, string | null>>;
117
+ }
118
+ interface SubmitOptions {
119
+ cardholderName?: string;
120
+ }
121
+ interface FlintNFieldsConfig {
122
+ clientSessionId: string;
123
+ styles?: FormStyles;
124
+ }
125
+ interface FlintNFieldsOptions {
126
+ origin?: string;
127
+ config: FlintNFieldsConfig;
128
+ onPayment?: (result: PaymentResult) => void;
129
+ onReady?: () => void;
130
+ onChange?: (event: FieldChangeEvent) => void;
131
+ onFocus?: (fieldType: TFieldType) => void;
132
+ onBlur?: (fieldType: TFieldType, state: FieldState) => void;
133
+ onError?: (error: PaymentError) => void;
134
+ debug?: boolean;
135
+ }
69
136
 
70
- declare class FlintNPayment {
71
- private options;
72
- private origin;
73
- private iframe;
74
- private container;
75
- private isReady;
76
- private messageHandler;
77
- constructor(options: FlintNPaymentOptions);
137
+ interface FlintNPayment {
78
138
  mount(selector: string | HTMLElement): void;
79
139
  unmount(): void;
80
140
  getIsReady(): boolean;
81
- private handleMessage;
82
- private isValidRedirectUrl;
83
- private handlePaymentResult;
84
- private sendConfig;
85
- private log;
86
141
  }
142
+ declare function createFlintNPayment(options: FlintNPaymentOptions): FlintNPayment;
143
+
144
+ interface FlintNFieldInternalCallbacks {
145
+ onReady: (fieldType: TFieldType) => void;
146
+ onChange: (event: FieldChangeEvent) => void;
147
+ onFocus: (fieldType: TFieldType) => void;
148
+ onBlur: (fieldType: TFieldType, state: FieldState) => void;
149
+ onHeight: (fieldType: TFieldType, height: number) => void;
150
+ }
151
+ interface FlintNField {
152
+ mount(selector: string | HTMLElement): void;
153
+ unmount(): void;
154
+ focus(): void;
155
+ clear(): void;
156
+ getState(): FieldState;
157
+ getFieldType(): TFieldType;
158
+ _sendMessage(type: string, payload: unknown): void;
159
+ _getIframe(): HTMLIFrameElement | null;
160
+ _handleMessage(type: string, payload: Record<string, unknown>): void;
161
+ }
162
+ declare function createFlintNField(fieldType: TFieldType, origin: string, clientSessionId: string, options: FieldOptions, callbacks: FlintNFieldInternalCallbacks, debug?: boolean, formStyles?: FormStyles): FlintNField;
163
+
164
+ interface FlintNFields {
165
+ createField(fieldType: TFieldType, options?: FieldOptions): FlintNField;
166
+ getField(fieldType: TFieldType): FlintNField | undefined;
167
+ validate(): Promise<FieldsValidationResult>;
168
+ submit(options?: SubmitOptions, skipValidation?: boolean): Promise<PaymentResult>;
169
+ unmount(): void;
170
+ getIsReady(): boolean;
171
+ }
172
+ declare function createFlintNFields(options: FlintNFieldsOptions): FlintNFields;
87
173
 
88
174
  declare const parseOrigin: (origin: string) => string;
89
175
  declare const buildIframeSrc: (origin: string) => string;
@@ -93,4 +179,4 @@ declare const validateConfig: (config: {
93
179
  }) => void;
94
180
  declare const sanitizeToken: (token: string) => string;
95
181
 
96
- export { CheckoutFormVariant, EventType, type FlintNConfig, FlintNPayment, type FlintNPaymentOptions, type FormFields, type FormStyles, type PaymentError, type PaymentResult, type TCheckoutFormVariant, type TEventType, buildIframeSrc, createIframeElement, parseOrigin, sanitizeToken, validateConfig };
182
+ export { CheckoutFormVariant, EventType, type FieldChangeEvent, FieldEventType, type FieldOptions, type FieldState, FieldType, type FieldValidationResult, type FieldsValidationResult, type FlintNConfig, type FlintNField, type FlintNFieldInternalCallbacks, type FlintNFields, type FlintNFieldsConfig, type FlintNFieldsOptions, type FlintNPayment, type FlintNPaymentOptions, type FormFields, type FormStyles, type PaymentError, type PaymentResult, type SubmitOptions, type TCheckoutFormVariant, type TEventType, type TFieldEventType, type TFieldType, buildIframeSrc, createFlintNField, createFlintNFields, createFlintNPayment, createIframeElement, parseOrigin, sanitizeToken, validateConfig };