PageSourceSearch

https://driveshaftshop.com/wp-content/plugins/woocommerce-ebizchar…/assets/js/EBiz3DSecure.js?ver=1

js driveshaftshop.com collected 2026-10-08 10:21:45 UTC 24,775 bytes, 551 lines download raw bytes

1
2const server = true;
3class EBiz3DSecure {
4
5    constructor(SecurityToken) {
6        this.intervalPointer = 0;
7        var urlParams = new URLSearchParams(window.location.search);
8        var hid3DSecurityToken = urlParams.get('hid3DSecurityToken');
9        var hidMerchantSecurityToken = urlParams.get('hidMerchantSecurityToken');
10
11        if (hid3DSecurityToken != null || hid3DSecurityToken == "")
12            this.guid = hid3DSecurityToken;
13        else {
14            this.server = true;
15            var obj = document.getElementById("hid3DSecurityToken");
16            if (obj != null) {
17                this.guid = obj.value;
18            }
19            else
20                this.server = false;
21        }
22
23        if (hidMerchantSecurityToken != null || hidMerchantSecurityToken == "")
24            this.merchantSecurityToken = hidMerchantSecurityToken;
25        else {
26            this.server = true;
27            var obj = document.getElementById("hidMerchantSecurityToken");
28            if (obj != null) {
29                this.merchantSecurityToken = obj.value;
30            }
31            else {
32                this.merchantSecurityToken = SecurityToken;
33                this.server = false;
34            }
35        }
36
37
38        //this.hostUrl = "https://localhost:7257/";
39        //this.hostUrl = "https://ebizcharge3ds.azurewebsites.net/";
40        //this.hostUrl = "https://ebizchargeapps101-3dsecure.azurewebsites.net/";
41        this.hostUrl = "https://3dsapi.ebizcharge.net/";
42        //this.hostUrl="https://ebizcharge3ds-staging1.azurewebsites.net/"
43        this.JWT = "";
44
45        this.AuthenticateCallback = null;
46        //${this.hostUrl}
47
48        fetch(`${this.hostUrl}V2/CreateJWT`,
49            {
50                method: 'get',
51                headers: {
52                    'Content-Type': 'application/json',
53                    'securitytoken': this.merchantSecurityToken,
54                    'relay_me': '1',
55                },
56            }).then((data) => {
57            data.json().then((objData) => {
58                this.JWT = objData.jwt;
59                this.createSongBird().then((data) => {
60                }).catch((data) => {
61                    alert("Cannot create JWT");
62
63                });
64            });
65        }).catch((data) => {
66            console.log(data);
67        });
68
69    }
70
71    start = () => {
72        if (this.intervalPointer == 0)
73            this.intervalPointer = setInterval(this.getConnectionstatus, 3000);
74    }
75
76    stop = () => {
77        clearInterval(this.intervalPointer);
78        this.intervalPointer = 0;
79    }
80
81    getConnectionstatus = () => {
82        if (this.guid == null || this.guid == "undefined") {
83            if (hid3DSecurityToken != null || hid3DSecurityToken == "")
84                this.guid = hid3DSecurityToken;
85            else {
86                this.server = true;
87                var obj = document.getElementById("hid3DSecurityToken");
88                if (obj != null) {
89                    this.guid = obj.value;
90                }
91                else
92                    this.server = false;
93            }
94            if (this.guid == null || this.guid == "undefined") {
95                return;
96            }
97        }
98        fetch(`${this.hostUrl}V2/GetConnectionStatus/${this.guid}`,
99            {
100                method: 'get',
101                headers: {
102                    'Content-Type': 'application/json',
103                    'GUID': this.guid,
104                    'SessionId': this.sessionId,
105                },
106            }).then((data) => {
107            data.json().then((objData) => {
108                if (objData.connectionStatus == "Challenge") {
109                    clearInterval(this.intervalPointer);
110                    this.intervalPointer = 0;
111                    this.TransactionId = objData.transactionId;
112                    this.cardinalContinue(objData.acsurl, objData.transactionId, objData.payload, this.Amount, this.CurrencyCode);
113                }
114                else if (objData.ConnectionStatus == "NoChallenge") {
115                    clearInterval(this.intervalPointer);
116                    this.intervalPointer = 0;
117                }
118
119            });
120        }).catch((data) => {
121        });
122    }
123
124    update3DsecureLogStatus = (guid, status, xid, cavv, paResStatus, eciFlag, authenticationType) => {
125        if (this.server) {
126
127            fetch(`${this.hostUrl}V2/Update3DSecureLogStatus/${guid}/${status}/${xid}/${cavv}/${paResStatus}/${eciFlag}/${authenticationType}`,
128                {
129                    method: 'get',
130                    headers: {
131                        'Content-Type': 'application/json',
132                        'GUID': this.guid,
133                    },
134                }).then((data) => {
135                data.json().then((objData) => {
136
137
138                }).catch((data) => {
139                });
140            }).catch((data) => {
141            });
142        }
143
144    }
145
146    createSongBird = () => {
147        var ret = new Promise((theSuccess, thefailure) => {
148            try {
149                var script = document.createElement('script');
150                script.src = "https://songbirdstag.cardinalcommerce.com/cardinalcruise/v1/songbird.js";
151                //script.src = "https://songbird.cardinalcommerce.com/edge/v1/songbird.js";
152                document.getElementsByTagName('head')[0].appendChild(script);
153                script.onload = () => {
154                    Cardinal.configure({
155                        timeout: 10000,
156                        extendedTimeout: 4000,
157                        maxRequestRetries: 2,
158                        logging: {
159                            level: "on"
160                        },
161                        payment: {
162                            view: 'modal',
163                            framework: 'cardinal',
164                            displayLoading: true,
165                            displayExitButton: false
166                        },
167                        visaCheckout: {
168                            button: {
169
170                                color: 'neutral',
171                                size: '',
172                                height: '94',
173                                width: '425',
174                                locale: ''
175                            }
176                        }
177
178                    });
179
180                    Cardinal.setup("init", {
181                        jwt: this.JWT
182                    });
183
184                    Cardinal.on('payments.setupComplete', (setupCompleteData) => {
185                        this.sessionId = setupCompleteData.sessionId;
186                        if (this.sessionId == null || this.guid == null || this.sessionId == "undefined" || this.guid == "undefined") {
187                            return;
188                        }
189                        fetch(`${this.hostUrl}V2/SetSessionId/${this.sessionId}/${this.guid}`,
190                            {
191                                method: 'get',
192                                headers: {
193                                    'Content-Type': 'application/json',
194                                    'GUID': this.guid,
195                                    'SessionId': this.sessionId,
196                                },
197                            }).then((data) => {
198
199                        }).catch((data) => {
200                        });
201                    });
202
203
204                    Cardinal.on("payments.validated", (data, jwt) => {
205                        switch (data.ActionCode) {
206                            case "SUCCESS":
207                                this.Authenticate("S");
208                                break;
209
210                            case "NOACTION":
211                                this.Authenticate("N");
212                                break;
213
214                            case "FAILURE":
215                                this.Authenticate("F");
216                                break;
217
218                            case "ERROR":
219                                this.Authenticate("E");
220                                break;
221                        }
222                    });
223
224                    theSuccess("Script loaded and ready!");
225                };
226
227
228            }
229            catch (ex) {
230                thefailure(ex.errorMessage);
231            }
232        });
233
234        return ret;
235    }
236
237    cardinalContinue = (AcsUrl, TransactionId, Payload, OrderNumber, Amount, CurrencyCode) => {
238        this.TransactionId = TransactionId;
239        Cardinal.continue('cca',
240            {
241                "AcsUrl": AcsUrl,
242                "Payload": Payload
243            },
244            {
245                "OrderDetails": {
246                    "TransactionId": TransactionId,
247                    "OrderNumber": OrderNumber,
248                    "Amount": Amount,
249                    "CurrencyCode": CurrencyCode
250                }
251            });
252    }
253
254    cardinalTrigger = (bintxt) => {
255        var bin = document.getElementById(bintxt);
256        Cardinal.trigger("bin.process", bin.value)
257            .then(function (results) {
258                if (results.Status) {
259                } else {
260                    alert("Bin profiling failed");
261                }
262
263            })
264            .catch(function (error) {
265                alert("An error occurred during profiling: " + error);
266            });
267    }
268
269    Authenticate = (ActionCode) => {
270        var a = JSON.stringify({ "TransactionId": this.TransactionId, "TransactionType": "C", "PAResPayload": "", "MerchantReferenceNumber": "" });
271        fetch(`${this.hostUrl}V2/CMPI_Authenticate`, {
272            method: 'post',
273            headers: {
274                //'Access-Control-Allow-Origin': true,
275                'Content-Type': 'application/json',
276                'securitytoken': this.merchantSecurityToken,
277            },
278            body: a
279        }).then((data) => {
280            data.json().then((objData) => {
281                if (objData.cavv == '') {
282                    objData.cavv = null;
283                }
284                if (objData.paResStatus == "Y" && objData.signatureVerification == "Y")
285                    this.update3DsecureLogStatus(this.guid, "S", objData.xid, objData.cavv, objData.paResStatus, objData.eciFlag, objData.authenticationType);
286                else
287                    this.update3DsecureLogStatus(this.guid, ActionCode, objData.xid, objData.cavv, objData.paResStatus, objData.eciFlag, objData.authenticationType);
288                if (this.AuthenticateCallback != null)
289                    this.AuthenticateCallback(objData);
290                clearInterval(this.intervalPointer);
291            });
292        }).catch((data) => {
293            clearInterval(this.intervalPointer);
294            this.intervalPointer = 0;
295            if (this.AuthenticateCallback != null)
296                this.AuthenticateCallback(objData);
297
298        });
299
300    }
301    Lookup = (LookupData) => {
302        var ret = new Promise((Success, Failure) => {
303
304            try {
305                this.AuthenticateCallback = (objdata) => {
306                    //|| objdata.enrolled == "B"
307                    if (((objdata.paResStatus == "Y" || objdata.paResStatus == "A") && objdata.signatureVerification == "Y")
308                        || (objdata.enrolled == "U" && objdata.reasonCode != "101" && objdata.reasonCode != "402")
309                        || (objdata.paResStatus != "C" && objdata.warning != undefined)) {
310                        Success(objdata);
311                    }
312                    else {
313                        Failure(objdata);
314
315                    }
316                }
317
318                var tempObj = {
319                    TransactionMode: "S",
320                    TransactionType: "C",
321
322                }
323
324
325                var t = JSON.stringify({
326                    "CustomerIntermalId": LookupData.CustomerInternalId,
327                    "MethodId": LookupData.MethodId,
328                    "MerchantId": "", "CardNumber": LookupData.CardNumber,
329                    "DFReferenceId": this.sessionId, "OrderNumber": LookupData.OrderNumber,
330                    "Amount": LookupData.Amount, "CurrencyCode": LookupData.CurrencyCode,
331                    "CardExpMonth": LookupData.ExpireMonth, "CardExpYear": LookupData.ExpireYear,
332                    "AcquirerId": "",
333                    "AcquirerMerchantId": "",
334                    "BillingAddress1": LookupData.BillingAddress, "BillingCity": LookupData.BillingCity,
335                    "BillingCountryCode": LookupData.BillingCountryCode, "BillingFirstName": LookupData.BillingFirstName,
336                    "BillingLastName": LookupData.BillingLastName, "BillingPhone": LookupData.BillingPhone,
337                    "BillingPostalCode": LookupData.Zip, "BillingState": LookupData.BillingState,
338                    "ShippingAddress1": LookupData.BillingAddress, "ShippingCity": LookupData.BillingCity,
339                    "ShippingCountryCode": LookupData.ShippingCountryCode, "ShippingFirstName": LookupData.BillingFirstName,
340                    "ShippingLastName": LookupData.BillingLastName,
341                    "ShippingMethodIndicator": "",
342                    "ShippingPostalCode": LookupData.Zip, "ShippingState": LookupData.BillingState,
343                    "ShippingAmount": LookupData.Amount, "MobilePhone": LookupData.phone, "Email": LookupData.Email,
344                    "BrowserJavascriptEnabled": true,
345                    "BrowserJavaEnabled": true,
346                    "BrowserScreenHeight": window.innerHeight.toString(),
347                    "BrowserScreenWidth": window.innerWidth.toString(),
348                    "UserAgent": window.navigator.userAgent,
349                    "BrowserHeader": "text/html",
350                    "BrowserLanguage": "en_US",
351                    "BrowserColorDepth": screen.colorDepth.toString(),
352                    "IPAddress": "",
353                    "DeviceChannel": "Browser",
354                    "BrowserTimeZone": "",
355                    "TransactionType": LookupData.TransactionType,
356                    "TransactionMode": LookupData.TransactionMode,
357                    "AcquirerCountryCode": "",
358                    "BillingAddress2": "",
359                    "BillingAddress3": "",
360                    "ShippingAddress2": "",
361                    "ShippingAddress3": "",
362                    "WorkPhone": "",
363                    "AuthenticationIndicator": "01",
364                    "ProductCode": "PHY",
365                    "ThreeDSVersion": "",
366                    "CardType": LookupData.CardType, //VSA - Visa, MSC - Mastercard, AMX - American Express, DSC - Discover
367                    "DeliveryTimeframe": "",
368                    "DeliveryEmail": "",
369                    "ReorderIndicator": "",
370                    "PreOrderIndicator": "",
371                    "PreOrderDate": "",
372                    "GiftCardAmount": "",
373                    "GiftCardCurrencyCode": "",
374                    "GiftCardCount": "",
375                    "CardinalEncryptedData": "",
376                    "AccountAgeIndicator": "",
377                    "AccountCreateDate": "",
378                    "AccountChangeIndicator": "",
379                    "AccountChangeDate": "",
380                    "AccountPwdChangeIndicator": "",
381                    "AccountPwdChangeDate": "",
382                    "ShippingAddressUsageIndicator": "",
383                    "ShippingAddressUsageDate": "",
384                    "TransactionCountDay": "",
385                    "TransactionCountYear": "",
386                    "AddCardAttempts": "",
387                    "AccountPurchases": "",
388                    "FraudActivity": "",
389                    "ShippingNameIndicator": "",
390                    "PaymentAccountIndicator": "",
391                    "AlternateAuthenticationMethod": "",
392                    "AlternateAuthenticationDate": "",
393                    "AlternateAuthenticationData": "",
394                    "AlternatePriorAuthenticationData": "",
395                    "AlternatePriorAuthenticationMethod": "",
396                    "AlternatePriorAuthenticationTime": "",
397                    "AlternatePriorAuthenticationRef": "",
398                    "Alias": "",
399                    "Token": "",
400                    "SdkMaxTimeout": "",
401                    "SDKFlowType": "",
402                    "ChallengeIndicator": "",
403                    "ACSWindowSize": "",
404                    "MerchantName": "",
405                    "AcquirerPassword": "",
406                    "RequestorId": "",
407                    "RequestorName": "",
408                    "CategoryCode": "",
409                    "CountryCodeOverride": "",
410                    "MessageCategory": "",
411                    "MerchantURL": "",
412                    "BillingFullName": "",
413                    "AddressMatch": "",
414                    "AccountId": "",
415                    "Custom_X": "",
416                    "Item_Desc_X": "",
417                    "Item_Name_X": "",
418                    "Item_Price_X": "",
419                    "Item_Quantity_X": "",
420                    "Item_ShippingAddress1_X": "",
421                    "Item_ShippingAddress2_X": "",
422                    "Item_ShippingCity_X": "",
423                    "Item_ShippingCountryCode_X": "",
424                    "Item_ShippingDestination_X": "",
425                    "Item_ShippingFirstName_X": "",
426                    "Item_ShippingLastName_X": "",
427                    "Item_ShippingMiddleName_X": "",
428                    "Item_ShippingPhone_X": "",
429                    "Item_ShippingPostalCode_X": "",
430                    "Item_ShippingState_X": "",
431                    "Item_SKU_X": "",
432                    "MerchantReferenceNumber": "",
433                    "OrderDescription": "",
434                    "ShippingDestination_X": "",
435                    "ShippingMiddleName": "",
436                    "TaxAmount": "",
437                    "OverridePaymentMethod": "",
438                    "ShippingFullName": "",
439                    "DecoupledMaxTime": "",
440                    "DecoupledIndicator": ""
441                });
442
443                fetch(`${this.hostUrl}V2/CMPI_Lookup`, {
444                    method: 'post',
445                    headers: {
446                        'Access-Control-Allow-Origin': true,
447                        'Content-Type': 'application/json',
448                        'securitytoken': this.merchantSecurityToken,
449                    },
450                    body: t
451                }).then((data) => {
452
453                    data.json().then((objData) => {
454                        this.TransactionId = objData.transactionId;
455                        if (objData.acsUrl != null && objData.acsUrl != "" && objData.enrolled == "Y" && objData.errorNo == "0")
456                            this.cardinalContinue(objData.acsUrl, objData.transactionId, objData.payload, LookupData.OrderNumber, LookupData.Amount, LookupData.CurrencyCode);
457                        else
458                            this.AuthenticateCallback(objData);
459                    });
460                }).catch((data) => {
461                });
462            }
463            catch {
464                Failure("Failure");
465            }
466        });
467        return ret;
468
469
470    }
471
472    EBiz3DSecureCheck = (LookupData) => {
473        this.CurrencyCode = LookupData.CurrencyCode;
474        this.Amount = LookupData.Amount;
475        var ret = new Promise((theSuccess, thefailure) => {
476            try {
477                if (this.JWT == null || this.JWT == "")
478                    return null;
479                this.Lookup(LookupData).then((data) => {
480                    data.resultCode = "A";
481                    console.log("sucsess:");
482                    console.log(data);
483                    theSuccess(data);
484
485                }).catch((data) => {
486                    data.resultCode = "E";
487                    console.log("failure:");
488                    console.log(data);
489                    thefailure(data);
490
491                });
492            }
493            catch (ex) {
494                thefailure(ex.errorMessage);
495            }
496
497        });
498        return ret;
499
500    }
501
502    GetErrorMessage = (OutputData) => {
503        var Message;
504        Message = "";
505        const errors_dictionary = new Array(
506            new Array("", "0", "N", "Y", "07", "", OutputData.cardHolderInfo, "Error#:2 Authentication failed by card Issuer, please try another card."),
507            new Array("", "0", "N", "Y", "00", "", OutputData.cardHolderInfo, "Error#:2 Authentication failed by card Issuer, please try another card."),
508            new Array("", "0", "U", "Y", "07", "", "", "Error#:4 Authentication is unavailable at the current time, please try again."),
509            new Array("", "0", "U", "Y", "00", "", "", "Error#:4 Authentication is unavailable at the current time, please try again."),
510            new Array("", "0", "R", "Y", "07", "", "", "Error#:5 Rejected authentication by the issuer, please try another card."),
511            new Array("", "0", "R", "Y", "00", "", "", "Error#:5 Rejected authentication by the issuer, please try another card."),
512            new Array("", "0", "", "U", "07", "101", "", "Error#:6 Authentication is unavailable due to a system error, please try again later."),
513            new Array("", "0", "", "U", "00", "101", "", "Error#:6 Authentication is unavailable due to a system error, please try again later."),
514            new Array("", "1001", "", "U", "07", "101", "", "Error#:7 An error occurred downstream while attempting authentication processing, please try again later."),
515            new Array("", "1001", "", "U", "00", "101", "", "Error#:7 An error occurred downstream while attempting authentication processing, please try again later."),
516            new Array("", "2860", "", "U", "07", "402", "", "Error#:8 Timeout encountered while attempting authentication processing, please try again later."),
517            new Array("", "2860", "", "U", "00", "402", "", "Error#:8 Timeout encountered while attempting authentication processing, please try again later."),
518            new Array("03", "0", "N", "", "07", "", "", "Error#:10 Your card can't be authenticated, please try another card."),
519            new Array("03", "0", "N", "", "00", "", "", "Error#:10 Your card can't be authenticated, please try another card."),
520            new Array("03", "0", "U", "", "07", "", "", "Error#:11 Authentication is unavailable, please try again."),
521            new Array("03", "0", "U", "", "00", "", "", "Error#:11 Authentication is unavailable, please try again."),
522            new Array("03", "1050", "U", "", "07", "", "", "Error#:12 A system error occurred while attempting to process the authentication request, please try another card."),
523            new Array("03", "1050", "U", "", "00", "", "", "Error#:12 A system error occurred while attempting to process the authentication request, please try another card."),
524            new Array("", "0", "", "B", "07", "", "", "Error#:13 Authentication is unavailable, please try another card."),
525            new Array("", "0", "", "B", "00", "", "", "Error#:13 Authentication is unavailable, please try another card."),
526            new Array("", "0", "C", "Y", "05", "", "", "Error#:14 Authentication is unavailable, please try another card."),
527            new Array("", "0", "C", "Y", "00", "", "", "Error#:14 Authentication is unavailable, please try another card."),
528        );
529
530        if (OutputData.authenticationType == undefined || OutputData.authenticationType == null) OutputData.authenticationType = "";
531        if (OutputData.errorNo == null) OutputData.errorNo = "";
532        if (OutputData.paResStatus == null) OutputData.paResStatus = "";
533        if (OutputData.enrolled == null) OutputData.enrolled = "";
534        if (OutputData.eciFlag == null) OutputData.eciFlag = "";
535        if (OutputData.reasonCode == null) OutputData.reasonCode = "";
536
537        errors_dictionary.forEach(row => {
538
539            if (row[0] == OutputData.authenticationType && row[1] == OutputData.errorNo &&
540                row[2] == OutputData.paResStatus && row[3] == OutputData.enrolled &&
541                row[4] == OutputData.eciFlag && row[5] == OutputData.reasonCode) {
542                Message = row[7] + " " + row[6];
543                return;
544            }
545        });
546        return Message;
547    }
548
549}
550
551let eBiz3DSecure;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.