@fat-zebra/sdk 1.4.13 → 1.4.14

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 (154) hide show
  1. package/.jest/setup-env-vars.js +0 -1
  2. package/dist/click_to_pay/index.d.ts +28 -0
  3. package/dist/click_to_pay/index.js +50 -0
  4. package/dist/click_to_pay/types.d.ts +13 -0
  5. package/dist/click_to_pay/types.js +1 -0
  6. package/dist/local/fatzebra.js.map +1 -0
  7. package/dist/local/index.html +247 -0
  8. package/dist/main.d.ts +2 -0
  9. package/dist/main.js +18 -1
  10. package/dist/production/fatzebra.js.LICENSE.txt +1 -0
  11. package/dist/react/url.js +0 -4
  12. package/dist/sca/index.d.ts +1 -1
  13. package/dist/sca/index.js +26 -10
  14. package/dist/sca/scenarios/enrollment.d.ts +2 -1
  15. package/dist/sca/scenarios/enrollment.js +11 -1
  16. package/dist/sca/scenarios/validation.d.ts +2 -1
  17. package/dist/sca/scenarios/validation.js +11 -1
  18. package/dist/sca/types.d.ts +2 -2
  19. package/dist/shared/api-gateway-client.js +6 -1
  20. package/dist/shared/post-message-client.js +2 -0
  21. package/dist/shared/types.d.ts +1 -1
  22. package/dist/src/applepay/applepay.js +198 -0
  23. package/dist/src/applepay/applepay.js.map +1 -0
  24. package/dist/src/applepay/clients/apple-pay-client.js +66 -0
  25. package/dist/src/applepay/clients/apple-pay-client.js.map +1 -0
  26. package/dist/src/applepay/clients/paynow-client.js +96 -0
  27. package/dist/src/applepay/clients/paynow-client.js.map +1 -0
  28. package/dist/src/applepay/index.js +6 -0
  29. package/dist/src/applepay/index.js.map +1 -0
  30. package/dist/src/click_to_pay/index.js +88 -0
  31. package/dist/src/click_to_pay/index.js.map +1 -0
  32. package/dist/src/click_to_pay/types.js +3 -0
  33. package/dist/src/click_to_pay/types.js.map +1 -0
  34. package/dist/src/hpp/hpp.js +230 -0
  35. package/dist/src/hpp/hpp.js.map +1 -0
  36. package/dist/src/hpp/hpp.test.js +135 -0
  37. package/dist/src/hpp/hpp.test.js.map +1 -0
  38. package/dist/src/hpp/index.js +6 -0
  39. package/dist/src/hpp/index.js.map +1 -0
  40. package/dist/src/index.js +14 -0
  41. package/dist/src/index.js.map +1 -0
  42. package/dist/src/main.js +243 -0
  43. package/dist/src/main.js.map +1 -0
  44. package/dist/src/main.test.js +236 -0
  45. package/dist/src/main.test.js.map +1 -0
  46. package/dist/src/paypal/paypal-button.js +311 -0
  47. package/dist/src/paypal/paypal-button.js.map +1 -0
  48. package/dist/src/paypal/paypal-button.test.js +41 -0
  49. package/dist/src/paypal/paypal-button.test.js.map +1 -0
  50. package/dist/src/paypal/paypal-checkout.js +111 -0
  51. package/dist/src/paypal/paypal-checkout.js.map +1 -0
  52. package/dist/src/paypal/paypal-checkout.test.js +167 -0
  53. package/dist/src/paypal/paypal-checkout.test.js.map +1 -0
  54. package/dist/src/paypal/types.js +9 -0
  55. package/dist/src/paypal/types.js.map +1 -0
  56. package/dist/src/paypal/validation.js +73 -0
  57. package/dist/src/paypal/validation.js.map +1 -0
  58. package/dist/src/react/VerifyCard.js +29 -0
  59. package/dist/src/react/VerifyCard.js.map +1 -0
  60. package/dist/src/react/index.js +11 -0
  61. package/dist/src/react/index.js.map +1 -0
  62. package/dist/src/react/submitForm.js +13 -0
  63. package/dist/src/react/submitForm.js.map +1 -0
  64. package/dist/src/react/url.js +60 -0
  65. package/dist/src/react/url.js.map +1 -0
  66. package/dist/src/react/url.test.js +88 -0
  67. package/dist/src/react/url.test.js.map +1 -0
  68. package/dist/src/react/useFatZebra.js +119 -0
  69. package/dist/src/react/useFatZebra.js.map +1 -0
  70. package/dist/src/sca/cardinal.js +110 -0
  71. package/dist/src/sca/cardinal.js.map +1 -0
  72. package/dist/src/sca/eci-mappings.js +63 -0
  73. package/dist/src/sca/eci-mappings.js.map +1 -0
  74. package/dist/src/sca/eci-mappings.test.js +31 -0
  75. package/dist/src/sca/eci-mappings.test.js.map +1 -0
  76. package/dist/src/sca/index.js +363 -0
  77. package/dist/src/sca/index.js.map +1 -0
  78. package/dist/src/sca/index.test.js +620 -0
  79. package/dist/src/sca/index.test.js.map +1 -0
  80. package/dist/src/sca/scenarios/enrollment.js +161 -0
  81. package/dist/src/sca/scenarios/enrollment.js.map +1 -0
  82. package/dist/src/sca/scenarios/index.js +8 -0
  83. package/dist/src/sca/scenarios/index.js.map +1 -0
  84. package/dist/src/sca/scenarios/validation.js +139 -0
  85. package/dist/src/sca/scenarios/validation.js.map +1 -0
  86. package/dist/src/sca/types.js +57 -0
  87. package/dist/src/sca/types.js.map +1 -0
  88. package/dist/src/shared/api-gateway-client.js +184 -0
  89. package/dist/src/shared/api-gateway-client.js.map +1 -0
  90. package/dist/src/shared/bridge-client.js +24 -0
  91. package/dist/src/shared/bridge-client.js.map +1 -0
  92. package/dist/src/shared/constants.js +19 -0
  93. package/dist/src/shared/constants.js.map +1 -0
  94. package/dist/src/shared/env.development.js +12 -0
  95. package/dist/src/shared/env.development.js.map +1 -0
  96. package/dist/src/shared/env.js +46 -0
  97. package/dist/src/shared/env.js.map +1 -0
  98. package/dist/src/shared/envs/local.js +12 -0
  99. package/dist/src/shared/envs/local.js.map +1 -0
  100. package/dist/src/shared/envs/production.js +12 -0
  101. package/dist/src/shared/envs/production.js.map +1 -0
  102. package/dist/src/shared/envs/sandbox.js +12 -0
  103. package/dist/src/shared/envs/sandbox.js.map +1 -0
  104. package/dist/src/shared/envs/staging.js +12 -0
  105. package/dist/src/shared/envs/staging.js.map +1 -0
  106. package/dist/src/shared/event-manager.js +14 -0
  107. package/dist/src/shared/event-manager.js.map +1 -0
  108. package/dist/src/shared/post-message-client.js +107 -0
  109. package/dist/src/shared/post-message-client.js.map +1 -0
  110. package/dist/src/shared/post-message-client.test.js +58 -0
  111. package/dist/src/shared/post-message-client.test.js.map +1 -0
  112. package/dist/src/shared/types.js +47 -0
  113. package/dist/src/shared/types.js.map +1 -0
  114. package/dist/src/shared/types.test.js +55 -0
  115. package/dist/src/shared/types.test.js.map +1 -0
  116. package/dist/src/shared/util.js +96 -0
  117. package/dist/src/shared/util.js.map +1 -0
  118. package/dist/src/shared/util.test.js +148 -0
  119. package/dist/src/shared/util.test.js.map +1 -0
  120. package/dist/src/validation/index.js +12 -0
  121. package/dist/src/validation/index.js.map +1 -0
  122. package/dist/src/validation/schemas/click-to-pay/load-params.json +34 -0
  123. package/dist/src/validation/schemas/click-to-pay/options.json +23 -0
  124. package/dist/src/validation/schemas/click-to-pay/payment-intent.json +42 -0
  125. package/dist/src/validation/schemas/customer.json +38 -0
  126. package/dist/src/validation/schemas/hpp-load-params.json +40 -0
  127. package/dist/src/validation/schemas/hpp-options.json +48 -0
  128. package/dist/src/validation/schemas/payment-intent.json +48 -0
  129. package/dist/src/validation/schemas/payment-method.json +83 -0
  130. package/dist/src/validation/schemas/verify-card-options.json +15 -0
  131. package/dist/src/validation/schemas/verify-card-params.json +24 -0
  132. package/dist/src/validation/validation-helper.js +10 -0
  133. package/dist/src/validation/validation-helper.js.map +1 -0
  134. package/dist/src/validation/validation-helper.test.js +34 -0
  135. package/dist/src/validation/validation-helper.test.js.map +1 -0
  136. package/dist/src/validation/validators/click-to-pay-load-params-validator.js +19 -0
  137. package/dist/src/validation/validators/click-to-pay-load-params-validator.js.map +1 -0
  138. package/dist/src/validation/validators/hpp-load-params-validator.js +21 -0
  139. package/dist/src/validation/validators/hpp-load-params-validator.js.map +1 -0
  140. package/dist/src/validation/validators/hpp-load-params-validator.test.js +56 -0
  141. package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +1 -0
  142. package/dist/src/validation/validators/verify-card-params-validator.js +23 -0
  143. package/dist/src/validation/validators/verify-card-params-validator.js.map +1 -0
  144. package/dist/tests/helpers/api-gateway-mock.js +37 -0
  145. package/dist/tests/helpers/api-gateway-mock.js.map +1 -0
  146. package/dist/validation/index.d.ts +1 -0
  147. package/dist/validation/index.js +1 -0
  148. package/dist/validation/schemas/click-to-pay/load-params.json +34 -0
  149. package/dist/validation/schemas/click-to-pay/options.json +23 -0
  150. package/dist/validation/schemas/click-to-pay/payment-intent.json +42 -0
  151. package/dist/validation/schemas/hpp-options.json +93 -45
  152. package/dist/validation/validators/click-to-pay-load-params-validator.d.ts +3 -0
  153. package/dist/validation/validators/click-to-pay-load-params-validator.js +12 -0
  154. package/package.json +1 -1
@@ -0,0 +1,247 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Merchant XYZ Checkout Page</title>
6
+ <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
7
+ <style type="text/css">
8
+ iframe {
9
+ height: 600px;
10
+ width: 700px;
11
+ }
12
+ </style>
13
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-md5.js"></script>
15
+ <script>
16
+ window.localStorage.setItem('fz-access-token', "<DO NOT USE>")
17
+ // card tokens will be filled out
18
+ var actionItems = {
19
+ tokens: [
20
+ {
21
+ token: 'whatever',
22
+ number: '4000000000001000',
23
+ description: 'Successful Frictionless Authentication'
24
+ },
25
+ {
26
+ token: '',
27
+ number: '4000000000001026',
28
+ description: 'Attempts Stand-In Frictionless'
29
+ },
30
+ {
31
+ token: '',
32
+ number: '4000000000001034',
33
+ description: 'Unavailable Frictionless'
34
+ },
35
+ {
36
+ token: '',
37
+ number: '4000000000001059',
38
+ description: 'Authentication Not Available on Lookup'
39
+ },
40
+ {
41
+ token: '',
42
+ number: '4000000000001067',
43
+ description: 'Error on Lookup'
44
+ },
45
+ {
46
+ token: '',
47
+ number: '4000000000001075',
48
+ description: 'Timeout on cmpi_lookup'
49
+ },
50
+ {
51
+ token: '',
52
+ number: '4000000000001083',
53
+ description: 'Bypassed Authentication'
54
+ },
55
+ {
56
+ token: '',
57
+ number: '4000000000001018',
58
+ description: 'Failed Frictionless'
59
+ },
60
+ {
61
+ token: '',
62
+ number: '4000000000001042',
63
+ description: 'Rejected Frictionless'
64
+ },
65
+ {
66
+ token: 'ahq94qb60fs0xaruga3h',
67
+ number: '4000000000001091',
68
+ description: 'Challenge'
69
+ }
70
+ ],
71
+ cards: [
72
+ {
73
+ number: '4000000000001000',
74
+ description: 'Successful Frictionless Authentication'
75
+ },
76
+ {
77
+ number: '4000000000001026',
78
+ description: 'Attempts Stand-In Frictionless'
79
+ },
80
+ {
81
+ number: '4000000000001034',
82
+ description: 'Unavailable Frictionless'
83
+ },
84
+ {
85
+ number: '4000000000001059',
86
+ description: 'Authentication Not Available on Lookup'
87
+ },
88
+ {
89
+ number: '4000000000001067',
90
+ description: 'Error on Lookup'
91
+ },
92
+ {
93
+ number: '4000000000001075',
94
+ description: 'Timeout on cmpi_lookup'
95
+ },
96
+ {
97
+ number: '4000000000001083',
98
+ description: 'Bypassed Authentication'
99
+ },
100
+ {
101
+ number: '4000000000001018',
102
+ description: 'Failed Frictionless'
103
+ },
104
+ {
105
+ number: '4000000000001042',
106
+ description: 'Rejected Frictionless'
107
+ },
108
+ {
109
+ number: '4000000000001091',
110
+ description: 'Challenge'
111
+ }
112
+ ]
113
+ }
114
+ </script>
115
+ <script src="fatzebra.js"></script></head>
116
+ <body>
117
+ <table id="options" class="table table-bordered">
118
+ <thead>
119
+ <tr>
120
+ <th scope="col">Card Token</th>
121
+ <th scope="col">New Card</th>
122
+ <th scope="col">Description</th>
123
+ </tr>
124
+ </thead>
125
+ <tbody>
126
+ </tbody>
127
+ </table>
128
+ <button type="button" class="btn btn-primary" id='doCheckout'>Primary</button>
129
+
130
+ <script>
131
+ var selectedMode = undefined
132
+ var selectedValue = undefined
133
+
134
+ $(document).ready(function() {
135
+
136
+ for (var i = 0; i < actionItems.tokens.length; i ++ ) {
137
+ const row = "<tr><td><input type='checkbox' class='option' data-mode='token' value='" + actionItems.tokens[i].token + "'><label>token for " + actionItems.tokens[i].number + "</label></td>" +
138
+ "<td><input type='checkbox' class='option' data-mode='card' value='" + actionItems.cards[i].number + "'><label>" + actionItems.cards[i].number + "</label></td>" +
139
+ "<td><label>" + actionItems.cards[i].description + "</label></td></tr>";
140
+ $('#options').append(row)
141
+ }
142
+
143
+ $('.option').change(function() {
144
+
145
+ if ($(this).prop("checked") == true) {
146
+ if (selectedValue === undefined) {
147
+ selectedMode = $(this).data('mode');
148
+ selectedValue = $(this).val();
149
+ } else {
150
+ $(this).prop("checked", false)
151
+ alert("There can only be one checkbox selected!");
152
+ }
153
+ } else {
154
+ selectedMode = undefined;
155
+ selectedValue = undefined;
156
+ }
157
+
158
+ console.log('selectedMode: ' + selectedMode);
159
+ console.log('selectedValue: ' + selectedValue);
160
+ })
161
+ })
162
+
163
+ </script>
164
+ </body>
165
+ <footer>
166
+
167
+ <script>
168
+ var fz = new FatZebra({
169
+ username: 'TEST'
170
+ });
171
+
172
+ $('#doCheckout').click(function() {
173
+ if (selectedMode === undefined || selectedValue == undefined) {
174
+ alert('Please select an option.');
175
+ return
176
+ }
177
+
178
+ var paymentMethod = undefined;
179
+
180
+ if (selectedMode === 'card') {
181
+ paymentMethod = {
182
+ type: 'card',
183
+ data: {
184
+ number: selectedValue,
185
+ holder: 'John Doe',
186
+ expiryMonth: '01',
187
+ expiryYear: '2022',
188
+ cvv: '123'
189
+ }
190
+ }
191
+ } else {
192
+ paymentMethod = {
193
+ type: 'card_on_file',
194
+ data: {
195
+ token: selectedValue
196
+ }
197
+ }
198
+ }
199
+
200
+ function randomString(length) {
201
+ return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1);
202
+ }
203
+
204
+ const reference = randomString(16);
205
+ const amount = 1200000;
206
+ const currency = 'AUD';
207
+ const message = [reference, amount, currency].join(':')
208
+ const verification = CryptoJS.HmacMD5(message, "033bd94b11").toString();
209
+
210
+ fz.verifyCard({
211
+ customer: {
212
+ firstName: 'Captain',
213
+ lastName: 'America',
214
+ email: 'sos@fatzebra.com.au',
215
+ address: '123 Get High Blvd.',
216
+ city: 'Red Light District',
217
+ postcode: '6666',
218
+ state: 'NSW',
219
+ country: 'Australia'
220
+ },
221
+ paymentIntent: {
222
+ payment: {
223
+ amount: amount,
224
+ currency: currency,
225
+ reference: reference
226
+ },
227
+ verification: verification
228
+ },
229
+ paymentMethod: paymentMethod
230
+ })
231
+ })
232
+
233
+ fz.on('fz.sca.error', function(event) {
234
+ console.log(JSON.stringify(event.detail))
235
+ })
236
+
237
+ fz.on('fz.sca.success', function(event) {
238
+ console.log(JSON.stringify(event.detail))
239
+ })
240
+
241
+ fz.on('fz.validation.error', function(event) {
242
+ console.log(JSON.stringify(event.detail))
243
+ })
244
+ </script>
245
+
246
+ </footer>
247
+ </html>
package/dist/main.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Customer, PaymentIntent, PaymentMethod, PublicEvent } from './shared/ty
2
2
  import { HppLoadParams } from './hpp';
3
3
  import { PayPalConfig } from './paypal/types';
4
4
  import { ChallengeWindowSize } from './sca/types';
5
+ import { HppClickToPayParams } from './click_to_pay/types';
5
6
  export interface FZConfig {
6
7
  username: string;
7
8
  test?: boolean;
@@ -31,6 +32,7 @@ export default class FatZebra {
31
32
  cardDidTokenize(headless: HTMLIFrameElement, callback: (data: any) => void): void;
32
33
  verifyCard(params: VerifyCardParams): Promise<void>;
33
34
  renderPaymentsPage(params: HppLoadParams): void;
35
+ renderClickToPay(params: HppClickToPayParams): void;
34
36
  checkout(): void;
35
37
  setupPayPal(config: PayPalConfig): void;
36
38
  on(event: PublicEvent, callback: (e: any) => void): void;
package/dist/main.js CHANGED
@@ -13,10 +13,11 @@ import { BridgeEvent, PaymentMethodType, PublicEvent, } from './shared/types';
13
13
  import { LocalStorageAccessTokenKey } from './shared/constants';
14
14
  import { emit, on } from './shared/event-manager';
15
15
  import * as bridge from './shared/bridge-client';
16
- import { validateHppLoadParams, validateVerifyCardParams, toHumanizedErrors, } from './validation';
16
+ import { validateHppLoadParams, validateVerifyCardParams, toHumanizedErrors, validateClickToPayLoadParams, } from './validation';
17
17
  import GatewayClient from './shared/api-gateway-client';
18
18
  import { Hpp } from './hpp';
19
19
  import { PayPalCheckout } from './paypal/paypal-checkout';
20
+ import ClickToPay from './click_to_pay';
20
21
  export default class FatZebra {
21
22
  constructor(config) {
22
23
  this.fzConfig = config;
@@ -121,6 +122,22 @@ export default class FatZebra {
121
122
  });
122
123
  window.HPP.load(params);
123
124
  }
125
+ renderClickToPay(params) {
126
+ const valid = validateClickToPayLoadParams(params);
127
+ if (!valid) {
128
+ emit(PublicEvent.VALIDATION_ERROR, {
129
+ errors: toHumanizedErrors(validateClickToPayLoadParams.errors),
130
+ data: null
131
+ });
132
+ return;
133
+ }
134
+ window.HPP = new ClickToPay({
135
+ paymentIntent: params.paymentIntent,
136
+ username: this.fzConfig.username,
137
+ test: this.fzConfig.test,
138
+ });
139
+ window.HPP.load(params);
140
+ }
124
141
  checkout() {
125
142
  window.HPP.purchase();
126
143
  }
@@ -0,0 +1 @@
1
+ /** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
package/dist/react/url.js CHANGED
@@ -9,14 +9,10 @@ const generatePaymentURL = (values, environment) => {
9
9
  "postmessage",
10
10
  "hide_card_holder",
11
11
  "hide_button",
12
- "return_path",
13
- "card_types",
14
- "surcharge_enabled",
15
12
  "sca_enabled",
16
13
  ];
17
14
  const environmentConfig = env[environment || Environment.sandbox];
18
15
  const urlTemplate = parseTemplate(`${environmentConfig.payNowUrl}/sdk/v3/{merchant}/{reference}/{currency}/{amount}/{verification}{?${queryParts.join(",")}}`);
19
- console.log(values);
20
16
  const url = urlTemplate.expand({
21
17
  merchant: values.merchant,
22
18
  reference: values.reference,
@@ -29,7 +29,7 @@ declare class Sca {
29
29
  private successCallback;
30
30
  private failureCallback;
31
31
  private environmentConfig;
32
- constructor({ gatewayClient, successCallback, failureCallback, environment }: ScaConfig);
32
+ constructor({ gatewayClient, successCallback, failureCallback }: ScaConfig);
33
33
  loadScript(): void;
34
34
  get cardinal(): CardinalManager;
35
35
  set cardinal(cardinal: CardinalManager);
package/dist/sca/index.js CHANGED
@@ -14,12 +14,14 @@ import { CardinalManager, } from './cardinal';
14
14
  import { emit, } from '../shared/event-manager';
15
15
  import { toFzSli } from './eci-mappings';
16
16
  import env, { Environment } from "../shared/env";
17
+ import { failedEnrollmentRequestScenario } from './scenarios/enrollment';
18
+ import { failedValidationRequestScenario } from './scenarios/validation';
17
19
  class Sca {
18
- constructor({ gatewayClient, successCallback, failureCallback, environment }) {
20
+ constructor({ gatewayClient, successCallback, failureCallback }) {
19
21
  this.gatewayClient = gatewayClient;
20
22
  this.successCallback = successCallback;
21
23
  this.failureCallback = failureCallback;
22
- this.environmentConfig = env[environment || Environment.sandbox];
24
+ this.environmentConfig = env[gatewayClient.environment || Environment.sandbox];
23
25
  }
24
26
  loadScript() {
25
27
  if (!document.getElementById("songbird-script")) {
@@ -59,7 +61,15 @@ class Sca {
59
61
  }
60
62
  run(config) {
61
63
  return __awaiter(this, void 0, void 0, function* () {
62
- this._cardinal = new CardinalManager();
64
+ try {
65
+ if (!this._cardinal) {
66
+ this._cardinal = new CardinalManager();
67
+ }
68
+ }
69
+ catch (error) {
70
+ this.reportFailure(`FatZebra.3DS: Failed to setup 3DS provider.`);
71
+ return;
72
+ }
63
73
  // Persist states until next 3DS run.
64
74
  this.paymentIntent = config.paymentIntent;
65
75
  this.bin = config.bin;
@@ -82,6 +92,7 @@ class Sca {
82
92
  this.sessionId = paymentsSetupCompleteResponse.sessionId;
83
93
  // Register handler. Called after OTP is entered on challenge prompt.
84
94
  this._cardinal.onPaymentValidated((data, error) => __awaiter(this, void 0, void 0, function* () {
95
+ var _a;
85
96
  if (typeof error == 'string') {
86
97
  this.reportFailure(`FatZebra.3DS: Validation failed. ${error}.`);
87
98
  return;
@@ -114,7 +125,8 @@ class Sca {
114
125
  this.reportSuccess(`FatZebra.3DS: 3DS success - ${scenario.description}.`, threedsData);
115
126
  }
116
127
  else {
117
- this.reportFailure(`FatZebra.3DS: 3DS error - ${scenario.description} - ${scenario.outcome.errorCode}`, {
128
+ const failureMessage = [scenario.description, (_a = scenario.outcome) === null || _a === void 0 ? void 0 : _a.errorCode].filter(Boolean).join(' - ');
129
+ this.reportFailure(`FatZebra.3DS: 3DS error - ${failureMessage}`, {
118
130
  errorCode: scenario.outcome.errorCode,
119
131
  });
120
132
  }
@@ -188,6 +200,7 @@ class Sca {
188
200
  return properties;
189
201
  }
190
202
  handleEnrollmentResult(enrollSCAResponse) {
203
+ var _a;
191
204
  const threedsData = threedsResponseData(enrollSCAResponse);
192
205
  const scenario = getEnrollmentResult(enrollSCAResponse);
193
206
  if (scenario.outcome.authenticationType === 'challenge') {
@@ -198,7 +211,8 @@ class Sca {
198
211
  this.reportSuccess(`FatZebra.3DS: 3DS success - ${scenario.description}.`, threedsData);
199
212
  }
200
213
  else {
201
- this.reportFailure(`FatZebra.3DS: 3DS error - ${scenario.description} - ${scenario.outcome.errorCode}`, { errorCode: scenario.outcome.errorCode });
214
+ const failureMessage = [scenario.description, (_a = scenario.outcome) === null || _a === void 0 ? void 0 : _a.errorCode].filter(Boolean).join(' - ');
215
+ this.reportFailure(`FatZebra.3DS: 3DS error - ${failureMessage}`, { errorCode: scenario.outcome.errorCode });
202
216
  }
203
217
  }
204
218
  }
@@ -211,27 +225,29 @@ const threedsResponseData = (response) => {
211
225
  sli: toFzSli(response.eci),
212
226
  xid: response.xid,
213
227
  ver: response.enrolled,
214
- directoryServerTxnId: response.directory_server_txn_id,
215
- threedsVersion: response.version,
228
+ directory_server_txn_id: response.directory_server_txn_id,
229
+ threeds_version: response.version,
216
230
  };
217
231
  };
218
232
  const getEnrollmentResult = (enrollment) => {
219
- return enrollmentScenarios.find((item) => {
233
+ const result = enrollmentScenarios.find((item) => {
220
234
  return item.reasonCode === enrollment.reason_code &&
221
235
  item.veresEnrolled === enrollment.enrolled &&
222
236
  item.pares === enrollment.pares &&
223
237
  item.threedsVersion === getMajor3dsVersion(enrollment.version);
224
238
  });
239
+ return result || failedEnrollmentRequestScenario;
225
240
  };
226
241
  const getValidationResult = (validation) => {
227
- return validationScenarios.find((item) => {
242
+ const result = validationScenarios.find((item) => {
228
243
  return item.reasonCode === validation.reason_code &&
229
244
  item.pares === validation.pares &&
230
245
  item.threedsVersion === getMajor3dsVersion(validation.version);
231
246
  });
247
+ return result || failedValidationRequestScenario;
232
248
  };
233
249
  // 3DS versioning follows SEMVER format. The first charactor is the major version number.
234
250
  const getMajor3dsVersion = (original) => {
235
- return original[0];
251
+ return original === null || original === void 0 ? void 0 : original[0];
236
252
  };
237
253
  export default Sca;
@@ -11,6 +11,7 @@ interface EnrollmentScenario {
11
11
  errorCode?: string;
12
12
  };
13
13
  }
14
+ declare const failedEnrollmentRequestScenario: EnrollmentScenario;
14
15
  declare const enrollmentScenarios: EnrollmentScenario[];
15
- export { enrollmentScenarios };
16
+ export { enrollmentScenarios, failedEnrollmentRequestScenario };
16
17
  export type { EnrollmentScenario };
@@ -1,4 +1,14 @@
1
1
  import { ScaErrorCode, VEResEnrolled, PARes } from '../types';
2
+ const failedEnrollmentRequestScenario = {
3
+ description: 'Enrollment Request Failed',
4
+ threedsVersion: null,
5
+ reasonCode: null,
6
+ veresEnrolled: null,
7
+ pares: null,
8
+ outcome: {
9
+ success: false, // no liability shift
10
+ },
11
+ };
2
12
  const enrollmentScenarios = [
3
13
  /***************************************************************/
4
14
  /********************** 3DS2 scenarios *************************/
@@ -143,4 +153,4 @@ const enrollmentScenarios = [
143
153
  }
144
154
  },
145
155
  ];
146
- export { enrollmentScenarios };
156
+ export { enrollmentScenarios, failedEnrollmentRequestScenario };
@@ -11,6 +11,7 @@ interface ValidationScenario {
11
11
  errorCode?: string;
12
12
  };
13
13
  }
14
+ declare const failedValidationRequestScenario: ValidationScenario;
14
15
  declare const validationScenarios: ValidationScenario[];
15
- export { validationScenarios };
16
+ export { validationScenarios, failedValidationRequestScenario };
16
17
  export type { ValidationScenario };
@@ -1,4 +1,14 @@
1
1
  import { ScaErrorCode, PARes } from '../types';
2
+ const failedValidationRequestScenario = {
3
+ description: 'Validation Request Failed',
4
+ threedsVersion: null,
5
+ reasonCode: null,
6
+ veresEnrolled: null,
7
+ pares: null,
8
+ outcome: {
9
+ success: false, // no liability shift
10
+ },
11
+ };
2
12
  const validationScenarios = [
3
13
  /***************************************************************/
4
14
  /********************** 3DS2 scenarios *************************/
@@ -121,4 +131,4 @@ const validationScenarios = [
121
131
  }
122
132
  },
123
133
  ];
124
- export { validationScenarios };
134
+ export { validationScenarios, failedValidationRequestScenario };
@@ -28,8 +28,8 @@ interface ThreedsData {
28
28
  sli: string;
29
29
  xid: string;
30
30
  ver: string;
31
- directoryServerTxnId: string;
32
- threedsVersion: string;
31
+ directory_server_txn_id: string;
32
+ threeds_version: string;
33
33
  }
34
34
  interface EnrollSCARequest {
35
35
  amount: number;
@@ -55,7 +55,12 @@ class GatewayClient {
55
55
  }
56
56
  validateSCA(data) {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
- return this.client.post("/sca/validation", data);
58
+ return this.client.post("/sca/validation", data).then((response) => response).catch(err => {
59
+ if (err.response && err.response.status == 422) {
60
+ return err.response;
61
+ }
62
+ throw err;
63
+ });
59
64
  });
60
65
  }
61
66
  getCard(data) {
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { NODE_ENV } from '../shared/types';
11
+ import env from './env';
11
12
  const domain = process.env.PAYNOW_BASE_URL;
12
13
  // NODE_ENV is introduced to PostMessageClient purely for the purpose of bypassing security
13
14
  // check on the postMessage event between parent and child frames. Unforunately there is
@@ -17,6 +18,7 @@ class PostMessageClient {
17
18
  this.channel = config.channel;
18
19
  this.fzEnv = process.env.NODE_ENV;
19
20
  this.target = config.target;
21
+ this.domain = env[this.fzEnv];
20
22
  }
21
23
  // Handle event messages that conform to PostMessage format.
22
24
  setEventListeners(handlers) {
@@ -98,6 +98,7 @@ export type PaymentConfig = {
98
98
  };
99
99
  export type OptionalUrlValues = {
100
100
  hide_card_holder?: boolean;
101
+ hide_button?: boolean;
101
102
  return_path?: string;
102
103
  card_types?: Array<string>;
103
104
  surcharge_enabled?: string;
@@ -105,7 +106,6 @@ export type OptionalUrlValues = {
105
106
  css?: string;
106
107
  css_signature?: string;
107
108
  tokenize_only?: boolean;
108
- hide_button?: boolean;
109
109
  };
110
110
  declare global {
111
111
  interface Window {