@fat-zebra/sdk 1.2.5 → 1.2.7

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.
@@ -1,5 +1,5 @@
1
1
  import * as t from './types';
2
- import { Customer, CustomerSnakeCase, PaymentIntent, PublicEvent } from '../shared/types';
2
+ import { Customer, CustomerSnakeCase, PaymentIntent } from '../shared/types';
3
3
  import { CardinalManager } from './cardinal';
4
4
  import GatewayClient from '../shared/api-gateway-client';
5
5
  export interface ScaRunProps {
@@ -11,8 +11,8 @@ export interface ScaRunProps {
11
11
  }
12
12
  export interface ScaConfig {
13
13
  gatewayClient: GatewayClient;
14
- successCallback?: (event: PublicEvent.SCA_SUCCESS, detail: any) => void;
15
- failureCallback?: (event: PublicEvent.SCA_ERROR, detail: any) => void;
14
+ successCallback?: (event: CustomEvent) => void;
15
+ failureCallback?: (event: CustomEvent) => void;
16
16
  }
17
17
  declare class Sca {
18
18
  private _cardinal;
package/dist/sca/index.js CHANGED
@@ -18,8 +18,8 @@ class Sca {
18
18
  constructor({ gatewayClient, successCallback, failureCallback }) {
19
19
  this.sessionId = null;
20
20
  this.gatewayClient = gatewayClient;
21
- this.successCallback = successCallback || emit;
22
- this.failureCallback = failureCallback || emit;
21
+ this.successCallback = successCallback;
22
+ this.failureCallback = failureCallback;
23
23
  this.loadScript();
24
24
  }
25
25
  loadScript() {
@@ -45,11 +45,23 @@ class Sca {
45
45
  this._cardinal = cardinal;
46
46
  }
47
47
  reportFailure(message) {
48
- this.failureCallback(PublicEvent.SCA_ERROR, { errors: [message] });
48
+ if (this.failureCallback) {
49
+ const event = new CustomEvent(PublicEvent.SCA_ERROR, { detail: { errors: [message] } });
50
+ this.failureCallback(event);
51
+ }
52
+ else {
53
+ emit(PublicEvent.SCA_ERROR, { errors: [message], data: {} });
54
+ }
49
55
  console.log(message);
50
56
  }
51
57
  reportSuccess(message, data) {
52
- this.successCallback(PublicEvent.SCA_SUCCESS, { data, message });
58
+ if (this.successCallback) {
59
+ const event = new CustomEvent(PublicEvent.SCA_SUCCESS, { detail: data });
60
+ this.successCallback(event);
61
+ }
62
+ else {
63
+ emit(PublicEvent.SCA_SUCCESS, { message, data });
64
+ }
53
65
  console.log(message);
54
66
  }
55
67
  run(config) {
@@ -72,7 +72,7 @@ interface Payment {
72
72
  amount: number;
73
73
  currency: string;
74
74
  reference: string;
75
- hide_card_holder: boolean;
75
+ hide_card_holder?: boolean;
76
76
  }
77
77
  interface PaymentIntent {
78
78
  payment: Payment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {