@chargehive/types 2.4.16 → 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 +104 -75
- 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>;
|
|
@@ -12,7 +12,7 @@ type EmptyObject = Record<string, never>;
|
|
|
12
12
|
declare global
|
|
13
13
|
{
|
|
14
14
|
// noinspection ES6ConvertVarToLetConst
|
|
15
|
-
var ChargeHive: ChargeHiveType;
|
|
15
|
+
var ChargeHive: ChargeHiveType;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
declare type FieldName = PCIBFieldName;
|
|
@@ -29,7 +29,7 @@ export interface ChargeHiveEventTarget extends Omit<EventTarget, 'dispatchEvent'
|
|
|
29
29
|
options?: EventListenerOptions | boolean,
|
|
30
30
|
): void;
|
|
31
31
|
|
|
32
|
-
triggerEvent<E extends
|
|
32
|
+
triggerEvent<E extends EventName>(type: E, data?: ChargeHiveEventData[E]): void;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface ChargeHiveType extends ChargeType, ChargeHiveEventTarget
|
|
@@ -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
|
|
|
@@ -124,7 +128,7 @@ export interface InitResponse
|
|
|
124
128
|
capabilities: PaymentMethodType[];
|
|
125
129
|
defaultPaymentType: PaymentMethodType;
|
|
126
130
|
walletOptions: WalletOptionsResponse;
|
|
127
|
-
riskCheckers: { [key: string]: RiskChecker };
|
|
131
|
+
riskCheckers: { [key: string]: RiskChecker; };
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
export type RiskChecker = {
|
|
@@ -142,63 +146,65 @@ export type PaymentMethodType =
|
|
|
142
146
|
export type PaymentMethodDataTypes = {
|
|
143
147
|
PLACEMENT_CAPABILITY_TOKEN: {
|
|
144
148
|
token: string;
|
|
145
|
-
}
|
|
146
|
-
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeResponse
|
|
147
|
-
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
149
|
+
};
|
|
150
|
+
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeResponse;
|
|
151
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject;
|
|
148
152
|
PLACEMENT_CAPABILITY_APPLE_PAY:
|
|
149
|
-
{ token: ApplePayJS.ApplePayPaymentToken } |
|
|
153
|
+
{ token: ApplePayJS.ApplePayPaymentToken; } |
|
|
150
154
|
{
|
|
151
155
|
initiativeContext: string;
|
|
152
156
|
sessionUrl: string;
|
|
153
|
-
}
|
|
154
|
-
PLACEMENT_CAPABILITY_GOOGLE_PAY: google.payments.api.PaymentData
|
|
157
|
+
};
|
|
158
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: google.payments.api.PaymentData;
|
|
155
159
|
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: {
|
|
156
160
|
accountName: string;
|
|
157
161
|
accountNum: string;
|
|
158
162
|
sortCode: string;
|
|
159
163
|
payerReference: string;
|
|
160
|
-
}
|
|
164
|
+
};
|
|
161
165
|
};
|
|
162
166
|
|
|
163
167
|
export type PaymentMethodEphemeralDataTypes = {
|
|
164
|
-
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
165
|
-
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeEphemeralResponse
|
|
166
|
-
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
167
|
-
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject
|
|
168
|
-
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject
|
|
169
|
-
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
168
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject;
|
|
169
|
+
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeEphemeralResponse;
|
|
170
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject;
|
|
171
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject;
|
|
172
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject;
|
|
173
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject;
|
|
170
174
|
};
|
|
171
175
|
|
|
172
176
|
export type PaymentMethodEphemeralTokenizationConfig = {
|
|
173
|
-
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
174
|
-
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject
|
|
175
|
-
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
176
|
-
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject
|
|
177
|
-
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject
|
|
178
|
-
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
177
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject;
|
|
178
|
+
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject;
|
|
179
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject;
|
|
180
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject;
|
|
181
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject;
|
|
182
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject;
|
|
179
183
|
};
|
|
180
184
|
|
|
181
185
|
export type PaymentMethodTokenizationConfig = {
|
|
182
|
-
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
183
|
-
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
184
|
-
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject
|
|
186
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject;
|
|
187
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject;
|
|
188
|
+
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject;
|
|
185
189
|
PLACEMENT_CAPABILITY_APPLE_PAY: {
|
|
186
190
|
Session?: string;
|
|
187
191
|
InitiativeContext?: string;
|
|
188
192
|
SessionUrl?: string;
|
|
189
|
-
}
|
|
193
|
+
};
|
|
190
194
|
PLACEMENT_CAPABILITY_GOOGLE_PAY: {
|
|
191
195
|
environment?: string;
|
|
192
196
|
googlePayConfig?: google.payments.api.PaymentDataRequest | string;
|
|
193
197
|
token?: string;
|
|
194
|
-
}
|
|
195
|
-
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
198
|
+
};
|
|
199
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject;
|
|
196
200
|
}
|
|
197
201
|
|
|
198
202
|
export type PaymentMethodAuthenticationTypes = {
|
|
199
203
|
cvv: string;
|
|
200
204
|
}
|
|
201
205
|
|
|
206
|
+
export type ChallengeWindowSize = '01' | '02' | '03' | '04' | '05';
|
|
207
|
+
|
|
202
208
|
export type ChargeEnvironment =
|
|
203
209
|
| 'CHARGE_ENVIRONMENT_RETAIL'
|
|
204
210
|
| 'CHARGE_ENVIRONMENT_ECOMMERCE'
|
|
@@ -223,7 +229,7 @@ export interface ChargeData
|
|
|
223
229
|
language?: string;
|
|
224
230
|
meta?: ChargeMeta;
|
|
225
231
|
connectorId?: string;
|
|
226
|
-
challengeWindowSize?:
|
|
232
|
+
challengeWindowSize?: ChallengeWindowSize;
|
|
227
233
|
}
|
|
228
234
|
|
|
229
235
|
export interface ChargeType
|
|
@@ -251,24 +257,24 @@ export interface ChargeType
|
|
|
251
257
|
|
|
252
258
|
export interface OrderItem
|
|
253
259
|
{
|
|
254
|
-
subscriptionId
|
|
255
|
-
renewalNumber
|
|
256
|
-
duration
|
|
257
|
-
startDate
|
|
258
|
-
endDate
|
|
259
|
-
productType
|
|
260
|
-
skuType
|
|
261
|
-
deliveryType
|
|
260
|
+
subscriptionId?: string;
|
|
261
|
+
renewalNumber?: number;
|
|
262
|
+
duration?: number;
|
|
263
|
+
startDate?: number;
|
|
264
|
+
endDate?: number;
|
|
265
|
+
productType?: number;
|
|
266
|
+
skuType?: number;
|
|
267
|
+
deliveryType?: number;
|
|
262
268
|
quantity?: number;
|
|
263
269
|
unitPrice: number;
|
|
264
270
|
taxAmount?: number;
|
|
265
271
|
discountAmount?: number;
|
|
266
272
|
name: string;
|
|
267
|
-
description
|
|
268
|
-
productCode
|
|
269
|
-
skuCode
|
|
270
|
-
termType
|
|
271
|
-
termUnits
|
|
273
|
+
description?: string;
|
|
274
|
+
productCode?: string;
|
|
275
|
+
skuCode?: string;
|
|
276
|
+
termType?: number;
|
|
277
|
+
termUnits?: number;
|
|
272
278
|
}
|
|
273
279
|
|
|
274
280
|
export type EventName = PCIBEventName
|
|
@@ -281,36 +287,46 @@ export type EventName = PCIBEventName
|
|
|
281
287
|
| 'cancel'
|
|
282
288
|
| 'authentication'
|
|
283
289
|
| 'ready'
|
|
284
|
-
| 'paste'
|
|
285
290
|
| 'method-type-changed'
|
|
286
291
|
| 'charge-id'
|
|
287
292
|
| 'capability'
|
|
293
|
+
| 'validation'
|
|
288
294
|
| 'google-pay-ready';
|
|
289
295
|
|
|
290
|
-
export type
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
responseCode: string;
|
|
294
|
-
responseMessage: string;
|
|
295
|
-
merchantMessage: string;
|
|
296
|
-
failureType: string;
|
|
297
|
-
category: string;
|
|
298
|
-
errorType: string;
|
|
299
|
-
errorProperties: Dictionary;
|
|
300
|
-
originatingCode: string;
|
|
301
|
-
specificErrors: TransactionResponse[];
|
|
296
|
+
export type ChargeHiveEvent<T extends EventName = EventName> = {
|
|
297
|
+
type: T;
|
|
298
|
+
data: ChargeHiveEventData[T];
|
|
302
299
|
}
|
|
303
300
|
|
|
304
|
-
export type ChargeHiveEventData = {
|
|
305
|
-
'token': ChargehiveTokenEvent;
|
|
306
|
-
'success': ChargehiveSuccessEvent;
|
|
307
|
-
'declined': ChargehiveDeclinedEvent;
|
|
308
|
-
'authentication': AuthenticationEvent;
|
|
309
|
-
'error': object;
|
|
310
|
-
'token-config': PaymentMethodTokenizationConfig[PaymentMethodType];
|
|
311
|
-
'capability': ChargehiveCapabilityEvent;
|
|
312
|
-
'method-type-changed': ChargehiveMethodTypeChangedEvent;
|
|
313
|
-
'charge-id': string;
|
|
301
|
+
export type ChargeHiveEventData = {
|
|
302
|
+
readonly 'token': ChargehiveTokenEvent;
|
|
303
|
+
readonly 'success': ChargehiveSuccessEvent;
|
|
304
|
+
readonly 'declined': ChargehiveDeclinedEvent;
|
|
305
|
+
readonly 'authentication': AuthenticationEvent;
|
|
306
|
+
readonly 'error': object;
|
|
307
|
+
readonly 'token-config': PaymentMethodTokenizationConfig[PaymentMethodType];
|
|
308
|
+
readonly 'capability': ChargehiveCapabilityEvent;
|
|
309
|
+
readonly 'method-type-changed': ChargehiveMethodTypeChangedEvent;
|
|
310
|
+
readonly 'charge-id': string;
|
|
311
|
+
|
|
312
|
+
readonly 'init': InitResponse;
|
|
313
|
+
readonly 'cancel': undefined;
|
|
314
|
+
readonly 'ready': undefined;
|
|
315
|
+
readonly 'google-pay-ready': undefined;
|
|
316
|
+
|
|
317
|
+
/* pcib */
|
|
318
|
+
readonly 'focus': unknown;
|
|
319
|
+
readonly 'focusin': unknown;
|
|
320
|
+
readonly 'focusout': unknown;
|
|
321
|
+
readonly 'blur': unknown;
|
|
322
|
+
readonly 'paste': unknown;
|
|
323
|
+
readonly 'field-ready': unknown;
|
|
324
|
+
readonly 'tokenize': unknown;
|
|
325
|
+
readonly 'tokenize-ephemeral': unknown;
|
|
326
|
+
readonly 'field-validation': unknown;
|
|
327
|
+
readonly 'field-changed': unknown;
|
|
328
|
+
|
|
329
|
+
readonly 'validation': ValidationEventData;
|
|
314
330
|
}
|
|
315
331
|
|
|
316
332
|
export type ChargehiveTokenEvent = TokenizeResponse
|
|
@@ -360,7 +376,7 @@ interface AuthenticationEvent
|
|
|
360
376
|
paymentType: string;
|
|
361
377
|
}
|
|
362
378
|
|
|
363
|
-
export type Dictionary = { [key: string]:
|
|
379
|
+
export type Dictionary = { [key: string]: unknown; };
|
|
364
380
|
|
|
365
381
|
export interface AuthorizeResponse
|
|
366
382
|
{
|
|
@@ -368,13 +384,19 @@ export interface AuthorizeResponse
|
|
|
368
384
|
message: string;
|
|
369
385
|
continuationId: string;
|
|
370
386
|
chargeId: string;
|
|
371
|
-
events: ChargeHiveEvent
|
|
387
|
+
events: ChargeHiveEvent[];
|
|
372
388
|
}
|
|
373
389
|
|
|
374
|
-
export
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
export type TransactionResponse = {
|
|
391
|
+
responseCode: string;
|
|
392
|
+
responseMessage: string;
|
|
393
|
+
merchantMessage: string;
|
|
394
|
+
failureType: string;
|
|
395
|
+
category: string;
|
|
396
|
+
errorType: string;
|
|
397
|
+
errorProperties: Dictionary;
|
|
398
|
+
originatingCode: string;
|
|
399
|
+
specificErrors: TransactionResponse[];
|
|
378
400
|
}
|
|
379
401
|
|
|
380
402
|
export interface TokenizeResponse
|
|
@@ -435,8 +457,8 @@ export interface WalletOptionsResponse
|
|
|
435
457
|
|
|
436
458
|
allowedCardNetworks?: string[];
|
|
437
459
|
|
|
438
|
-
parameters: Dictionary
|
|
439
|
-
}]
|
|
460
|
+
parameters: Dictionary;
|
|
461
|
+
}];
|
|
440
462
|
};
|
|
441
463
|
|
|
442
464
|
applePay: {
|
|
@@ -455,4 +477,11 @@ export interface WalletOptionsResponse
|
|
|
455
477
|
supportedNetworks: string[];
|
|
456
478
|
merchantCapabilities: ApplePayJS.ApplePayMerchantCapability[];
|
|
457
479
|
};
|
|
480
|
+
|
|
481
|
+
paypal: {
|
|
482
|
+
connectorId: string;
|
|
483
|
+
connectorLibrary: string;
|
|
484
|
+
clientId: string;
|
|
485
|
+
merchantId: string;
|
|
486
|
+
};
|
|
458
487
|
}
|
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>;
|