@fat-zebra/sdk 2.0.3 → 2.0.4-beta.1
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.
|
@@ -32,6 +32,7 @@ declare class ThreeDSecure {
|
|
|
32
32
|
private failureCallback;
|
|
33
33
|
private tokenizeOnly;
|
|
34
34
|
private iframe?;
|
|
35
|
+
private deviceProfileReadyHandler;
|
|
35
36
|
constructor({ successCallback, failureCallback, environment, bridge }: ThreeDSecureConfig);
|
|
36
37
|
run({ paymentIntent, cardToken, merchantUsername, challengeWindowSize, test, tokenizeOnly, iframe }: ThreeDSecureRunProps): void;
|
|
37
38
|
setupResponse(data: DeviceDataCollectionMessage): void;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { BridgeEvent, PublicEvent } from "../shared/types";
|
|
8
8
|
import DeviceDataCollection from "./utility/device-data-collection";
|
|
9
9
|
import { LocalStorageAccessTokenKey } from "../shared/constants";
|
|
10
|
-
import { emit, on } from "../shared/event-manager";
|
|
10
|
+
import { emit, off, on } from "../shared/event-manager";
|
|
11
11
|
import { logMethod } from "../logging/logMethod";
|
|
12
12
|
import ThreeDSecureChallengeWindow from "./utility/three_d_secure_challenge_window";
|
|
13
13
|
import { toFzSli } from "../sca/eci-mappings";
|
|
@@ -20,12 +20,12 @@ import * as util from "../shared/util";
|
|
|
20
20
|
class ThreeDSecure {
|
|
21
21
|
constructor({ successCallback, failureCallback, environment, bridge }) {
|
|
22
22
|
this.tokenizeOnly = false;
|
|
23
|
+
this.deviceProfileReadyHandler = null;
|
|
23
24
|
this.headlessBridge = bridge;
|
|
24
25
|
this.environment = environment;
|
|
25
26
|
this.successCallback = successCallback;
|
|
26
27
|
this.failureCallback = failureCallback;
|
|
27
28
|
DeviceDataCollection.listenDataCollectionResponse(environment);
|
|
28
|
-
this.listenDeviceCollectionReady();
|
|
29
29
|
}
|
|
30
30
|
run({ paymentIntent, cardToken, merchantUsername, challengeWindowSize, test, tokenizeOnly, iframe }) {
|
|
31
31
|
console.log('Running 3DS (ThreeDSecure)');
|
|
@@ -37,6 +37,7 @@ class ThreeDSecure {
|
|
|
37
37
|
this.cardToken = cardToken;
|
|
38
38
|
this.merchantUsername = merchantUsername;
|
|
39
39
|
this.challengeWindowSize = challengeWindowSize;
|
|
40
|
+
this.listenDeviceCollectionReady();
|
|
40
41
|
this.setup();
|
|
41
42
|
}
|
|
42
43
|
setupResponse(data) {
|
|
@@ -179,12 +180,16 @@ class ThreeDSecure {
|
|
|
179
180
|
this.headlessBridge.contentWindow.postMessage(message, '*');
|
|
180
181
|
}
|
|
181
182
|
listenDeviceCollectionReady() {
|
|
182
|
-
|
|
183
|
+
if (this.deviceProfileReadyHandler) {
|
|
184
|
+
off(PublicEvent.DEVICE_PROFILE_READY_THREE_D_SECURE_EVENT, this.deviceProfileReadyHandler);
|
|
185
|
+
}
|
|
186
|
+
this.deviceProfileReadyHandler = () => this.checkEnrollment({
|
|
183
187
|
paymentIntent: this.paymentIntent,
|
|
184
188
|
cardToken: this.cardToken,
|
|
185
189
|
merchantUsername: this.merchantUsername,
|
|
186
190
|
cybersourceReferenceId: this.cybersourceReferenceId,
|
|
187
|
-
})
|
|
191
|
+
});
|
|
192
|
+
on(PublicEvent.DEVICE_PROFILE_READY_THREE_D_SECURE_EVENT, this.deviceProfileReadyHandler);
|
|
188
193
|
}
|
|
189
194
|
setLoading(loading = true) {
|
|
190
195
|
var _a;
|
|
@@ -11,6 +11,7 @@ export default class DeviceDataCollection {
|
|
|
11
11
|
private static readonly IFRAME_NAME;
|
|
12
12
|
private static readonly FORM_ID;
|
|
13
13
|
private static readonly INPUT_ID;
|
|
14
|
+
private static messageHandler;
|
|
14
15
|
createIframe(): void;
|
|
15
16
|
static listenDataCollectionResponse(environment: Environment): void;
|
|
16
17
|
private static handleDataCollectionResponse;
|
|
@@ -44,7 +44,11 @@ class DeviceDataCollection {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
static listenDataCollectionResponse(environment) {
|
|
47
|
-
|
|
47
|
+
if (this.messageHandler) {
|
|
48
|
+
window.removeEventListener("message", this.messageHandler, false);
|
|
49
|
+
}
|
|
50
|
+
this.messageHandler = (event) => this.handleDataCollectionResponse(event, environment);
|
|
51
|
+
window.addEventListener("message", this.messageHandler, false);
|
|
48
52
|
}
|
|
49
53
|
static handleDataCollectionResponse(event, environment) {
|
|
50
54
|
// https://developer.cybersource.com/docs/cybs/en-us/payer-authentication/developer/all/so/payer-auth/pa2-ccdc-ddc-intro.html#reference_qmk_jrl_xpb
|
|
@@ -124,6 +128,7 @@ DeviceDataCollection.IFRAME_ID = "cardinal_collection_iframe";
|
|
|
124
128
|
DeviceDataCollection.IFRAME_NAME = "collectionIframe";
|
|
125
129
|
DeviceDataCollection.FORM_ID = "cardinal_collection_form";
|
|
126
130
|
DeviceDataCollection.INPUT_ID = "cardinal_collection_form_input";
|
|
131
|
+
DeviceDataCollection.messageHandler = null;
|
|
127
132
|
export default DeviceDataCollection;
|
|
128
133
|
__decorate([
|
|
129
134
|
logMethod({
|