@chargehive/types 2.5.0 → 2.6.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/chargehive.d.ts +9 -2
- package/package.json +1 -1
- package/validation.d.ts +15 -4
package/chargehive.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
PCIBridgeTokenizeEphemeralResponse,
|
|
5
5
|
PCIBridgeTokenizeResponse,
|
|
6
6
|
} from '@pci-bridge/types/pcibridge';
|
|
7
|
-
import {
|
|
7
|
+
import {Validation, ValidationEventData} from './validation';
|
|
8
8
|
import {Address, Person} from './address';
|
|
9
9
|
|
|
10
10
|
type EmptyObject = Record<string, never>;
|
|
@@ -47,7 +47,11 @@ export interface ChargeHiveType extends ChargeType, ChargeHiveEventTarget
|
|
|
47
47
|
|
|
48
48
|
getInitResponse(): InitResponse | undefined;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
addValidator(fn: Validator): void;
|
|
51
|
+
|
|
52
|
+
assertValid(): Promise<void>;
|
|
53
|
+
|
|
54
|
+
validate(field?: FieldName, timeout?: number): Promise<Map<FieldName, Validation>>;
|
|
51
55
|
|
|
52
56
|
tokenize(): Promise<TokenizeResponse>;
|
|
53
57
|
|
|
@@ -286,6 +290,7 @@ export type EventName = PCIBEventName
|
|
|
286
290
|
| 'method-type-changed'
|
|
287
291
|
| 'charge-id'
|
|
288
292
|
| 'capability'
|
|
293
|
+
| 'validation'
|
|
289
294
|
| 'google-pay-ready';
|
|
290
295
|
|
|
291
296
|
export type ChargeHiveEvent<T extends EventName = EventName> = {
|
|
@@ -320,6 +325,8 @@ export type ChargeHiveEventData = {
|
|
|
320
325
|
readonly 'tokenize-ephemeral': unknown;
|
|
321
326
|
readonly 'field-validation': unknown;
|
|
322
327
|
readonly 'field-changed': unknown;
|
|
328
|
+
|
|
329
|
+
readonly 'validation': ValidationEventData;
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
export type ChargehiveTokenEvent = TokenizeResponse
|
package/package.json
CHANGED
package/validation.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FieldValidation as PCIBFieldValidation,
|
|
3
|
-
CardFieldValidation as PCIBCardFieldValidation,
|
|
3
|
+
CardFieldValidation as PCIBCardFieldValidation, ValidationState,
|
|
4
4
|
} from '@pci-bridge/types/validation';
|
|
5
|
+
import {FieldName} from './chargehive';
|
|
5
6
|
|
|
6
|
-
export type
|
|
7
|
+
export type ValidationEventData = Map<FieldName, Validation>;
|
|
7
8
|
|
|
8
|
-
export type
|
|
9
|
+
export type Validator = () => Promise<Validations>;
|
|
9
10
|
|
|
10
|
-
export type
|
|
11
|
+
export type Validation = {
|
|
12
|
+
isValid: boolean;
|
|
13
|
+
isPotentiallyValid: boolean;
|
|
14
|
+
validationState: ValidationState;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type FieldValidation = Validation & PCIBFieldValidation
|
|
18
|
+
|
|
19
|
+
export type CardFieldValidation = Validation & PCIBCardFieldValidation
|
|
20
|
+
|
|
21
|
+
export type ValidationEvent = CustomEvent<ValidationEventData>;
|