flintn-checkout 0.0.7 → 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/dist/index.d.ts CHANGED
@@ -7,11 +7,13 @@ declare const EventType: {
7
7
  readonly PAYMENT_ERROR: "PAYMENT_ERROR";
8
8
  readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
9
9
  readonly REDIRECT: "REDIRECT";
10
+ readonly RESIZE: "RESIZE";
10
11
  };
11
12
  type TEventType = (typeof EventType)[keyof typeof EventType];
12
13
  declare const CheckoutFormVariant: {
13
14
  readonly DEFAULT: "DEFAULT";
14
15
  readonly LIST: "LIST";
16
+ readonly RADIO: "RADIO";
15
17
  };
16
18
  type TCheckoutFormVariant = (typeof CheckoutFormVariant)[keyof typeof CheckoutFormVariant];
17
19
  interface FormFields {
@@ -65,24 +67,109 @@ interface FlintNPaymentOptions {
65
67
  onError?: (error: PaymentError) => void;
66
68
  debug?: boolean;
67
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
+ }
68
136
 
69
- declare class FlintNPayment {
70
- private options;
71
- private origin;
72
- private iframe;
73
- private container;
74
- private isReady;
75
- private messageHandler;
76
- constructor(options: FlintNPaymentOptions);
137
+ interface FlintNPayment {
77
138
  mount(selector: string | HTMLElement): void;
78
139
  unmount(): void;
79
140
  getIsReady(): boolean;
80
- private handleMessage;
81
- private isValidRedirectUrl;
82
- private handlePaymentResult;
83
- private sendConfig;
84
- private log;
85
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;
86
173
 
87
174
  declare const parseOrigin: (origin: string) => string;
88
175
  declare const buildIframeSrc: (origin: string) => string;
@@ -92,4 +179,4 @@ declare const validateConfig: (config: {
92
179
  }) => void;
93
180
  declare const sanitizeToken: (token: string) => string;
94
181
 
95
- 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 };