@fat-zebra/sdk 1.2.1 → 1.2.2
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/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/dist/env.d.ts +0 -5
- package/dist/env.development.d.ts +0 -5
- package/dist/env.development.js +0 -5
- package/dist/env.js +0 -5
- package/dist/local/fatzebra.js +0 -17728
- package/dist/local/fatzebra.js.map +0 -1
- package/dist/local/index.html +0 -247
- package/dist/sca/sca.d.ts +0 -42
- package/dist/sca/sca.js +0 -273
- package/dist/src/applepay/applepay.js +0 -198
- package/dist/src/applepay/applepay.js.map +0 -1
- package/dist/src/applepay/clients/apple-pay-client.js +0 -66
- package/dist/src/applepay/clients/apple-pay-client.js.map +0 -1
- package/dist/src/applepay/clients/paynow-client.js +0 -96
- package/dist/src/applepay/clients/paynow-client.js.map +0 -1
- package/dist/src/applepay/index.js +0 -6
- package/dist/src/applepay/index.js.map +0 -1
- package/dist/src/hpp/hpp.js +0 -230
- package/dist/src/hpp/hpp.js.map +0 -1
- package/dist/src/hpp/hpp.test.js +0 -135
- package/dist/src/hpp/hpp.test.js.map +0 -1
- package/dist/src/hpp/index.js +0 -6
- package/dist/src/hpp/index.js.map +0 -1
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +0 -1
- package/dist/src/main.js +0 -225
- package/dist/src/main.js.map +0 -1
- package/dist/src/main.test.js +0 -236
- package/dist/src/main.test.js.map +0 -1
- package/dist/src/paypal/paypal-button.js +0 -311
- package/dist/src/paypal/paypal-button.js.map +0 -1
- package/dist/src/paypal/paypal-button.test.js +0 -41
- package/dist/src/paypal/paypal-button.test.js.map +0 -1
- package/dist/src/paypal/paypal-checkout.js +0 -111
- package/dist/src/paypal/paypal-checkout.js.map +0 -1
- package/dist/src/paypal/paypal-checkout.test.js +0 -167
- package/dist/src/paypal/paypal-checkout.test.js.map +0 -1
- package/dist/src/paypal/types.js +0 -9
- package/dist/src/paypal/types.js.map +0 -1
- package/dist/src/paypal/validation.js +0 -73
- package/dist/src/paypal/validation.js.map +0 -1
- package/dist/src/sca/__tests__/eci-mappings.test.js +0 -31
- package/dist/src/sca/__tests__/eci-mappings.test.js.map +0 -1
- package/dist/src/sca/__tests__/index.test.js +0 -558
- package/dist/src/sca/__tests__/index.test.js.map +0 -1
- package/dist/src/sca/cardinal.js +0 -110
- package/dist/src/sca/cardinal.js.map +0 -1
- package/dist/src/sca/eci-mappings.js +0 -63
- package/dist/src/sca/eci-mappings.js.map +0 -1
- package/dist/src/sca/eci-mappings.test.js +0 -31
- package/dist/src/sca/eci-mappings.test.js.map +0 -1
- package/dist/src/sca/index.js +0 -388
- package/dist/src/sca/index.js.map +0 -1
- package/dist/src/sca/index.test.js +0 -558
- package/dist/src/sca/index.test.js.map +0 -1
- package/dist/src/sca/scenarios/enrollment.js +0 -150
- package/dist/src/sca/scenarios/enrollment.js.map +0 -1
- package/dist/src/sca/scenarios/index.js +0 -8
- package/dist/src/sca/scenarios/index.js.map +0 -1
- package/dist/src/sca/scenarios/validation.js +0 -128
- package/dist/src/sca/scenarios/validation.js.map +0 -1
- package/dist/src/sca/types.js +0 -57
- package/dist/src/sca/types.js.map +0 -1
- package/dist/src/shared/api-gateway-client.js +0 -150
- package/dist/src/shared/api-gateway-client.js.map +0 -1
- package/dist/src/shared/bridge-client.js +0 -24
- package/dist/src/shared/bridge-client.js.map +0 -1
- package/dist/src/shared/constants.js +0 -19
- package/dist/src/shared/constants.js.map +0 -1
- package/dist/src/shared/event-manager.js +0 -15
- package/dist/src/shared/event-manager.js.map +0 -1
- package/dist/src/shared/post-message-client.js +0 -107
- package/dist/src/shared/post-message-client.js.map +0 -1
- package/dist/src/shared/post-message-client.test.js +0 -58
- package/dist/src/shared/post-message-client.test.js.map +0 -1
- package/dist/src/shared/types.js +0 -47
- package/dist/src/shared/types.js.map +0 -1
- package/dist/src/shared/types.test.js +0 -55
- package/dist/src/shared/types.test.js.map +0 -1
- package/dist/src/shared/util.js +0 -96
- package/dist/src/shared/util.js.map +0 -1
- package/dist/src/shared/util.test.js +0 -148
- package/dist/src/shared/util.test.js.map +0 -1
- package/dist/src/validation/index.js +0 -10
- package/dist/src/validation/index.js.map +0 -1
- package/dist/src/validation/validation-helper.js +0 -10
- package/dist/src/validation/validation-helper.js.map +0 -1
- package/dist/src/validation/validation-helper.test.js +0 -34
- package/dist/src/validation/validation-helper.test.js.map +0 -1
- package/dist/src/validation/validators/hpp-load-params-validator.js +0 -17
- package/dist/src/validation/validators/hpp-load-params-validator.js.map +0 -1
- package/dist/src/validation/validators/hpp-load-params-validator.test.js +0 -56
- package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +0 -1
- package/dist/src/validation/validators/verify-card-params-validator.js +0 -18
- package/dist/src/validation/validators/verify-card-params-validator.js.map +0 -1
- package/dist/tests/helpers/api-gateway-mock.js +0 -36
- package/dist/tests/helpers/api-gateway-mock.js.map +0 -1
package/dist/local/index.html
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
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/sca/sca.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as t from './types';
|
|
2
|
-
import { Customer, CustomerSnakeCase, PaymentIntent } from '../shared/types';
|
|
3
|
-
import { CardinalManager } from './cardinal';
|
|
4
|
-
interface ScaConfig {
|
|
5
|
-
cardToken: string;
|
|
6
|
-
customer?: Customer;
|
|
7
|
-
paymentIntent: PaymentIntent;
|
|
8
|
-
bin: string;
|
|
9
|
-
challengeWindowSize?: t.ChallengeWindowSize;
|
|
10
|
-
}
|
|
11
|
-
interface ThreedsData {
|
|
12
|
-
cavv: string;
|
|
13
|
-
par: string;
|
|
14
|
-
sli: string;
|
|
15
|
-
xid: string;
|
|
16
|
-
ver: string;
|
|
17
|
-
directoryServerTxnId: string;
|
|
18
|
-
threedsVersion: string;
|
|
19
|
-
}
|
|
20
|
-
declare class Sca {
|
|
21
|
-
private _cardinal;
|
|
22
|
-
private _eventEmitTarget;
|
|
23
|
-
private enrollmentResult;
|
|
24
|
-
private paymentIntent;
|
|
25
|
-
private bin;
|
|
26
|
-
private cardToken;
|
|
27
|
-
private customer;
|
|
28
|
-
private challengeWindowSize;
|
|
29
|
-
private sessionId;
|
|
30
|
-
constructor();
|
|
31
|
-
loadScript(): void;
|
|
32
|
-
get cardinal(): CardinalManager;
|
|
33
|
-
set cardinal(cardinal: CardinalManager);
|
|
34
|
-
get eventEmitTarget(): HTMLDivElement | Window;
|
|
35
|
-
set eventEmitTarget(target: HTMLDivElement | Window);
|
|
36
|
-
run(config: ScaConfig): Promise<void>;
|
|
37
|
-
createCardinalJWT(): Promise<string>;
|
|
38
|
-
check3DSEnrollment(): Promise<void>;
|
|
39
|
-
customerProperties(customer: Customer): CustomerSnakeCase;
|
|
40
|
-
handleEnrollmentResult(enrollSCAResponse: t.EnrollSCAResponse): void;
|
|
41
|
-
}
|
|
42
|
-
export { Sca, ThreedsData, ScaConfig };
|
package/dist/sca/sca.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { createSCASession, decodeSCASession, enrolSCA, validateSCA, } from '../shared/api-gateway-client';
|
|
11
|
-
import * as t from './types';
|
|
12
|
-
import { enrollmentScenarios, validationScenarios, } from './scenarios';
|
|
13
|
-
import { PublicEvent, } from '../shared/types';
|
|
14
|
-
import { CardinalManager, } from './cardinal';
|
|
15
|
-
import { emit, } from '../shared/event-manager';
|
|
16
|
-
import { toFzSli } from './eci-mappings';
|
|
17
|
-
class Sca {
|
|
18
|
-
constructor() {
|
|
19
|
-
this._eventEmitTarget = window;
|
|
20
|
-
this.sessionId = null;
|
|
21
|
-
}
|
|
22
|
-
loadScript() {
|
|
23
|
-
const script = document.createElement('script');
|
|
24
|
-
script.type = 'text/javascript';
|
|
25
|
-
script.src = process.env.SONGBIRD_URL;
|
|
26
|
-
script.async = true;
|
|
27
|
-
script.onload = () => {
|
|
28
|
-
this._cardinal = new CardinalManager();
|
|
29
|
-
};
|
|
30
|
-
document.body.appendChild(script);
|
|
31
|
-
}
|
|
32
|
-
get cardinal() {
|
|
33
|
-
return this._cardinal;
|
|
34
|
-
}
|
|
35
|
-
set cardinal(cardinal) {
|
|
36
|
-
this._cardinal = cardinal;
|
|
37
|
-
}
|
|
38
|
-
get eventEmitTarget() {
|
|
39
|
-
return this._eventEmitTarget;
|
|
40
|
-
}
|
|
41
|
-
// Specify the DOM element to which the SCA results are outputted.
|
|
42
|
-
set eventEmitTarget(target) {
|
|
43
|
-
this._eventEmitTarget = target;
|
|
44
|
-
}
|
|
45
|
-
run(config) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
// Persist states until next 3DS run.
|
|
48
|
-
this.paymentIntent = config.paymentIntent;
|
|
49
|
-
this.bin = config.bin;
|
|
50
|
-
this.cardToken = config.cardToken;
|
|
51
|
-
this.customer = config.customer;
|
|
52
|
-
this.challengeWindowSize = config.challengeWindowSize || t.ChallengeWindowSize.SIZE_FULL_PAGE;
|
|
53
|
-
let cardinalJwt;
|
|
54
|
-
// Generate Cardinal JWT
|
|
55
|
-
try {
|
|
56
|
-
cardinalJwt = yield this.createCardinalJWT();
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
const message = 'FatZebra.3DS: JWT creation failed.';
|
|
60
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
61
|
-
errors: [message],
|
|
62
|
-
data: null
|
|
63
|
-
});
|
|
64
|
-
console.log(message);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
// Init cardinal
|
|
68
|
-
this._cardinal.setup(cardinalJwt);
|
|
69
|
-
if (!this.sessionId) {
|
|
70
|
-
const paymentsSetupCompleteResponse = yield this._cardinal.onPaymentSetupComplete();
|
|
71
|
-
this.sessionId = paymentsSetupCompleteResponse.sessionId;
|
|
72
|
-
// Register handler. Called after OTP is entered on challenge prompt.
|
|
73
|
-
this._cardinal.onPaymentValidated((data, error) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
if (typeof error == 'string') {
|
|
75
|
-
const message = `FatZebra.3DS: Validation failed. ${error}.`;
|
|
76
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
77
|
-
errors: [message],
|
|
78
|
-
data: null,
|
|
79
|
-
});
|
|
80
|
-
console.log(message);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const decodeSCASessionResponse = (yield decodeSCASession({
|
|
84
|
-
token: data.jwt
|
|
85
|
-
})).data;
|
|
86
|
-
if (data.processorTransactionId !== decodeSCASessionResponse.processor_transaction_id) {
|
|
87
|
-
const message = 'FatZebra.3DS: Validation failed. Invalid process transaction id.';
|
|
88
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
89
|
-
errors: [message],
|
|
90
|
-
data: null
|
|
91
|
-
});
|
|
92
|
-
console.log(message);
|
|
93
|
-
}
|
|
94
|
-
let validateSCAResponse;
|
|
95
|
-
try {
|
|
96
|
-
const requestParams = {
|
|
97
|
-
amount: this.paymentIntent.payment.amount,
|
|
98
|
-
authentication_transaction_id: this.enrollmentResult.authentication_transaction_id,
|
|
99
|
-
card_token: this.cardToken,
|
|
100
|
-
currency: this.paymentIntent.payment.currency,
|
|
101
|
-
pareq: this.enrollmentResult.pareq,
|
|
102
|
-
reference: this.paymentIntent.payment.reference,
|
|
103
|
-
};
|
|
104
|
-
validateSCAResponse = (yield validateSCA(requestParams)).data;
|
|
105
|
-
}
|
|
106
|
-
catch (errorResponse) {
|
|
107
|
-
const message = 'FatZebra.3DS: Validation failed. Server error.';
|
|
108
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
109
|
-
errors: [message],
|
|
110
|
-
data: null,
|
|
111
|
-
});
|
|
112
|
-
console.log(message);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const threedsData = threedsResponseData(validateSCAResponse);
|
|
116
|
-
const scenario = getValidationResult(validateSCAResponse);
|
|
117
|
-
if (scenario.outcome.success) {
|
|
118
|
-
const message = `FatZebra.3DS: 3DS success - ${scenario.description}.`;
|
|
119
|
-
emit(PublicEvent.SCA_SUCCESS, {
|
|
120
|
-
message,
|
|
121
|
-
data: threedsData,
|
|
122
|
-
});
|
|
123
|
-
console.log(message);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
const message = `FatZebra.3DS: 3DS error - ${scenario.description}`;
|
|
127
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
128
|
-
errors: [message],
|
|
129
|
-
data: {
|
|
130
|
-
errorCode: scenario.outcome.errorCode
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
console.log(message);
|
|
134
|
-
}
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
// Cardinal processs BIN using directory server. This determines the 3DS version used.
|
|
138
|
-
try {
|
|
139
|
-
yield this._cardinal.processBin(this.bin);
|
|
140
|
-
}
|
|
141
|
-
catch (err) {
|
|
142
|
-
const message = 'FatZebra.3DS: BIN verification failed.';
|
|
143
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
144
|
-
errors: [message],
|
|
145
|
-
data: null
|
|
146
|
-
});
|
|
147
|
-
console.log(message);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
try {
|
|
151
|
-
yield this.check3DSEnrollment();
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
const message = 'FatZebra.3DS: Enrollment failed. Server error.';
|
|
155
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
156
|
-
errors: [message],
|
|
157
|
-
data: null
|
|
158
|
-
});
|
|
159
|
-
console.log(message);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this.handleEnrollmentResult(this.enrollmentResult);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
createCardinalJWT() {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const { payment } = this.paymentIntent;
|
|
168
|
-
const response = (yield createSCASession({
|
|
169
|
-
amount: payment.amount,
|
|
170
|
-
currency: payment.currency,
|
|
171
|
-
hide_card_holder: payment.hide_card_holder,
|
|
172
|
-
})).data;
|
|
173
|
-
return response.jwt;
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
check3DSEnrollment() {
|
|
177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
// Persist enrollResult state in memory for handlePaymentValidation handler
|
|
179
|
-
this.enrollmentResult = (yield enrolSCA({
|
|
180
|
-
amount: this.paymentIntent.payment.amount,
|
|
181
|
-
card_token: this.cardToken,
|
|
182
|
-
currency: this.paymentIntent.payment.currency,
|
|
183
|
-
reference: this.paymentIntent.payment.reference,
|
|
184
|
-
verification: this.paymentIntent.verification,
|
|
185
|
-
session_id: this.sessionId,
|
|
186
|
-
challenge_window_size: this.challengeWindowSize,
|
|
187
|
-
hide_card_holder: this.paymentIntent.payment.hide_card_holder,
|
|
188
|
-
customer: this.customerProperties(this.customer),
|
|
189
|
-
})).data;
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
customerProperties(customer) {
|
|
193
|
-
let properties = {};
|
|
194
|
-
if (!customer)
|
|
195
|
-
return properties;
|
|
196
|
-
if (customer.firstName)
|
|
197
|
-
properties.first_name = customer.firstName;
|
|
198
|
-
if (customer.lastName)
|
|
199
|
-
properties.last_name = customer.lastName;
|
|
200
|
-
if (customer.email)
|
|
201
|
-
properties.email = customer.email;
|
|
202
|
-
if (customer.address)
|
|
203
|
-
properties.address = customer.address;
|
|
204
|
-
if (customer.city)
|
|
205
|
-
properties.city = customer.city;
|
|
206
|
-
if (customer.state)
|
|
207
|
-
properties.state = customer.state;
|
|
208
|
-
if (customer.postcode)
|
|
209
|
-
properties.postcode = customer.postcode;
|
|
210
|
-
if (customer.country)
|
|
211
|
-
properties.country = customer.country;
|
|
212
|
-
return properties;
|
|
213
|
-
}
|
|
214
|
-
handleEnrollmentResult(enrollSCAResponse) {
|
|
215
|
-
const threedsData = threedsResponseData(enrollSCAResponse);
|
|
216
|
-
const scenario = getEnrollmentResult(enrollSCAResponse);
|
|
217
|
-
if (scenario.outcome.authenticationType === 'challenge') {
|
|
218
|
-
this._cardinal.continue(enrollSCAResponse.acs_url, enrollSCAResponse.pareq, enrollSCAResponse.authentication_transaction_id);
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (scenario.outcome.success) {
|
|
222
|
-
const message = `FatZebra.3DS: 3DS success - ${scenario.description}.`;
|
|
223
|
-
emit(PublicEvent.SCA_SUCCESS, {
|
|
224
|
-
message,
|
|
225
|
-
data: threedsData,
|
|
226
|
-
});
|
|
227
|
-
console.log(message);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
const message = `FatZebra.3DS: 3DS error - ${scenario.description}`;
|
|
231
|
-
emit(PublicEvent.SCA_ERROR, {
|
|
232
|
-
errors: [message],
|
|
233
|
-
data: {
|
|
234
|
-
errorCode: scenario.outcome.errorCode
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
console.log(message);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const threedsResponseData = (response) => {
|
|
242
|
-
return {
|
|
243
|
-
// CAVV: Visa & Amex only
|
|
244
|
-
// AAV: Mastercard only, known as UCAF
|
|
245
|
-
cavv: response.cavv || response.aav,
|
|
246
|
-
par: response.pares,
|
|
247
|
-
sli: toFzSli(response.eci),
|
|
248
|
-
xid: response.xid,
|
|
249
|
-
ver: response.enrolled,
|
|
250
|
-
directoryServerTxnId: response.directory_server_txn_id,
|
|
251
|
-
threedsVersion: response.version,
|
|
252
|
-
};
|
|
253
|
-
};
|
|
254
|
-
const getEnrollmentResult = (enrollment) => {
|
|
255
|
-
return enrollmentScenarios.find((item) => {
|
|
256
|
-
return item.reasonCode === enrollment.reason_code &&
|
|
257
|
-
item.veresEnrolled === enrollment.enrolled &&
|
|
258
|
-
item.pares === enrollment.pares &&
|
|
259
|
-
item.threedsVersion === getMajor3dsVersion(enrollment.version);
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
const getValidationResult = (validation) => {
|
|
263
|
-
return validationScenarios.find((item) => {
|
|
264
|
-
return item.reasonCode === validation.reason_code &&
|
|
265
|
-
item.pares === validation.pares &&
|
|
266
|
-
item.threedsVersion === getMajor3dsVersion(validation.version);
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
// 3DS versioning follows SEMVER format. The first charactor is the major version number.
|
|
270
|
-
const getMajor3dsVersion = (original) => {
|
|
271
|
-
return original[0];
|
|
272
|
-
};
|
|
273
|
-
export { Sca };
|