@fat-zebra/sdk 2.0.1-beta.4 → 2.0.1-beta.5

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/dist/main.d.ts CHANGED
@@ -40,6 +40,9 @@ export default class FatZebra {
40
40
  renderPaymentsPage(params: HppLoadParams): Promise<void>;
41
41
  renderApplePayButton(params: ApplePayParams): void;
42
42
  renderClickToPay(params: HppClickToPayParams): void;
43
+ reportThreeDSecureFetchedOnInit(data: any): void;
44
+ reportThreeDSecureFetched(data: any, paymentIntent?: PaymentIntent): void;
45
+ reportRequestThreedsEnabledTimeout(paymentIntent?: PaymentIntent): void;
43
46
  checkout(): void;
44
47
  on(event: PublicEvent, callback: (e: any) => void): void;
45
48
  off(event: PublicEvent, callback: (e: any) => void): void;
package/dist/main.js CHANGED
@@ -91,9 +91,9 @@ export default class FatZebra {
91
91
  };
92
92
  postMessageClient.setEventListeners(handlers);
93
93
  }
94
- requestThreeDSEnabled() {
94
+ requestThreeDSEnabled(paymentIntent) {
95
+ console.log('requestThreeDSEnabled');
95
96
  return new Promise((resolve) => {
96
- var _a;
97
97
  const channel = 'sca';
98
98
  const postMessageClient = new PostMessageClient({
99
99
  channel,
@@ -103,9 +103,10 @@ export default class FatZebra {
103
103
  postMessageClient.setEventListeners({
104
104
  [BridgeEvent.THREE_D_SECURE_ENABLED]: (data) => {
105
105
  const enabled = typeof data === 'boolean' ? data : false;
106
- this.threeDSEnabled = enabled;
107
106
  if (!resolved) {
107
+ this.reportThreeDSecureFetched(data, paymentIntent);
108
108
  resolved = true;
109
+ this.threeDSEnabled = enabled;
109
110
  resolve(enabled);
110
111
  }
111
112
  },
@@ -118,10 +119,12 @@ export default class FatZebra {
118
119
  access_token: window.localStorage.getItem(LocalStorageAccessTokenKey),
119
120
  },
120
121
  };
121
- (_a = this.headless.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, '*');
122
+ postMessageClient.send(message);
122
123
  window.setTimeout(() => {
123
124
  if (!resolved) {
125
+ this.reportRequestThreedsEnabledTimeout(paymentIntent);
124
126
  resolved = true;
127
+ this.threeDSEnabled = false;
125
128
  resolve(false);
126
129
  }
127
130
  }, 5000);
@@ -138,9 +141,10 @@ export default class FatZebra {
138
141
  });
139
142
  return;
140
143
  }
141
- const threeDSEnabled = yield this.requestThreeDSEnabled();
144
+ const threeDSEnabled = yield this.requestThreeDSEnabled(params.paymentIntent);
142
145
  switch (params.paymentMethod.type) {
143
146
  case PaymentMethodType.CARD: {
147
+ console.log('Verify card (new card)');
144
148
  const card = params.paymentMethod.data;
145
149
  this.cardDidTokenize((data) => __awaiter(this, void 0, void 0, function* () {
146
150
  var _a, _b;
@@ -169,6 +173,7 @@ export default class FatZebra {
169
173
  break;
170
174
  }
171
175
  case PaymentMethodType.CARD_ON_FILE: {
176
+ console.log('Verify card (card on file)');
172
177
  const cardToken = params.paymentMethod.data.token;
173
178
  if (threeDSEnabled) {
174
179
  this.threeDSecure.run({
@@ -198,6 +203,7 @@ export default class FatZebra {
198
203
  });
199
204
  }
200
205
  setThreeDSecureListeners() {
206
+ console.log('setThreeDSecureListeners');
201
207
  if (this.threeDSecureListenersBound)
202
208
  return;
203
209
  this.threeDSecureListenersBound = true;
@@ -208,13 +214,24 @@ export default class FatZebra {
208
214
  });
209
215
  const handlers = this.threeDSecure.messageHandlers();
210
216
  handlers[BridgeEvent.THREE_D_SECURE_ENABLED] = (data) => {
217
+ this.reportThreeDSecureFetchedOnInit(data);
211
218
  this.threeDSEnabled = typeof data === 'boolean' ? data : false;
212
219
  };
213
220
  postMessageClient.setEventListeners(handlers);
221
+ const message = {
222
+ channel,
223
+ subject: 'fzi.is-enabled-three-d-secure-req',
224
+ data: {
225
+ merchant: this.fzConfig.username,
226
+ access_token: window.localStorage.getItem(LocalStorageAccessTokenKey),
227
+ },
228
+ };
229
+ postMessageClient.send(message);
214
230
  }
215
231
  renderPaymentsPage(params) {
216
232
  return __awaiter(this, void 0, void 0, function* () {
217
233
  var _a;
234
+ console.log('renderPaymentsPage');
218
235
  const valid = validateHppLoadParams(params);
219
236
  if (!valid) {
220
237
  emit(PublicEvent.VALIDATION_ERROR, {
@@ -223,7 +240,7 @@ export default class FatZebra {
223
240
  });
224
241
  return;
225
242
  }
226
- yield this.requestThreeDSEnabled();
243
+ yield this.requestThreeDSEnabled(params.paymentIntent);
227
244
  if ((_a = window.HPP) === null || _a === void 0 ? void 0 : _a.destroy) {
228
245
  window.HPP.destroy();
229
246
  }
@@ -276,6 +293,15 @@ export default class FatZebra {
276
293
  });
277
294
  window.HPP.load(params);
278
295
  }
296
+ reportThreeDSecureFetchedOnInit(data) {
297
+ console.log("three_d_secure fetched on init", data);
298
+ }
299
+ reportThreeDSecureFetched(data, paymentIntent) {
300
+ console.log("three_d_secure fetched", data);
301
+ }
302
+ reportRequestThreedsEnabledTimeout(paymentIntent) {
303
+ console.log("3DS enabled check timed out");
304
+ }
279
305
  checkout() {
280
306
  window.HPP.purchase();
281
307
  }
@@ -289,6 +315,18 @@ export default class FatZebra {
289
315
  onOnce(event, callback);
290
316
  }
291
317
  }
318
+ __decorate([
319
+ logMethod({
320
+ mapArgs: (args) => {
321
+ const params = args[0];
322
+ return [
323
+ {
324
+ payment_intent: params === null || params === void 0 ? void 0 : params.paymentIntent
325
+ },
326
+ ];
327
+ },
328
+ })
329
+ ], FatZebra.prototype, "requestThreeDSEnabled", null);
292
330
  __decorate([
293
331
  logMethod({
294
332
  mapArgs: (args) => {
@@ -304,4 +342,53 @@ __decorate([
304
342
  },
305
343
  })
306
344
  ], FatZebra.prototype, "verifyCard", null);
345
+ __decorate([
346
+ logMethod({
347
+ mapArgs: (args) => {
348
+ const params = args[0];
349
+ return [
350
+ {
351
+ payment_intent: params.paymentIntent,
352
+ version: params.version
353
+ },
354
+ ];
355
+ },
356
+ })
357
+ ], FatZebra.prototype, "renderPaymentsPage", null);
358
+ __decorate([
359
+ logMethod({
360
+ mapArgs: (args) => {
361
+ const data = args[0];
362
+ return [
363
+ {
364
+ data
365
+ },
366
+ ];
367
+ },
368
+ })
369
+ ], FatZebra.prototype, "reportThreeDSecureFetchedOnInit", null);
370
+ __decorate([
371
+ logMethod({
372
+ mapArgs: (args) => {
373
+ const data = args[0];
374
+ return [
375
+ {
376
+ data
377
+ },
378
+ ];
379
+ },
380
+ })
381
+ ], FatZebra.prototype, "reportThreeDSecureFetched", null);
382
+ __decorate([
383
+ logMethod({
384
+ mapArgs: (args) => {
385
+ const data = args[0];
386
+ return [
387
+ {
388
+ data
389
+ },
390
+ ];
391
+ },
392
+ })
393
+ ], FatZebra.prototype, "reportRequestThreedsEnabledTimeout", null);
307
394
  export { FatZebra, };
package/dist/sca/index.js CHANGED
@@ -58,6 +58,7 @@ class Sca {
58
58
  }
59
59
  run(config) {
60
60
  return __awaiter(this, void 0, void 0, function* () {
61
+ console.log('Running 3DS (SCA)');
61
62
  try {
62
63
  if (!this._cardinal) {
63
64
  this._cardinal = new CardinalManager();
@@ -28,6 +28,7 @@ class ThreeDSecure {
28
28
  this.listenDeviceCollectionReady();
29
29
  }
30
30
  run({ paymentIntent, cardToken, merchantUsername, challengeWindowSize, test, tokenizeOnly, iframe }) {
31
+ console.log('Running 3DS (ThreeDSecure)');
31
32
  this.iframe = iframe;
32
33
  this.tokenizeOnly = tokenizeOnly;
33
34
  this.setLoading();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "2.0.1-beta.4",
3
+ "version": "2.0.1-beta.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {