flintn-checkout 0.0.12 → 0.0.14

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
@@ -10,7 +10,7 @@ npm install flintn-checkout
10
10
 
11
11
  ## Iframe Checkout
12
12
 
13
- Full checkout UI rendered inside a single iframe. Includes card form, express payments (Apple Pay, Google Pay, PayPal), and 3DS handling.
13
+ Full checkout UI rendered inside a single iframe. Includes card form, express payments (Apple Pay, PayPal), and 3DS handling.
14
14
 
15
15
  **React**
16
16
 
@@ -18,7 +18,7 @@ Full checkout UI rendered inside a single iframe. Includes card form, express pa
18
18
  import { useFlintNPayment } from 'flintn-checkout/react';
19
19
 
20
20
  function Checkout() {
21
- const { containerRef, isReady, paymentResult, attempts, error } = useFlintNPayment({
21
+ const { containerRef, isReady, paymentResult, events, error } = useFlintNPayment({
22
22
  config: {
23
23
  clientSessionId: 'your_client_session_id',
24
24
  },
@@ -31,8 +31,9 @@ function Checkout() {
31
31
  },
32
32
  onEvent: (event) => {
33
33
  // Per-attempt analytics — fires for every payment attempt outcome
34
- // (initiated, soft/hard decline, 3DS, cancel, network error, success).
35
- console.log('Attempt:', event.result, event.method, event.code);
34
+ // (initiated, soft/hard decline, 3DS, cancel, network error, success)
35
+ // and for UI navigation in the LIST and RADIO variants (form entered/exited).
36
+ console.log('Event:', event.type, event.event);
36
37
  },
37
38
  });
38
39
 
@@ -61,7 +62,7 @@ const payment = createFlintNPayment({
61
62
  }
62
63
  },
63
64
  onEvent: (event) => {
64
- console.log('Attempt:', event.result, event.method);
65
+ console.log('Event:', event.type, event.event);
65
66
  },
66
67
  onReady: () => {
67
68
  console.log('Widget ready');
@@ -97,7 +98,7 @@ payment.mount('#payment-container');
97
98
  console.log('Payment result:', result);
98
99
  },
99
100
  onEvent: (event) => {
100
- console.log('Attempt:', event);
101
+ console.log('Event:', event);
101
102
  },
102
103
  });
103
104
 
@@ -130,12 +131,19 @@ Fires when:
130
131
  Fires for **every payment attempt outcome**, including ones where the session continues. Use for funnel analytics, retry tracking, A/B test instrumentation, fraud signals.
131
132
 
132
133
  ```ts
133
- onEvent(event: PaymentAttempt)
134
+ onEvent(event: CheckoutEvent)
134
135
  ```
135
136
 
136
- The `result` discriminator describes what happened at this step:
137
+ `CheckoutEvent` is a union of two event kinds, discriminated by `type` (the `isAttemptEvent` / `isUIEvent` guards are also exported):
137
138
 
138
- | `result` | When | Terminal `onPayment` follows? |
139
+ - `PaymentAttempt` `type: 'PAYMENT_ATTEMPT_EVENT'`, a payment attempt outcome
140
+ - `PaymentUI` — `type: 'PAYMENT_UI_EVENT'`, card form entered/exited (LIST and RADIO variants)
141
+
142
+ Every event carries a `timestamp` (epoch ms) and the `clientSessionId`.
143
+
144
+ For attempt events, the `event` discriminator describes what happened at this step:
145
+
146
+ | `event` | When | Terminal `onPayment` follows? |
139
147
  |---|---|---|
140
148
  | `'INITIATED'` | Buyer clicked Pay / Apple Pay / PayPal and validation passed | — |
141
149
  | `'THREE_DS_INITIATED'` | Authorize returned `THREE_DS_INITIATED`; 3DS challenge is opening | — |
@@ -147,46 +155,61 @@ The `result` discriminator describes what happened at this step:
147
155
 
148
156
  A terminal `onPayment` event always fires *after* the corresponding `onEvent` for `AUTHORIZED` / `NETWORK_ERROR` / non-retryable declines / 3DS failures.
149
157
 
158
+ For UI events (LIST and RADIO variants), `view` is the view that became active:
159
+
160
+ | `event` | When | `view` |
161
+ |---|---|---|
162
+ | `'FORM_ENTERED'` | Buyer opened the card form ("Credit or Debit Card" button / "Card payment" radio) | `'CARD'` |
163
+ | `'FORM_EXITED'` | Buyer returned to express (back arrow / "Fast checkout" radio) | `'EXPRESS'` |
164
+
150
165
  **Example funnel — soft decline → retry success:**
151
166
 
152
167
  ```
153
- onEvent → { result: 'INITIATED', method: 'PAYMENT_CARD' }
154
- onEvent → { result: 'SOFT_DECLINE', method: 'PAYMENT_CARD', code: 'do_not_honor', message: 'Payment declined.' }
168
+ onEvent → { event: 'INITIATED', method: 'PAYMENT_CARD' }
169
+ onEvent → { event: 'SOFT_DECLINE', method: 'PAYMENT_CARD', code: 'do_not_honor', message: 'Payment declined.' }
155
170
  // buyer retries with another card
156
- onEvent → { result: 'INITIATED', method: 'PAYMENT_CARD' }
157
- onEvent → { result: 'AUTHORIZED', method: 'PAYMENT_CARD', paymentId: 'pay_...' }
171
+ onEvent → { event: 'INITIATED', method: 'PAYMENT_CARD' }
172
+ onEvent → { event: 'AUTHORIZED', method: 'PAYMENT_CARD', paymentId: 'pay_...' }
158
173
  onPayment → { status: 'PAYMENT_SUCCESS', data: 'pay_...' }
159
174
  ```
160
175
 
161
176
  **Example — Apple Pay buyer cancel (DEFAULT variant):**
162
177
 
163
178
  ```
164
- onEvent → { result: 'INITIATED', method: 'APPLE_PAY' }
165
- onEvent → { result: 'CANCELLED', method: 'APPLE_PAY', message: 'Buyer dismissed Apple Pay' }
179
+ onEvent → { event: 'INITIATED', method: 'APPLE_PAY' }
180
+ onEvent → { event: 'CANCELLED', method: 'APPLE_PAY', message: 'Buyer dismissed Apple Pay' }
166
181
  // no onPayment — session stays alive, buyer can pick another method
167
182
  ```
168
183
 
169
184
  **Example — PayPal popup → 3DS → success:**
170
185
 
171
186
  ```
172
- onEvent → { result: 'INITIATED', method: 'PAYPAL' }
173
- onEvent → { result: 'THREE_DS_INITIATED', method: 'PAYPAL', paymentId: 'pay_...' }
174
- onEvent → { result: 'AUTHORIZED', method: 'PAYPAL', paymentId: 'pay_...' }
187
+ onEvent → { event: 'INITIATED', method: 'PAYPAL' }
188
+ onEvent → { event: 'THREE_DS_INITIATED', method: 'PAYPAL', paymentId: 'pay_...' }
189
+ onEvent → { event: 'AUTHORIZED', method: 'PAYPAL', paymentId: 'pay_...' }
175
190
  onPayment → { status: 'PAYMENT_SUCCESS', data: 'pay_...' }
176
191
  ```
177
192
 
178
- ### `attempts` (React)accumulated log
193
+ (Every event also carries `type`, `timestamp`, and `clientSessionId` omitted above for brevity.)
194
+
195
+ ### `events` (React) — accumulated log
179
196
 
180
- The `useFlintNPayment` hook also exposes `attempts: PaymentAttempt[]` — every event since mount, useful for rendering a per-attempt UI without wiring `onEvent` manually:
197
+ The `useFlintNPayment` hook also exposes `events: CheckoutEvent[]` — every event since mount, useful for rendering a per-attempt UI without wiring `onEvent` manually:
181
198
 
182
199
  ```tsx
183
- const { attempts } = useFlintNPayment({ ... });
200
+ import { isAttemptEvent } from 'flintn-checkout';
201
+
202
+ const { events } = useFlintNPayment({ ... });
184
203
 
185
204
  return (
186
205
  <ul>
187
- {attempts.map((a, i) => (
188
- <li key={i}>[{a.method}] {a.result} {a.code && `— ${a.code}`}</li>
189
- ))}
206
+ {events.map((e, i) =>
207
+ isAttemptEvent(e) ? (
208
+ <li key={i}>[{e.method}] {e.event} {e.code && `— ${e.code}`}</li>
209
+ ) : (
210
+ <li key={i}>[UI] {e.event} → {e.view}</li>
211
+ ),
212
+ )}
190
213
  </ul>
191
214
  );
192
215
  ```
@@ -209,7 +232,7 @@ Do **not** set a fixed `height` on the container — it will leave empty space b
209
232
  |--------|------|----------|---------|-------------|
210
233
  | `config` | `FlintNConfig` | Yes | — | Checkout configuration |
211
234
  | `onPayment` | `(result: PaymentResult) => void` | No | — | Terminal session result (success / error) |
212
- | `onEvent` | `(event: PaymentAttempt) => void` | No | — | Per-attempt analytics signal |
235
+ | `onEvent` | `(event: CheckoutEvent) => void` | No | — | Per-attempt analytics signal |
213
236
  | `onReady` | `() => void` | No | — | Widget loaded and ready |
214
237
  | `onError` | `(error: PaymentError) => void` | No | — | SDK initialization error |
215
238
  | `debug` | `boolean` | No | `false` | Enable console debug logs |
@@ -219,7 +242,7 @@ Do **not** set a fixed `height` on the container — it will leave empty space b
219
242
  | Property | Type | Required | Description |
220
243
  |----------|------|----------|-------------|
221
244
  | `clientSessionId` | `string` | Yes | Client session ID from backend |
222
- | `formFields` | `FormFields` | No | Form field visibility and requirements |
245
+ | `formFields` | `FormFields` | No | Form display options — layout via `formVariant`. Field visibility and requirements are controlled by the merchant session configuration, not SDK options |
223
246
  | `styles` | `FormStyles` | No | Custom styles for the checkout form |
224
247
  | `successRedirectUrl` | `string` | No | Redirect URL after successful payment |
225
248
 
@@ -230,7 +253,7 @@ Do **not** set a fixed `height` on the container — it will leave empty space b
230
253
  | `containerRef` | `RefObject<HTMLDivElement>` | Ref to attach to container element |
231
254
  | `isReady` | `boolean` | Widget is loaded and ready |
232
255
  | `paymentResult` | `PaymentResult \| null` | Result after terminal `onPayment` event |
233
- | `attempts` | `PaymentAttempt[]` | Per-attempt event log (accumulated since mount) |
256
+ | `events` | `CheckoutEvent[]` | Per-attempt event log (accumulated since mount) |
234
257
  | `error` | `PaymentError \| null` | SDK error if any |
235
258
 
236
259
  ---
@@ -479,11 +502,18 @@ interface PaymentError {
479
502
  }
480
503
  ```
481
504
 
505
+ ### CheckoutEvent
506
+
507
+ ```typescript
508
+ type CheckoutEvent = PaymentAttempt | PaymentUI;
509
+ ```
510
+
482
511
  ### PaymentAttempt
483
512
 
484
513
  ```typescript
485
514
  interface PaymentAttempt {
486
- result:
515
+ type: 'PAYMENT_ATTEMPT_EVENT';
516
+ event:
487
517
  | 'INITIATED'
488
518
  | 'THREE_DS_INITIATED'
489
519
  | 'AUTHORIZED'
@@ -498,19 +528,37 @@ interface PaymentAttempt {
498
528
  | 'PAYPAL'
499
529
  | 'BANK_ACCOUNT'
500
530
  | 'OTHER';
501
- paymentId?: string; // Set when the backend has minted a payment id (auth response, 3DS, approve)
502
- code?: string; // Processor decline code or internal error code (FNT-EC-*, FORBIDDEN, PAYPAL_ERROR, THREE_DS_FAILED, …)
503
- message?: string; // Translated merchant-facing message for the code
531
+ paymentId?: string; // Set when the backend has minted a payment id (auth response, 3DS, approve)
532
+ code?: string; // Processor decline code or internal error code (FNT-EC-*, FORBIDDEN, PAYPAL_ERROR, THREE_DS_FAILED, …)
533
+ message?: string; // Translated merchant-facing message for the code
534
+ timestamp: number; // Epoch ms, stamped at emit time
535
+ clientSessionId?: string; // Session the event belongs to
536
+ }
537
+ ```
538
+
539
+ ### PaymentUI
540
+
541
+ ```typescript
542
+ interface PaymentUI {
543
+ type: 'PAYMENT_UI_EVENT';
544
+ event: 'FORM_ENTERED' | 'FORM_EXITED';
545
+ view: 'EXPRESS' | 'CARD'; // The view that became active
546
+ timestamp: number;
547
+ clientSessionId?: string;
504
548
  }
505
549
  ```
506
550
 
507
551
  Const-object accessors are also exported if you prefer typed comparisons over string literals:
508
552
 
509
553
  ```ts
510
- import { AttemptResult, PaymentMethod } from 'flintn-checkout';
554
+ import { PaymentAttemptResult, PaymentMethod, isAttemptEvent } from 'flintn-checkout';
511
555
 
512
556
  onEvent: (e) => {
513
- if (e.result === AttemptResult.SOFT_DECLINE && e.method === PaymentMethod.PAYMENT_CARD) {
557
+ if (
558
+ isAttemptEvent(e) &&
559
+ e.event === PaymentAttemptResult.SOFT_DECLINE &&
560
+ e.method === PaymentMethod.PAYMENT_CARD
561
+ ) {
514
562
  analytics.track('soft_decline_card', { code: e.code });
515
563
  }
516
564
  }
@@ -549,18 +597,22 @@ interface FieldsValidationResult {
549
597
  ### FormFields
550
598
  ```typescript
551
599
  interface FormFields {
552
- isEmailVisible?: boolean; // Primer only
553
- isCardholderNameRequired?: boolean; // Primer only
554
600
  formVariant?: 'DEFAULT' | 'LIST' | 'RADIO';
555
601
  }
556
602
  ```
557
603
 
604
+ > **Note:** form field visibility and requirements (e.g. email, cardholder
605
+ > name) are controlled by the merchant's session configuration, not by SDK
606
+ > options. Use `formVariant` to control the checkout layout.
607
+
558
608
  ### FormStyles
559
609
  ```typescript
560
610
  interface FormStyles {
561
611
  loaderColor?: string;
562
612
  backgroundColor?: string;
613
+ lightLogos?: boolean;
563
614
  expressButtonsSpacing?: string;
615
+ expressButtonsBorderRadius?: string;
564
616
  inputBackgroundColor?: string;
565
617
  inputBorderRadius?: string;
566
618
  inputBorderColor?: string;
@@ -568,6 +620,20 @@ interface FormStyles {
568
620
  inputBorderFocusColor?: string;
569
621
  inputBorderErrorColor?: string;
570
622
  errorMessageColor?: string;
623
+ labelColor?: string;
624
+ dividerColor?: string;
625
+ dividerTextColor?: string;
626
+ safeCheckoutAccentColor?: string;
627
+ safeCheckoutTextColor?: string;
628
+ radioOptionBorderColor?: string;
629
+ radioOptionBorderRadius?: string;
630
+ radioOptionBackgroundColor?: string;
631
+ radioOptionActiveBackgroundColor?: string;
632
+ radioOptionTitleColor?: string;
633
+ radioButtonColor?: string;
634
+ radioButtonActiveColor?: string;
635
+ fastCheckoutText?: string;
636
+ cardPaymentText?: string;
571
637
  buttonColor?: string;
572
638
  buttonHoverColor?: string;
573
639
  buttonBorderRadius?: string;
@@ -584,7 +650,9 @@ interface FormStyles {
584
650
  |----------|:-:|:-:|-------------|
585
651
  | `loaderColor` | ✅ | — | Loading spinner color |
586
652
  | `backgroundColor` | ✅ | — | Form background color |
653
+ | `lightLogos` | ✅ | — | Use light logo variants in the safe-checkout row (for dark backgrounds) |
587
654
  | `expressButtonsSpacing` | ✅ | — | Spacing between express payment buttons |
655
+ | `expressButtonsBorderRadius` | ✅ | — | Corner radius for express buttons — Apple Pay, Google Pay, PayPal, and the "Credit or debit card" button in the LIST variant (e.g. `8px`) |
588
656
  | `inputBackgroundColor` | ✅ | ✅ | Input field background color |
589
657
  | `inputBorderRadius` | ✅ | ✅ | Input field border radius |
590
658
  | `inputBorderColor` | ✅ | ✅ | Default input border color |
@@ -592,6 +660,20 @@ interface FormStyles {
592
660
  | `inputBorderFocusColor` | ✅ | ✅ | Input border color on focus |
593
661
  | `inputBorderErrorColor` | ✅ | ✅ | Input border color in error state |
594
662
  | `errorMessageColor` | ✅ | — | Error message text color |
663
+ | `labelColor` | ✅ | — | Field label text color |
664
+ | `dividerColor` | ✅ | — | Divider line color ("or" + "safe checkout" dividers) |
665
+ | `dividerTextColor` | ✅ | — | "or" divider text color |
666
+ | `safeCheckoutAccentColor` | ✅ | — | "Safe" accent word color (defaults to theme success) |
667
+ | `safeCheckoutTextColor` | ✅ | — | "Checkout" word color in the safe-checkout divider |
668
+ | `radioOptionBorderColor` | ✅ | — | Radio option card border color (RADIO variant) |
669
+ | `radioOptionBorderRadius` | ✅ | — | Radio option card border radius (RADIO variant) |
670
+ | `radioOptionBackgroundColor` | ✅ | — | Radio option card background, inactive (RADIO variant) |
671
+ | `radioOptionActiveBackgroundColor` | ✅ | — | Radio option card background, active (RADIO variant) |
672
+ | `radioOptionTitleColor` | ✅ | — | Radio option title text color (RADIO variant) |
673
+ | `radioButtonColor` | ✅ | — | Radio button color, unselected (RADIO variant) |
674
+ | `radioButtonActiveColor` | ✅ | — | Radio button color, selected (RADIO variant) |
675
+ | `fastCheckoutText` | ✅ | — | Custom "Fast checkout" option label (RADIO variant) |
676
+ | `cardPaymentText` | ✅ | — | Custom "Card payment" option label (RADIO variant) |
595
677
  | `buttonColor` | ✅ | — | Submit button background color |
596
678
  | `buttonHoverColor` | ✅ | — | Submit button hover color |
597
679
  | `buttonBorderRadius` | ✅ | — | Submit button border radius |
@@ -605,10 +687,10 @@ interface FormStyles {
605
687
  The iframe checkout supports three layout variants via `formFields.formVariant`:
606
688
 
607
689
  - **DEFAULT** — Express payment methods shown above the card form with dividers.
608
- - **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.
609
- - **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.
690
+ - **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. Toggling emits `FORM_ENTERED` / `FORM_EXITED` UI events.
691
+ - **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. Selecting a radio emits `FORM_ENTERED` / `FORM_EXITED` UI events.
610
692
 
611
- 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.
693
+ LIST and RADIO automatically fall back to the DEFAULT layout when no express payment methods are available, since there's nothing to toggle between (and no UI events fire). The `cardButtonColor`, `cardButtonHoverColor`, and `cardButtonText` style overrides apply only to the LIST variant's "Credit or Debit Card" button.
612
694
 
613
695
  ### Cancel-message behavior across variants
614
696
 
@@ -629,7 +711,6 @@ Every cancellation still emits a `CANCELLED` `onEvent` regardless of variant, so
629
711
  ### Iframe Checkout
630
712
  - Credit/Debit Cards (Visa, Mastercard, Amex, Discover)
631
713
  - Apple Pay
632
- - Google Pay
633
714
  - PayPal
634
715
 
635
716
  ### Hosted Fields
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  declare const EventType: {
2
2
  readonly WIDGET_READY: "WIDGET_READY";
3
3
  readonly WIDGET_CONFIG: "WIDGET_CONFIG";
4
- readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT";
4
+ readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT";
5
+ readonly PAYMENT_UI: "PAYMENT_UI_EVENT";
5
6
  readonly PAYMENT: "PAYMENT";
6
7
  readonly PAYMENT_SUCCESS: "PAYMENT_SUCCESS";
7
8
  readonly PAYMENT_ERROR: "PAYMENT_ERROR";
@@ -17,14 +18,14 @@ declare const CheckoutFormVariant: {
17
18
  };
18
19
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
19
20
  interface FormFields {
20
- isEmailVisible?: boolean;
21
- isCardholderNameRequired?: boolean;
22
21
  formVariant?: TCheckoutFormVariant;
23
22
  }
24
23
  interface FormStyles {
25
24
  loaderColor?: string;
26
25
  backgroundColor?: string;
26
+ lightLogos?: boolean;
27
27
  expressButtonsSpacing?: string;
28
+ expressButtonsBorderRadius?: string;
28
29
  inputBackgroundColor?: string;
29
30
  inputBorderRadius?: string;
30
31
  inputBorderColor?: string;
@@ -32,6 +33,20 @@ interface FormStyles {
32
33
  inputBorderFocusColor?: string;
33
34
  inputBorderErrorColor?: string;
34
35
  errorMessageColor?: string;
36
+ labelColor?: string;
37
+ dividerColor?: string;
38
+ dividerTextColor?: string;
39
+ safeCheckoutAccentColor?: string;
40
+ safeCheckoutTextColor?: string;
41
+ radioOptionBorderColor?: string;
42
+ radioOptionBorderRadius?: string;
43
+ radioOptionBackgroundColor?: string;
44
+ radioOptionActiveBackgroundColor?: string;
45
+ radioOptionTitleColor?: string;
46
+ radioButtonColor?: string;
47
+ radioButtonActiveColor?: string;
48
+ fastCheckoutText?: string;
49
+ cardPaymentText?: string;
35
50
  buttonColor?: string;
36
51
  buttonHoverColor?: string;
37
52
  buttonBorderRadius?: string;
@@ -55,7 +70,7 @@ declare const PaymentMethod: {
55
70
  readonly OTHER: "OTHER";
56
71
  };
57
72
  type TPaymentMethod = (typeof PaymentMethod)[keyof typeof PaymentMethod];
58
- declare const AttemptResult: {
73
+ declare const PaymentAttemptResult: {
59
74
  readonly INITIATED: "INITIATED";
60
75
  readonly THREE_DS_INITIATED: "THREE_DS_INITIATED";
61
76
  readonly AUTHORIZED: "AUTHORIZED";
@@ -64,14 +79,37 @@ declare const AttemptResult: {
64
79
  readonly CANCELLED: "CANCELLED";
65
80
  readonly NETWORK_ERROR: "NETWORK_ERROR";
66
81
  };
67
- type TAttemptResult = (typeof AttemptResult)[keyof typeof AttemptResult];
82
+ type TPaymentAttemptResult = (typeof PaymentAttemptResult)[keyof typeof PaymentAttemptResult];
83
+ declare const PaymentUIEvent: {
84
+ readonly FORM_ENTERED: "FORM_ENTERED";
85
+ readonly FORM_EXITED: "FORM_EXITED";
86
+ };
87
+ type TPaymentUIEvent = (typeof PaymentUIEvent)[keyof typeof PaymentUIEvent];
88
+ declare const CheckoutView: {
89
+ readonly EXPRESS: "EXPRESS";
90
+ readonly CARD: "CARD";
91
+ };
92
+ type TCheckoutView = (typeof CheckoutView)[keyof typeof CheckoutView];
68
93
  interface PaymentAttempt {
69
- result: TAttemptResult;
94
+ type: typeof EventType.PAYMENT_ATTEMPT;
95
+ event: TPaymentAttemptResult;
70
96
  method: TPaymentMethod;
71
97
  paymentId?: string;
72
98
  code?: string;
73
99
  message?: string;
100
+ timestamp: number;
101
+ clientSessionId?: string;
102
+ }
103
+ interface PaymentUI {
104
+ type: typeof EventType.PAYMENT_UI;
105
+ event: TPaymentUIEvent;
106
+ view: TCheckoutView;
107
+ timestamp: number;
108
+ clientSessionId?: string;
74
109
  }
110
+ type CheckoutEvent = PaymentAttempt | PaymentUI;
111
+ declare const isAttemptEvent: (e: CheckoutEvent) => e is PaymentAttempt;
112
+ declare const isUIEvent: (e: CheckoutEvent) => e is PaymentUI;
75
113
  interface PaymentResult {
76
114
  status: 'PAYMENT_SUCCESS' | 'PAYMENT_ERROR' | 'PAYMENT_CANCELLED';
77
115
  data?: string;
@@ -88,7 +126,7 @@ interface FlintNPaymentOptions {
88
126
  origin?: string;
89
127
  config: FlintNConfig;
90
128
  onPayment?: (result: PaymentResult) => void;
91
- onEvent?: (event: PaymentAttempt) => void;
129
+ onEvent?: (event: CheckoutEvent) => void;
92
130
  onReady?: () => void;
93
131
  onError?: (error: PaymentError) => void;
94
132
  debug?: boolean;
@@ -206,4 +244,4 @@ declare const validateConfig: (config: {
206
244
  }) => void;
207
245
  declare const sanitizeToken: (token: string) => string;
208
246
 
209
- export { AttemptResult, 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 PaymentAttempt, type PaymentError, PaymentMethod, type PaymentResult, type SubmitOptions, type TAttemptResult, type TCheckoutFormVariant, type TEventType, type TFieldEventType, type TFieldType, type TPaymentMethod, buildIframeSrc, createFlintNField, createFlintNFields, createFlintNPayment, createIframeElement, parseOrigin, sanitizeToken, validateConfig };
247
+ export { type CheckoutEvent, CheckoutFormVariant, CheckoutView, 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 PaymentAttempt, PaymentAttemptResult, type PaymentError, PaymentMethod, type PaymentResult, type PaymentUI, PaymentUIEvent, type SubmitOptions, type TCheckoutFormVariant, type TCheckoutView, type TEventType, type TFieldEventType, type TFieldType, type TPaymentAttemptResult, type TPaymentMethod, type TPaymentUIEvent, buildIframeSrc, createFlintNField, createFlintNFields, createFlintNPayment, createIframeElement, isAttemptEvent, isUIEvent, parseOrigin, sanitizeToken, validateConfig };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  declare const EventType: {
2
2
  readonly WIDGET_READY: "WIDGET_READY";
3
3
  readonly WIDGET_CONFIG: "WIDGET_CONFIG";
4
- readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT";
4
+ readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT";
5
+ readonly PAYMENT_UI: "PAYMENT_UI_EVENT";
5
6
  readonly PAYMENT: "PAYMENT";
6
7
  readonly PAYMENT_SUCCESS: "PAYMENT_SUCCESS";
7
8
  readonly PAYMENT_ERROR: "PAYMENT_ERROR";
@@ -17,14 +18,14 @@ declare const CheckoutFormVariant: {
17
18
  };
18
19
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
19
20
  interface FormFields {
20
- isEmailVisible?: boolean;
21
- isCardholderNameRequired?: boolean;
22
21
  formVariant?: TCheckoutFormVariant;
23
22
  }
24
23
  interface FormStyles {
25
24
  loaderColor?: string;
26
25
  backgroundColor?: string;
26
+ lightLogos?: boolean;
27
27
  expressButtonsSpacing?: string;
28
+ expressButtonsBorderRadius?: string;
28
29
  inputBackgroundColor?: string;
29
30
  inputBorderRadius?: string;
30
31
  inputBorderColor?: string;
@@ -32,6 +33,20 @@ interface FormStyles {
32
33
  inputBorderFocusColor?: string;
33
34
  inputBorderErrorColor?: string;
34
35
  errorMessageColor?: string;
36
+ labelColor?: string;
37
+ dividerColor?: string;
38
+ dividerTextColor?: string;
39
+ safeCheckoutAccentColor?: string;
40
+ safeCheckoutTextColor?: string;
41
+ radioOptionBorderColor?: string;
42
+ radioOptionBorderRadius?: string;
43
+ radioOptionBackgroundColor?: string;
44
+ radioOptionActiveBackgroundColor?: string;
45
+ radioOptionTitleColor?: string;
46
+ radioButtonColor?: string;
47
+ radioButtonActiveColor?: string;
48
+ fastCheckoutText?: string;
49
+ cardPaymentText?: string;
35
50
  buttonColor?: string;
36
51
  buttonHoverColor?: string;
37
52
  buttonBorderRadius?: string;
@@ -55,7 +70,7 @@ declare const PaymentMethod: {
55
70
  readonly OTHER: "OTHER";
56
71
  };
57
72
  type TPaymentMethod = (typeof PaymentMethod)[keyof typeof PaymentMethod];
58
- declare const AttemptResult: {
73
+ declare const PaymentAttemptResult: {
59
74
  readonly INITIATED: "INITIATED";
60
75
  readonly THREE_DS_INITIATED: "THREE_DS_INITIATED";
61
76
  readonly AUTHORIZED: "AUTHORIZED";
@@ -64,14 +79,37 @@ declare const AttemptResult: {
64
79
  readonly CANCELLED: "CANCELLED";
65
80
  readonly NETWORK_ERROR: "NETWORK_ERROR";
66
81
  };
67
- type TAttemptResult = (typeof AttemptResult)[keyof typeof AttemptResult];
82
+ type TPaymentAttemptResult = (typeof PaymentAttemptResult)[keyof typeof PaymentAttemptResult];
83
+ declare const PaymentUIEvent: {
84
+ readonly FORM_ENTERED: "FORM_ENTERED";
85
+ readonly FORM_EXITED: "FORM_EXITED";
86
+ };
87
+ type TPaymentUIEvent = (typeof PaymentUIEvent)[keyof typeof PaymentUIEvent];
88
+ declare const CheckoutView: {
89
+ readonly EXPRESS: "EXPRESS";
90
+ readonly CARD: "CARD";
91
+ };
92
+ type TCheckoutView = (typeof CheckoutView)[keyof typeof CheckoutView];
68
93
  interface PaymentAttempt {
69
- result: TAttemptResult;
94
+ type: typeof EventType.PAYMENT_ATTEMPT;
95
+ event: TPaymentAttemptResult;
70
96
  method: TPaymentMethod;
71
97
  paymentId?: string;
72
98
  code?: string;
73
99
  message?: string;
100
+ timestamp: number;
101
+ clientSessionId?: string;
102
+ }
103
+ interface PaymentUI {
104
+ type: typeof EventType.PAYMENT_UI;
105
+ event: TPaymentUIEvent;
106
+ view: TCheckoutView;
107
+ timestamp: number;
108
+ clientSessionId?: string;
74
109
  }
110
+ type CheckoutEvent = PaymentAttempt | PaymentUI;
111
+ declare const isAttemptEvent: (e: CheckoutEvent) => e is PaymentAttempt;
112
+ declare const isUIEvent: (e: CheckoutEvent) => e is PaymentUI;
75
113
  interface PaymentResult {
76
114
  status: 'PAYMENT_SUCCESS' | 'PAYMENT_ERROR' | 'PAYMENT_CANCELLED';
77
115
  data?: string;
@@ -88,7 +126,7 @@ interface FlintNPaymentOptions {
88
126
  origin?: string;
89
127
  config: FlintNConfig;
90
128
  onPayment?: (result: PaymentResult) => void;
91
- onEvent?: (event: PaymentAttempt) => void;
129
+ onEvent?: (event: CheckoutEvent) => void;
92
130
  onReady?: () => void;
93
131
  onError?: (error: PaymentError) => void;
94
132
  debug?: boolean;
@@ -206,4 +244,4 @@ declare const validateConfig: (config: {
206
244
  }) => void;
207
245
  declare const sanitizeToken: (token: string) => string;
208
246
 
209
- export { AttemptResult, 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 PaymentAttempt, type PaymentError, PaymentMethod, type PaymentResult, type SubmitOptions, type TAttemptResult, type TCheckoutFormVariant, type TEventType, type TFieldEventType, type TFieldType, type TPaymentMethod, buildIframeSrc, createFlintNField, createFlintNFields, createFlintNPayment, createIframeElement, parseOrigin, sanitizeToken, validateConfig };
247
+ export { type CheckoutEvent, CheckoutFormVariant, CheckoutView, 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 PaymentAttempt, PaymentAttemptResult, type PaymentError, PaymentMethod, type PaymentResult, type PaymentUI, PaymentUIEvent, type SubmitOptions, type TCheckoutFormVariant, type TCheckoutView, type TEventType, type TFieldEventType, type TFieldType, type TPaymentAttemptResult, type TPaymentMethod, type TPaymentUIEvent, buildIframeSrc, createFlintNField, createFlintNFields, createFlintNPayment, createIframeElement, isAttemptEvent, isUIEvent, parseOrigin, sanitizeToken, validateConfig };
package/dist/index.js CHANGED
@@ -20,17 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- AttemptResult: () => AttemptResult,
24
23
  CheckoutFormVariant: () => CheckoutFormVariant,
24
+ CheckoutView: () => CheckoutView,
25
25
  EventType: () => EventType,
26
26
  FieldEventType: () => FieldEventType,
27
27
  FieldType: () => FieldType,
28
+ PaymentAttemptResult: () => PaymentAttemptResult,
28
29
  PaymentMethod: () => PaymentMethod,
30
+ PaymentUIEvent: () => PaymentUIEvent,
29
31
  buildIframeSrc: () => buildIframeSrc,
30
32
  createFlintNField: () => createFlintNField,
31
33
  createFlintNFields: () => createFlintNFields,
32
34
  createFlintNPayment: () => createFlintNPayment,
33
35
  createIframeElement: () => createIframeElement,
36
+ isAttemptEvent: () => isAttemptEvent,
37
+ isUIEvent: () => isUIEvent,
34
38
  parseOrigin: () => parseOrigin,
35
39
  sanitizeToken: () => sanitizeToken,
36
40
  validateConfig: () => validateConfig
@@ -41,7 +45,8 @@ module.exports = __toCommonJS(index_exports);
41
45
  var EventType = {
42
46
  WIDGET_READY: "WIDGET_READY",
43
47
  WIDGET_CONFIG: "WIDGET_CONFIG",
44
- PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT",
48
+ PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT",
49
+ PAYMENT_UI: "PAYMENT_UI_EVENT",
45
50
  PAYMENT: "PAYMENT",
46
51
  PAYMENT_SUCCESS: "PAYMENT_SUCCESS",
47
52
  PAYMENT_ERROR: "PAYMENT_ERROR",
@@ -62,7 +67,7 @@ var PaymentMethod = {
62
67
  BANK_ACCOUNT: "BANK_ACCOUNT",
63
68
  OTHER: "OTHER"
64
69
  };
65
- var AttemptResult = {
70
+ var PaymentAttemptResult = {
66
71
  INITIATED: "INITIATED",
67
72
  THREE_DS_INITIATED: "THREE_DS_INITIATED",
68
73
  AUTHORIZED: "AUTHORIZED",
@@ -71,6 +76,16 @@ var AttemptResult = {
71
76
  CANCELLED: "CANCELLED",
72
77
  NETWORK_ERROR: "NETWORK_ERROR"
73
78
  };
79
+ var PaymentUIEvent = {
80
+ FORM_ENTERED: "FORM_ENTERED",
81
+ FORM_EXITED: "FORM_EXITED"
82
+ };
83
+ var CheckoutView = {
84
+ EXPRESS: "EXPRESS",
85
+ CARD: "CARD"
86
+ };
87
+ var isAttemptEvent = (e) => e.type === EventType.PAYMENT_ATTEMPT;
88
+ var isUIEvent = (e) => e.type === EventType.PAYMENT_UI;
74
89
  var FieldType = {
75
90
  CARD_NUMBER: "card-number",
76
91
  EXPIRY: "expiry",
@@ -204,7 +219,16 @@ function createFlintNPayment(options) {
204
219
  options.onReady?.();
205
220
  break;
206
221
  case EventType.PAYMENT_ATTEMPT:
207
- options.onEvent?.(payload);
222
+ options.onEvent?.({
223
+ type: EventType.PAYMENT_ATTEMPT,
224
+ ...payload
225
+ });
226
+ break;
227
+ case EventType.PAYMENT_UI:
228
+ options.onEvent?.({
229
+ type: EventType.PAYMENT_UI,
230
+ ...payload
231
+ });
208
232
  break;
209
233
  case EventType.PAYMENT:
210
234
  options.onPayment?.(payload);
@@ -651,17 +675,21 @@ function createFlintNFields(options) {
651
675
  }
652
676
  // Annotate the CommonJS export names for ESM import in node:
653
677
  0 && (module.exports = {
654
- AttemptResult,
655
678
  CheckoutFormVariant,
679
+ CheckoutView,
656
680
  EventType,
657
681
  FieldEventType,
658
682
  FieldType,
683
+ PaymentAttemptResult,
659
684
  PaymentMethod,
685
+ PaymentUIEvent,
660
686
  buildIframeSrc,
661
687
  createFlintNField,
662
688
  createFlintNFields,
663
689
  createFlintNPayment,
664
690
  createIframeElement,
691
+ isAttemptEvent,
692
+ isUIEvent,
665
693
  parseOrigin,
666
694
  sanitizeToken,
667
695
  validateConfig
package/dist/index.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  var EventType = {
3
3
  WIDGET_READY: "WIDGET_READY",
4
4
  WIDGET_CONFIG: "WIDGET_CONFIG",
5
- PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT",
5
+ PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT",
6
+ PAYMENT_UI: "PAYMENT_UI_EVENT",
6
7
  PAYMENT: "PAYMENT",
7
8
  PAYMENT_SUCCESS: "PAYMENT_SUCCESS",
8
9
  PAYMENT_ERROR: "PAYMENT_ERROR",
@@ -23,7 +24,7 @@ var PaymentMethod = {
23
24
  BANK_ACCOUNT: "BANK_ACCOUNT",
24
25
  OTHER: "OTHER"
25
26
  };
26
- var AttemptResult = {
27
+ var PaymentAttemptResult = {
27
28
  INITIATED: "INITIATED",
28
29
  THREE_DS_INITIATED: "THREE_DS_INITIATED",
29
30
  AUTHORIZED: "AUTHORIZED",
@@ -32,6 +33,16 @@ var AttemptResult = {
32
33
  CANCELLED: "CANCELLED",
33
34
  NETWORK_ERROR: "NETWORK_ERROR"
34
35
  };
36
+ var PaymentUIEvent = {
37
+ FORM_ENTERED: "FORM_ENTERED",
38
+ FORM_EXITED: "FORM_EXITED"
39
+ };
40
+ var CheckoutView = {
41
+ EXPRESS: "EXPRESS",
42
+ CARD: "CARD"
43
+ };
44
+ var isAttemptEvent = (e) => e.type === EventType.PAYMENT_ATTEMPT;
45
+ var isUIEvent = (e) => e.type === EventType.PAYMENT_UI;
35
46
  var FieldType = {
36
47
  CARD_NUMBER: "card-number",
37
48
  EXPIRY: "expiry",
@@ -165,7 +176,16 @@ function createFlintNPayment(options) {
165
176
  options.onReady?.();
166
177
  break;
167
178
  case EventType.PAYMENT_ATTEMPT:
168
- options.onEvent?.(payload);
179
+ options.onEvent?.({
180
+ type: EventType.PAYMENT_ATTEMPT,
181
+ ...payload
182
+ });
183
+ break;
184
+ case EventType.PAYMENT_UI:
185
+ options.onEvent?.({
186
+ type: EventType.PAYMENT_UI,
187
+ ...payload
188
+ });
169
189
  break;
170
190
  case EventType.PAYMENT:
171
191
  options.onPayment?.(payload);
@@ -611,17 +631,21 @@ function createFlintNFields(options) {
611
631
  return { createField, getField, validate, submit, unmount, getIsReady };
612
632
  }
613
633
  export {
614
- AttemptResult,
615
634
  CheckoutFormVariant,
635
+ CheckoutView,
616
636
  EventType,
617
637
  FieldEventType,
618
638
  FieldType,
639
+ PaymentAttemptResult,
619
640
  PaymentMethod,
641
+ PaymentUIEvent,
620
642
  buildIframeSrc,
621
643
  createFlintNField,
622
644
  createFlintNFields,
623
645
  createFlintNPayment,
624
646
  createIframeElement,
647
+ isAttemptEvent,
648
+ isUIEvent,
625
649
  parseOrigin,
626
650
  sanitizeToken,
627
651
  validateConfig
package/dist/react.d.mts CHANGED
@@ -1,3 +1,15 @@
1
+ declare const EventType: {
2
+ readonly WIDGET_READY: "WIDGET_READY";
3
+ readonly WIDGET_CONFIG: "WIDGET_CONFIG";
4
+ readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT";
5
+ readonly PAYMENT_UI: "PAYMENT_UI_EVENT";
6
+ readonly PAYMENT: "PAYMENT";
7
+ readonly PAYMENT_SUCCESS: "PAYMENT_SUCCESS";
8
+ readonly PAYMENT_ERROR: "PAYMENT_ERROR";
9
+ readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
10
+ readonly REDIRECT: "REDIRECT";
11
+ readonly RESIZE: "RESIZE";
12
+ };
1
13
  declare const CheckoutFormVariant: {
2
14
  readonly DEFAULT: "DEFAULT";
3
15
  readonly LIST: "LIST";
@@ -5,14 +17,14 @@ declare const CheckoutFormVariant: {
5
17
  };
6
18
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
7
19
  interface FormFields {
8
- isEmailVisible?: boolean;
9
- isCardholderNameRequired?: boolean;
10
20
  formVariant?: TCheckoutFormVariant;
11
21
  }
12
22
  interface FormStyles {
13
23
  loaderColor?: string;
14
24
  backgroundColor?: string;
25
+ lightLogos?: boolean;
15
26
  expressButtonsSpacing?: string;
27
+ expressButtonsBorderRadius?: string;
16
28
  inputBackgroundColor?: string;
17
29
  inputBorderRadius?: string;
18
30
  inputBorderColor?: string;
@@ -20,6 +32,20 @@ interface FormStyles {
20
32
  inputBorderFocusColor?: string;
21
33
  inputBorderErrorColor?: string;
22
34
  errorMessageColor?: string;
35
+ labelColor?: string;
36
+ dividerColor?: string;
37
+ dividerTextColor?: string;
38
+ safeCheckoutAccentColor?: string;
39
+ safeCheckoutTextColor?: string;
40
+ radioOptionBorderColor?: string;
41
+ radioOptionBorderRadius?: string;
42
+ radioOptionBackgroundColor?: string;
43
+ radioOptionActiveBackgroundColor?: string;
44
+ radioOptionTitleColor?: string;
45
+ radioButtonColor?: string;
46
+ radioButtonActiveColor?: string;
47
+ fastCheckoutText?: string;
48
+ cardPaymentText?: string;
23
49
  buttonColor?: string;
24
50
  buttonHoverColor?: string;
25
51
  buttonBorderRadius?: string;
@@ -43,7 +69,7 @@ declare const PaymentMethod: {
43
69
  readonly OTHER: "OTHER";
44
70
  };
45
71
  type TPaymentMethod = (typeof PaymentMethod)[keyof typeof PaymentMethod];
46
- declare const AttemptResult: {
72
+ declare const PaymentAttemptResult: {
47
73
  readonly INITIATED: "INITIATED";
48
74
  readonly THREE_DS_INITIATED: "THREE_DS_INITIATED";
49
75
  readonly AUTHORIZED: "AUTHORIZED";
@@ -52,14 +78,35 @@ declare const AttemptResult: {
52
78
  readonly CANCELLED: "CANCELLED";
53
79
  readonly NETWORK_ERROR: "NETWORK_ERROR";
54
80
  };
55
- type TAttemptResult = (typeof AttemptResult)[keyof typeof AttemptResult];
81
+ type TPaymentAttemptResult = (typeof PaymentAttemptResult)[keyof typeof PaymentAttemptResult];
82
+ declare const PaymentUIEvent: {
83
+ readonly FORM_ENTERED: "FORM_ENTERED";
84
+ readonly FORM_EXITED: "FORM_EXITED";
85
+ };
86
+ type TPaymentUIEvent = (typeof PaymentUIEvent)[keyof typeof PaymentUIEvent];
87
+ declare const CheckoutView: {
88
+ readonly EXPRESS: "EXPRESS";
89
+ readonly CARD: "CARD";
90
+ };
91
+ type TCheckoutView = (typeof CheckoutView)[keyof typeof CheckoutView];
56
92
  interface PaymentAttempt {
57
- result: TAttemptResult;
93
+ type: typeof EventType.PAYMENT_ATTEMPT;
94
+ event: TPaymentAttemptResult;
58
95
  method: TPaymentMethod;
59
96
  paymentId?: string;
60
97
  code?: string;
61
98
  message?: string;
99
+ timestamp: number;
100
+ clientSessionId?: string;
101
+ }
102
+ interface PaymentUI {
103
+ type: typeof EventType.PAYMENT_UI;
104
+ event: TPaymentUIEvent;
105
+ view: TCheckoutView;
106
+ timestamp: number;
107
+ clientSessionId?: string;
62
108
  }
109
+ type CheckoutEvent = PaymentAttempt | PaymentUI;
63
110
  interface PaymentResult {
64
111
  status: 'PAYMENT_SUCCESS' | 'PAYMENT_ERROR' | 'PAYMENT_CANCELLED';
65
112
  data?: string;
@@ -76,7 +123,7 @@ interface FlintNPaymentOptions {
76
123
  origin?: string;
77
124
  config: FlintNConfig;
78
125
  onPayment?: (result: PaymentResult) => void;
79
- onEvent?: (event: PaymentAttempt) => void;
126
+ onEvent?: (event: CheckoutEvent) => void;
80
127
  onReady?: () => void;
81
128
  onError?: (error: PaymentError) => void;
82
129
  debug?: boolean;
@@ -134,7 +181,7 @@ interface UseFlintNPaymentReturn {
134
181
  containerRef: React.RefObject<HTMLDivElement | null>;
135
182
  isReady: boolean;
136
183
  paymentResult: PaymentResult | null;
137
- attempts: Array<PaymentAttempt>;
184
+ events: Array<CheckoutEvent>;
138
185
  error: PaymentError | null;
139
186
  }
140
187
  declare function useFlintNPayment(options: UseFlintNPaymentOptions): UseFlintNPaymentReturn;
package/dist/react.d.ts CHANGED
@@ -1,3 +1,15 @@
1
+ declare const EventType: {
2
+ readonly WIDGET_READY: "WIDGET_READY";
3
+ readonly WIDGET_CONFIG: "WIDGET_CONFIG";
4
+ readonly PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT";
5
+ readonly PAYMENT_UI: "PAYMENT_UI_EVENT";
6
+ readonly PAYMENT: "PAYMENT";
7
+ readonly PAYMENT_SUCCESS: "PAYMENT_SUCCESS";
8
+ readonly PAYMENT_ERROR: "PAYMENT_ERROR";
9
+ readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
10
+ readonly REDIRECT: "REDIRECT";
11
+ readonly RESIZE: "RESIZE";
12
+ };
1
13
  declare const CheckoutFormVariant: {
2
14
  readonly DEFAULT: "DEFAULT";
3
15
  readonly LIST: "LIST";
@@ -5,14 +17,14 @@ declare const CheckoutFormVariant: {
5
17
  };
6
18
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
7
19
  interface FormFields {
8
- isEmailVisible?: boolean;
9
- isCardholderNameRequired?: boolean;
10
20
  formVariant?: TCheckoutFormVariant;
11
21
  }
12
22
  interface FormStyles {
13
23
  loaderColor?: string;
14
24
  backgroundColor?: string;
25
+ lightLogos?: boolean;
15
26
  expressButtonsSpacing?: string;
27
+ expressButtonsBorderRadius?: string;
16
28
  inputBackgroundColor?: string;
17
29
  inputBorderRadius?: string;
18
30
  inputBorderColor?: string;
@@ -20,6 +32,20 @@ interface FormStyles {
20
32
  inputBorderFocusColor?: string;
21
33
  inputBorderErrorColor?: string;
22
34
  errorMessageColor?: string;
35
+ labelColor?: string;
36
+ dividerColor?: string;
37
+ dividerTextColor?: string;
38
+ safeCheckoutAccentColor?: string;
39
+ safeCheckoutTextColor?: string;
40
+ radioOptionBorderColor?: string;
41
+ radioOptionBorderRadius?: string;
42
+ radioOptionBackgroundColor?: string;
43
+ radioOptionActiveBackgroundColor?: string;
44
+ radioOptionTitleColor?: string;
45
+ radioButtonColor?: string;
46
+ radioButtonActiveColor?: string;
47
+ fastCheckoutText?: string;
48
+ cardPaymentText?: string;
23
49
  buttonColor?: string;
24
50
  buttonHoverColor?: string;
25
51
  buttonBorderRadius?: string;
@@ -43,7 +69,7 @@ declare const PaymentMethod: {
43
69
  readonly OTHER: "OTHER";
44
70
  };
45
71
  type TPaymentMethod = (typeof PaymentMethod)[keyof typeof PaymentMethod];
46
- declare const AttemptResult: {
72
+ declare const PaymentAttemptResult: {
47
73
  readonly INITIATED: "INITIATED";
48
74
  readonly THREE_DS_INITIATED: "THREE_DS_INITIATED";
49
75
  readonly AUTHORIZED: "AUTHORIZED";
@@ -52,14 +78,35 @@ declare const AttemptResult: {
52
78
  readonly CANCELLED: "CANCELLED";
53
79
  readonly NETWORK_ERROR: "NETWORK_ERROR";
54
80
  };
55
- type TAttemptResult = (typeof AttemptResult)[keyof typeof AttemptResult];
81
+ type TPaymentAttemptResult = (typeof PaymentAttemptResult)[keyof typeof PaymentAttemptResult];
82
+ declare const PaymentUIEvent: {
83
+ readonly FORM_ENTERED: "FORM_ENTERED";
84
+ readonly FORM_EXITED: "FORM_EXITED";
85
+ };
86
+ type TPaymentUIEvent = (typeof PaymentUIEvent)[keyof typeof PaymentUIEvent];
87
+ declare const CheckoutView: {
88
+ readonly EXPRESS: "EXPRESS";
89
+ readonly CARD: "CARD";
90
+ };
91
+ type TCheckoutView = (typeof CheckoutView)[keyof typeof CheckoutView];
56
92
  interface PaymentAttempt {
57
- result: TAttemptResult;
93
+ type: typeof EventType.PAYMENT_ATTEMPT;
94
+ event: TPaymentAttemptResult;
58
95
  method: TPaymentMethod;
59
96
  paymentId?: string;
60
97
  code?: string;
61
98
  message?: string;
99
+ timestamp: number;
100
+ clientSessionId?: string;
101
+ }
102
+ interface PaymentUI {
103
+ type: typeof EventType.PAYMENT_UI;
104
+ event: TPaymentUIEvent;
105
+ view: TCheckoutView;
106
+ timestamp: number;
107
+ clientSessionId?: string;
62
108
  }
109
+ type CheckoutEvent = PaymentAttempt | PaymentUI;
63
110
  interface PaymentResult {
64
111
  status: 'PAYMENT_SUCCESS' | 'PAYMENT_ERROR' | 'PAYMENT_CANCELLED';
65
112
  data?: string;
@@ -76,7 +123,7 @@ interface FlintNPaymentOptions {
76
123
  origin?: string;
77
124
  config: FlintNConfig;
78
125
  onPayment?: (result: PaymentResult) => void;
79
- onEvent?: (event: PaymentAttempt) => void;
126
+ onEvent?: (event: CheckoutEvent) => void;
80
127
  onReady?: () => void;
81
128
  onError?: (error: PaymentError) => void;
82
129
  debug?: boolean;
@@ -134,7 +181,7 @@ interface UseFlintNPaymentReturn {
134
181
  containerRef: React.RefObject<HTMLDivElement | null>;
135
182
  isReady: boolean;
136
183
  paymentResult: PaymentResult | null;
137
- attempts: Array<PaymentAttempt>;
184
+ events: Array<CheckoutEvent>;
138
185
  error: PaymentError | null;
139
186
  }
140
187
  declare function useFlintNPayment(options: UseFlintNPaymentOptions): UseFlintNPaymentReturn;
package/dist/react.js CHANGED
@@ -32,7 +32,8 @@ var import_react = require("react");
32
32
  var EventType = {
33
33
  WIDGET_READY: "WIDGET_READY",
34
34
  WIDGET_CONFIG: "WIDGET_CONFIG",
35
- PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT",
35
+ PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT",
36
+ PAYMENT_UI: "PAYMENT_UI_EVENT",
36
37
  PAYMENT: "PAYMENT",
37
38
  PAYMENT_SUCCESS: "PAYMENT_SUCCESS",
38
39
  PAYMENT_ERROR: "PAYMENT_ERROR",
@@ -173,7 +174,16 @@ function createFlintNPayment(options) {
173
174
  options.onReady?.();
174
175
  break;
175
176
  case EventType.PAYMENT_ATTEMPT:
176
- options.onEvent?.(payload);
177
+ options.onEvent?.({
178
+ type: EventType.PAYMENT_ATTEMPT,
179
+ ...payload
180
+ });
181
+ break;
182
+ case EventType.PAYMENT_UI:
183
+ options.onEvent?.({
184
+ type: EventType.PAYMENT_UI,
185
+ ...payload
186
+ });
177
187
  break;
178
188
  case EventType.PAYMENT:
179
189
  options.onPayment?.(payload);
@@ -233,7 +243,7 @@ function useFlintNPayment(options) {
233
243
  const onEventRef = (0, import_react.useRef)(options.onEvent);
234
244
  const [isReady, setIsReady] = (0, import_react.useState)(false);
235
245
  const [paymentResult, setPaymentResult] = (0, import_react.useState)(null);
236
- const [attempts, setAttempts] = (0, import_react.useState)([]);
246
+ const [events, setEvents] = (0, import_react.useState)([]);
237
247
  const [error, setError] = (0, import_react.useState)(null);
238
248
  (0, import_react.useEffect)(() => {
239
249
  onPaymentRef.current = options.onPayment;
@@ -243,7 +253,7 @@ function useFlintNPayment(options) {
243
253
  if (!containerRef.current) return;
244
254
  setIsReady(false);
245
255
  setPaymentResult(null);
246
- setAttempts([]);
256
+ setEvents([]);
247
257
  setError(null);
248
258
  paymentRef.current = createFlintNPayment({
249
259
  ...options,
@@ -253,7 +263,7 @@ function useFlintNPayment(options) {
253
263
  onPaymentRef.current?.(result);
254
264
  },
255
265
  onEvent: (event) => {
256
- setAttempts((prev) => [...prev, event]);
266
+ setEvents((prev) => [...prev, event]);
257
267
  onEventRef.current?.(event);
258
268
  },
259
269
  onError: (err) => setError(err)
@@ -275,7 +285,7 @@ function useFlintNPayment(options) {
275
285
  containerRef,
276
286
  isReady,
277
287
  paymentResult,
278
- attempts,
288
+ events,
279
289
  error
280
290
  };
281
291
  }
package/dist/react.mjs CHANGED
@@ -5,7 +5,8 @@ import { useEffect, useRef, useState } from "react";
5
5
  var EventType = {
6
6
  WIDGET_READY: "WIDGET_READY",
7
7
  WIDGET_CONFIG: "WIDGET_CONFIG",
8
- PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT",
8
+ PAYMENT_ATTEMPT: "PAYMENT_ATTEMPT_EVENT",
9
+ PAYMENT_UI: "PAYMENT_UI_EVENT",
9
10
  PAYMENT: "PAYMENT",
10
11
  PAYMENT_SUCCESS: "PAYMENT_SUCCESS",
11
12
  PAYMENT_ERROR: "PAYMENT_ERROR",
@@ -146,7 +147,16 @@ function createFlintNPayment(options) {
146
147
  options.onReady?.();
147
148
  break;
148
149
  case EventType.PAYMENT_ATTEMPT:
149
- options.onEvent?.(payload);
150
+ options.onEvent?.({
151
+ type: EventType.PAYMENT_ATTEMPT,
152
+ ...payload
153
+ });
154
+ break;
155
+ case EventType.PAYMENT_UI:
156
+ options.onEvent?.({
157
+ type: EventType.PAYMENT_UI,
158
+ ...payload
159
+ });
150
160
  break;
151
161
  case EventType.PAYMENT:
152
162
  options.onPayment?.(payload);
@@ -206,7 +216,7 @@ function useFlintNPayment(options) {
206
216
  const onEventRef = useRef(options.onEvent);
207
217
  const [isReady, setIsReady] = useState(false);
208
218
  const [paymentResult, setPaymentResult] = useState(null);
209
- const [attempts, setAttempts] = useState([]);
219
+ const [events, setEvents] = useState([]);
210
220
  const [error, setError] = useState(null);
211
221
  useEffect(() => {
212
222
  onPaymentRef.current = options.onPayment;
@@ -216,7 +226,7 @@ function useFlintNPayment(options) {
216
226
  if (!containerRef.current) return;
217
227
  setIsReady(false);
218
228
  setPaymentResult(null);
219
- setAttempts([]);
229
+ setEvents([]);
220
230
  setError(null);
221
231
  paymentRef.current = createFlintNPayment({
222
232
  ...options,
@@ -226,7 +236,7 @@ function useFlintNPayment(options) {
226
236
  onPaymentRef.current?.(result);
227
237
  },
228
238
  onEvent: (event) => {
229
- setAttempts((prev) => [...prev, event]);
239
+ setEvents((prev) => [...prev, event]);
230
240
  onEventRef.current?.(event);
231
241
  },
232
242
  onError: (err) => setError(err)
@@ -248,7 +258,7 @@ function useFlintNPayment(options) {
248
258
  containerRef,
249
259
  isReady,
250
260
  paymentResult,
251
- attempts,
261
+ events,
252
262
  error
253
263
  };
254
264
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flintn-checkout",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "FlintN Payment SDK — drop-in iframe checkout for card payments and wallets with localization and theming.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",