@fat-zebra/sdk 2.0.3-beta.2 → 2.0.3-beta.4

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/hpp/hpp.js CHANGED
@@ -259,6 +259,9 @@ __decorate([
259
259
  __decorate([
260
260
  logMethod()
261
261
  ], Hpp.prototype, "setPublicEventListeners", null);
262
+ __decorate([
263
+ logMethod()
264
+ ], Hpp.prototype, "destroy", null);
262
265
  __decorate([
263
266
  logMethod()
264
267
  ], Hpp.prototype, "createPurchase", null);
package/dist/main.js CHANGED
@@ -51,10 +51,6 @@ class FatZebra {
51
51
  this.headless.addEventListener('load', () => resolve());
52
52
  });
53
53
  }
54
- this.sca = new Sca({
55
- gatewayClient: this.gatewayClient,
56
- });
57
- this.sca.loadScript();
58
54
  this.authReady = this.setAuthImpl();
59
55
  const message = {
60
56
  channel: 'sca',
@@ -75,6 +71,12 @@ class FatZebra {
75
71
  });
76
72
  this.setThreeDSecureListeners();
77
73
  }
74
+ else {
75
+ this.sca = new Sca({
76
+ gatewayClient: this.gatewayClient,
77
+ });
78
+ this.sca.loadScript();
79
+ }
78
80
  });
79
81
  }
80
82
  tokenizeCard(card) {
@@ -147,7 +149,7 @@ class FatZebra {
147
149
  }
148
150
  verifyCard(params) {
149
151
  return __awaiter(this, void 0, void 0, function* () {
150
- var _a;
152
+ var _a, _b;
151
153
  console.log('verifyCard');
152
154
  const valid = validateVerifyCardParams(params);
153
155
  if (!valid) {
@@ -157,22 +159,34 @@ class FatZebra {
157
159
  });
158
160
  return;
159
161
  }
160
- yield this.bridgeReady;
162
+ yield this.authReady;
161
163
  switch (params.paymentMethod.type) {
162
164
  case PaymentMethodType.CARD: {
163
165
  console.log('Verify card (new card)');
164
166
  const card = params.paymentMethod.data;
165
167
  this.cardDidTokenize((data) => __awaiter(this, void 0, void 0, function* () {
166
- var _a;
167
- const bin = card.number.substr(0, 6);
168
- this.sca.run({
169
- source: 'verifyCard',
170
- cardToken: data.token,
171
- customer: params.customer,
172
- paymentIntent: params.paymentIntent,
173
- bin,
174
- challengeWindowSize: (_a = params.options) === null || _a === void 0 ? void 0 : _a.challengeWindowSize,
175
- });
168
+ var _a, _b;
169
+ if (this.threeDSecure && this.isThreeDSecureEnabled) {
170
+ this.threeDSecure.run({
171
+ paymentIntent: params.paymentIntent,
172
+ cardToken: data.token,
173
+ merchantUsername: this.fzConfig.username,
174
+ challengeWindowSize: (_a = params.options) === null || _a === void 0 ? void 0 : _a.challengeWindowSize,
175
+ test: this.fzConfig.test,
176
+ tokenizeOnly: true,
177
+ });
178
+ }
179
+ else {
180
+ const bin = card.number.substr(0, 6);
181
+ this.sca.run({
182
+ source: 'verifyCard',
183
+ cardToken: data.token,
184
+ customer: params.customer,
185
+ paymentIntent: params.paymentIntent,
186
+ bin,
187
+ challengeWindowSize: (_b = params.options) === null || _b === void 0 ? void 0 : _b.challengeWindowSize,
188
+ });
189
+ }
176
190
  }));
177
191
  this.tokenizeCard(card);
178
192
  break;
@@ -180,17 +194,29 @@ class FatZebra {
180
194
  case PaymentMethodType.CARD_ON_FILE: {
181
195
  console.log('Verify card (card on file)');
182
196
  const cardToken = params.paymentMethod.data.token;
183
- const bin = (yield this.gatewayClient.getCard({
184
- card_token: cardToken,
185
- })).data.bin;
186
- this.sca.run({
187
- source: 'verifyCard',
188
- cardToken,
189
- customer: params.customer,
190
- paymentIntent: params.paymentIntent,
191
- bin,
192
- challengeWindowSize: (_a = params.options) === null || _a === void 0 ? void 0 : _a.challengeWindowSize,
193
- });
197
+ if (this.threeDSecure && this.isThreeDSecureEnabled) {
198
+ this.threeDSecure.run({
199
+ paymentIntent: params.paymentIntent,
200
+ cardToken,
201
+ merchantUsername: this.fzConfig.username,
202
+ challengeWindowSize: (_a = params.options) === null || _a === void 0 ? void 0 : _a.challengeWindowSize,
203
+ test: this.fzConfig.test,
204
+ tokenizeOnly: true,
205
+ });
206
+ }
207
+ else {
208
+ const bin = (yield this.gatewayClient.getCard({
209
+ card_token: cardToken,
210
+ })).data.bin;
211
+ this.sca.run({
212
+ source: 'verifyCard',
213
+ cardToken,
214
+ customer: params.customer,
215
+ paymentIntent: params.paymentIntent,
216
+ bin,
217
+ challengeWindowSize: (_b = params.options) === null || _b === void 0 ? void 0 : _b.challengeWindowSize,
218
+ });
219
+ }
194
220
  break;
195
221
  }
196
222
  }
@@ -13,6 +13,7 @@ export default class CardinalManager {
13
13
  setup(jwt: any): void;
14
14
  onPaymentValidated(handler: (data: PaymentValidatedDTO, error: string) => void): void;
15
15
  onPaymentSetupComplete(callback: (data: CardinalSetupCompleteResponseData) => void): void;
16
+ off(event: string): void;
16
17
  processBin(bin: string): Promise<any>;
17
18
  continue(acsUrl: string, pareq: string, transactionId: string): void;
18
19
  }
@@ -63,6 +63,10 @@ export default class CardinalManager {
63
63
  callback(data);
64
64
  });
65
65
  }
66
+ off(event) {
67
+ var _a;
68
+ (_a = window.Cardinal) === null || _a === void 0 ? void 0 : _a.off(event);
69
+ }
66
70
  processBin(bin) {
67
71
  return __awaiter(this, void 0, void 0, function* () {
68
72
  yield window.Cardinal.trigger('bin.process', bin);
package/dist/sca/index.js CHANGED
@@ -102,7 +102,9 @@ class Sca {
102
102
  perform3DS(_a) {
103
103
  return __awaiter(this, arguments, void 0, function* ({ sessionID }) {
104
104
  this.sessionId = sessionID;
105
- // Register handler. Called after OTP is entered on challenge prompt.
105
+ // Clear any orphaned listeners.
106
+ this._cardinal.off('payments.validated');
107
+ // Called after OTP is entered on challenge prompt.
106
108
  this._cardinal.onPaymentValidated((data, error) => __awaiter(this, void 0, void 0, function* () {
107
109
  var _a;
108
110
  if (typeof error == 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "2.0.3-beta.2",
3
+ "version": "2.0.3-beta.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {