@chargehive/types 2.4.11 → 2.4.13

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.
Files changed (2) hide show
  1. package/chargehive.d.ts +54 -42
  2. package/package.json +1 -2
package/chargehive.d.ts CHANGED
@@ -29,7 +29,7 @@ export interface ChargeHiveEventTarget extends Omit<EventTarget, 'dispatchEvent'
29
29
  options?: EventListenerOptions | boolean,
30
30
  ): void;
31
31
 
32
- triggerEvent(type: EventName, data?: object);
32
+ triggerEvent<E extends ChargeHiveEventType>(type: E, data?: ChargeHiveEventData[E]): void;
33
33
  }
34
34
 
35
35
  export interface ChargeHiveType extends ChargeType, ChargeHiveEventTarget
@@ -120,7 +120,7 @@ export interface InitResponse
120
120
  sandboxMode: boolean;
121
121
  country: string;
122
122
  currency: string;
123
- /** @deprecated */
123
+ /** @internal this should not be used to determine whether a capability is usable in this session */
124
124
  capabilities: PaymentMethodType[];
125
125
  defaultPaymentType: PaymentMethodType;
126
126
  walletOptions: WalletOptionsResponse;
@@ -287,7 +287,7 @@ export type EventName = PCIBEventName
287
287
  | 'capability'
288
288
  | 'google-pay-ready';
289
289
 
290
- export type ChargeHiveEventType = Extract<EventName, 'token' | 'success' | 'declined' | 'authentication' | 'error' | 'token-config'>
290
+ export type ChargeHiveEventType = Extract<EventName, 'token' | 'success' | 'declined' | 'authentication' | 'error' | 'token-config' | 'charge-id' | 'method-type-changed'>
291
291
 
292
292
  export type TransactionResponse = {
293
293
  responseCode: string;
@@ -301,53 +301,65 @@ export type TransactionResponse = {
301
301
  specificErrors: TransactionResponse[];
302
302
  }
303
303
 
304
- export type ChargeHiveEventData = {
305
- token: {
306
- name: string;
307
- scheme: string;
308
- expiry: string;
309
- token: string;
310
- additionalData: Dictionary;
311
- connectorId: string;
312
- customerError: string;
313
- merchantError: string;
314
- }
315
- success: {
316
- chargeId: string;
317
- transactionId: string;
318
- transactedAmount: {
319
- currency: string;
320
- units: number;
321
- };
322
- responseBreakdown: TransactionResponse;
323
- }
324
- declined: {
325
- chargeId: string;
326
- message: string;
327
- responseCode: string;
328
- paymentScheme: string;
329
- responseBreakdown: TransactionResponse;
330
- }
331
- authentication: {
332
- environment: string;
333
- type: string;
334
- connector: string;
335
- connectorData: Dictionary;
336
- paymentType: string;
337
- }
338
- error: object;
304
+ export type ChargeHiveEventData = { [key in EventName]: unknown } & {
305
+ 'token': ChargehiveTokenEvent;
306
+ 'success': ChargehiveSuccessEvent;
307
+ 'declined': ChargehiveDeclinedEvent;
308
+ 'authentication': AuthenticationEvent;
309
+ 'error': object;
339
310
  'token-config': PaymentMethodTokenizationConfig[PaymentMethodType];
340
- capability: {
341
- type: PaymentMethodType;
342
- data?: object;
311
+ 'capability': ChargehiveCapabilityEvent;
312
+ 'method-type-changed': ChargehiveMethodTypeChangedEvent;
313
+ 'charge-id': string;
314
+ }
315
+
316
+ export type ChargehiveTokenEvent = TokenizeResponse
317
+
318
+ interface ChargehiveSuccessEvent
319
+ {
320
+ chargeId: string;
321
+ transactionId: string;
322
+ transactedAmount: {
323
+ currency: string;
324
+ units: number;
343
325
  };
326
+ responseBreakdown: TransactionResponse;
344
327
  }
345
328
 
346
- export type CapabilityResult = {
329
+ interface ChargehiveDeclinedEvent
330
+ {
331
+ chargeId: string;
332
+ message: string;
333
+ responseCode: string;
334
+ paymentScheme: string;
335
+ responseBreakdown: TransactionResponse;
336
+ }
337
+
338
+ interface CapabilityResult
339
+ {
347
340
  result: boolean;
348
341
  data?: object;
349
342
  }
350
343
 
344
+ interface ChargehiveMethodTypeChangedEvent
345
+ {
346
+ type: PaymentMethodType;
347
+ }
348
+
349
+ interface ChargehiveCapabilityEvent extends CapabilityResult
350
+ {
351
+ type: PaymentMethodType;
352
+ }
353
+
354
+ interface AuthenticationEvent
355
+ {
356
+ environment: string;
357
+ type: string;
358
+ connector: string;
359
+ connectorData: Dictionary;
360
+ paymentType: string;
361
+ }
362
+
351
363
  export type Dictionary = { [key: string]: string };
352
364
 
353
365
  export interface AuthorizeResponse
package/package.json CHANGED
@@ -6,8 +6,7 @@
6
6
  "*.d.ts"
7
7
  ],
8
8
  "dependencies": {
9
- "typescript": "^3 || ^4",
10
9
  "@pci-bridge/types": "*"
11
10
  },
12
- "version": "2.4.11"
11
+ "version": "2.4.13"
13
12
  }