PageSourceSearch

https://www.martinguitar.com/on/demandware.static/Sites-MartinGuit…/custom/cybersource-custom.js

js martinguitar.com collected 2026-10-01 11:27:04 UTC 21,352 bytes, 525 lines download raw bytes

vendor: 3,723 bytes, lines 1-89
1/*! ab v3.3.0 */
2/******/ (function(modules) { // webpackBootstrap
3/******/ 	// The module cache
4/******/ 	var installedModules = {};
5/******/
6/******/ 	// The require function
7/******/ 	function __webpack_require__(moduleId) {
8/******/
9/******/ 		// Check if module is in cache
10/******/ 		if(installedModules[moduleId]) {
11/******/ 			return installedModules[moduleId].exports;
12/******/ 		}
13/******/ 		// Create a new module (and put it into the cache)
14/******/ 		var module = installedModules[moduleId] = {
15/******/ 			i: moduleId,
16/******/ 			l: false,
17/******/ 			exports: {}
18/******/ 		};
19/******/
20/******/ 		// Execute the module function
21/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22/******/
23/******/ 		// Flag the module as loaded
24/******/ 		module.l = true;
25/******/
26/******/ 		// Return the exports of the module
27/******/ 		return module.exports;
28/******/ 	}
29/******/
30/******/
31/******/ 	// expose the modules object (__webpack_modules__)
32/******/ 	__webpack_require__.m = modules;
33/******/
34/******/ 	// expose the module cache
35/******/ 	__webpack_require__.c = installedModules;
36/******/
37/******/ 	// define getter function for harmony exports
38/******/ 	__webpack_require__.d = function(exports, name, getter) {
39/******/ 		if(!__webpack_require__.o(exports, name)) {
40/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
41/******/ 		}
42/******/ 	};
43/******/
44/******/ 	// define __esModule on exports
45/******/ 	__webpack_require__.r = function(exports) {
46/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48/******/ 		}
49/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
50/******/ 	};
51/******/
52/******/ 	// create a fake namespace object
53/******/ 	// mode & 1: value is a module id, require it
54/******/ 	// mode & 2: merge all properties of value into the ns
55/******/ 	// mode & 4: return value when already ns object
56/******/ 	// mode & 8|1: behave like require
57/******/ 	__webpack_require__.t = function(value, mode) {
58/******/ 		if(mode & 1) value = __webpack_require__(value);
59/******/ 		if(mode & 8) return value;
60/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61/******/ 		var ns = Object.create(null);
62/******/ 		__webpack_require__.r(ns);
63/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65/******/ 		return ns;
66/******/ 	};
67/******/
68/******/ 	// getDefaultExport function for compatibility with non-harmony modules
69/******/ 	__webpack_require__.n = function(module) {
70/******/ 		var getter = module && module.__esModule ?
71/******/ 			function getDefault() { return module['default']; } :
72/******/ 			function getModuleExports() { return module; };
73/******/ 		__webpack_require__.d(getter, 'a', getter);
74/******/ 		return getter;
75/******/ 	};
76/******/
77/******/ 	// Object.prototype.hasOwnProperty.call
78/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79/******/
80/******/ 	// __webpack_public_path__
81/******/ 	__webpack_require__.p = "";
82/******/
83/******/
84/******/ 	// Load entry module and return exports
85/******/ 	return __webpack_require__(__webpack_require__.s = "../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/custom/cybersource-custom.js");
86/******/ })
87/************************************************************************/
88/******/ ({
89
90/***/ "../rvw_autobahn_core/cartridges/rvw_autobahn_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js":
91/*!***************************************************************************************************************************!*\
92  !*** ../rvw_autobahn_core/cartridges/rvw_autobahn_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js ***!
93  \***************************************************************************************************************************/
94/*! no static exports found */
95/***/ (function(module, exports, __webpack_require__) {
96
97"use strict";
98
99/**
100 * This client-side js file just acts as a wrapper for the site preference config toggles
101 * that are outputted by Controller: Integrations-OutputIntegrationsConfig
102 */
103
104function getIntegrationSettings() {
105  if (window && window.CachedData && window.CachedData.siteIntegrations) {
106    return window.CachedData.siteIntegrations;
107  }
108
109  return {};
110}
111
112module.exports = {
113  getIntegrationSettings: getIntegrationSettings
114};
115
116/***/ }),
117
118/***/ "../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/custom/cybersource-custom.js":
119/*!***********************************************************************************************************************!*\
120  !*** ../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/custom/cybersource-custom.js ***!
121  \***********************************************************************************************************************/
122/*! no static exports found */
123/***/ (function(module, exports, __webpack_require__) {
124
125/* eslint-disable */
126var siteIntegrations = __webpack_require__(/*! integrations/integrations/siteIntegrationsUtils */ "../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js");
127
128var toggleObject = siteIntegrations.getIntegrationSettings();
129
130if (toggleObject.cybersourceCartridgeEnabled) {
131  var init = {
132    initConfig: function initConfig() {
133      var requestId;
134      var billingAgreementFlag; // A Flag to show whether user has opted for Billing Agreement or not
135
136      var billingAgreementButton; // The Billing Agreement Checkbox
137
138      var billingAgreementID; // Billing Agreement ID
139
140      var isPayPalCredit = false;
141      var endPoint = $('#paypal_endpoint').length > 0 ? document.getElementById('paypal_endpoint').value : 'sandbox';
142      var config = {
143        env: endPoint,
144        commit: true,
145        validate: function validate(actions) {// if ($('.paypal-address').length > 0) {
146          //     paypalvalidator.toggleForm(actions);
147          //     paypalvalidator.onChangeForm(function () {
148          //         paypalvalidator.toggleForm(actions);
149          //     });
150          // }
151        },
152        payment: function payment() {
153          var CREATE_URL = document.getElementById('paypal_express').value;
154
155          if (config.paymentOption.credit) {
156            isPayPalCredit = true;
157          } else {
158            isPayPalCredit = false;
159          }
160
161          billingAgreementButton = document.getElementById('billingAgreementCheckbox'); // billingAgreementFlag - This variable is used to indicate if billing agreement creation is requested or not
162
163          billingAgreementFlag = billingAgreementButton == null ? false : billingAgreementButton.checked; // Append a parameter to URL when Billing Agreement is checked
164
165          if (billingAgreementFlag) {
166            CREATE_URL += '?billingAgreement=true';
167          } else if (isPayPalCredit) {
168            // Append a parameter to URL when PayPal Credit is used
169            CREATE_URL += '?isPayPalCredit=true';
170          }
171
172          return paypal.request.post(CREATE_URL).then(function (res) {
173            requestId = res.requestID;
174            return res.processorTransactionID;
175          });
176        },
177        onAuthorize: function onAuthorize(data, actions) {
178          var data = {
179            requestId: requestId,
180            billingAgreementFlag: billingAgreementFlag,
181            paymentID: data.paymentID,
182            payerID: data.payerID,
183            isPayPalCredit: isPayPalCredit
184          };
185          var paypalcallback = document.getElementById('paypal_callback').value;
186          var form = $('<form action="' + paypalcallback + '" method="post">' + '<input type="hidden" name="requestId" value="' + requestId + '" />' + '<input type="hidden" name="billingAgreementFlag" value="' + billingAgreementFlag + '" />' + '<input type="hidden" name="paymentID" value="' + data.paymentID + '" />' + '<input type="hidden" name="payerID" value="' + data.payerID + '" />' + '<input type="hidden" name="isPayPalCredit" value="' + isPayPalCredit + '" />' + '</form>');
187          $('body').append(form);
188          form.submit();
189        }
190      };
191      return config;
192    },
193    initPayPalButtons: function initPayPalButtons() {
194      var isPaypalEnabled;
195      isPaypalEnabled = !!($('#paypal_enabled').length > 0 && document.getElementById('paypal_enabled').value == 'true');
196      var locale = $('#currentLocale').length > 0 ? document.getElementById('currentLocale').value : '';
197      var config = init.initConfig();
198      config.paymentOption = {
199        express: true,
200        credit: false
201      };
202      config.locale = locale;
203
204      if (isPaypalEnabled && $('.paypal-button-container-cart1').length > 0) {
205        paypal.Button.render(config, '.paypal-button-container-cart1');
206        $('body').trigger('PaymentMethodObserver:iframePresent');
207      }
208
209      if (isPaypalEnabled && $('.paypal-button-container-cart2').length > 0) {
210        paypal.Button.render(config, '.paypal-button-container-cart2');
211        $('body').trigger('PaymentMethodObserver:iframePresent');
212      }
213
214      if (isPaypalEnabled && $('#paypal-button-container').length > 0) {
215        paypal.Button.render(config, '#paypal-button-container');
216        $('body').trigger('PaymentMethodObserver:iframePresent');
217      } // Settings for PayPal Credit Card Button
218
219
220      if (isPaypalEnabled && $('#paypal-credit-container').length > 0) {
221        var creditConfig = init.initConfig();
222        creditConfig.style = {
223          label: 'credit',
224          size: 'small',
225          // small | medium
226          shape: 'rect' // pill | rect
227
228        };
229        creditConfig.paymentOption = {
230          express: false,
231          credit: true
232        };
233        creditConfig.locale = locale;
234        paypal.Button.render(creditConfig, '#paypal-credit-container');
235        $('body').trigger('PaymentMethodObserver:iframePresent');
236      }
237    },
238    initFunctions: function initFunctions() {
239      $(document).on('click', '.credit_card, .sa_flex', function (e) {
240        e.stopImmediatePropagation();
241        var payerAuth = $(this).data('payerauth');
242        window.location.href = payerAuth;
243      });
244      $(document).on('click', '.wechat', function (e) {
245        e.stopImmediatePropagation();
246        var formaction = $(this).attr('data-action');
247        setTimeout(function () {
248          window.location.href = formaction;
249        }, 500);
250      }); // for Alipay Intermediate
251
252      if ($('body').hasClass('cyb_alipayintermediate')) {
253        var loaded = false;
254        setTimeout(function () {
255          document.RedirectForm.submit();
256          loaded = true;
257        }, 1000);
258      } // For FingerPrint Unit testing
259
260
261      if ($('body').hasClass('cyb_testfingerprintRedirect')) {
262        var url_loc = document.getElementById('URl_redirect').value;
263        setTimeout(function () {
264          location.href = url_loc;
265        }, 1000);
266      } // For Payerauth during checkout
267
268
269      if ($('div').hasClass('payerauth')) {
270        document.PAInfoForm.submit();
271      } // For payerauth during  Credit card
272
273
274      if ($('body').hasClass('cyb_payerauthenticationredirect')) {
275        document.RedirectForm.submit();
276      } // For payerauth during  Unit testing
277
278
279      if ($('body').hasClass('cyb_unitTest_payerauth')) {
280        document.RedirectForm.submit();
281      } // For payer auth during  Unit testing
282
283
284      if ($('div').hasClass('cyb_unitTest_payerauthsubmit')) {
285        document.PAInfoForm.submit();
286      } // For Secure Acceptance Redirect
287
288
289      if ($('body').hasClass('cyb_sa_redirect')) {
290        var url_loc = document.getElementById('redirect_url_sa').value;
291        window.top.location.replace(url_loc);
292      } // For Secure Acceptance Iframe
293
294
295      if ($('div').hasClass('SecureAcceptance_IFRAME')) {
296        var url_loc = document.getElementById('sa_iframeURL').value;
297        $('.SecureAcceptance_IFRAME').append('<iframe src=' + url_loc + '  name="hss_iframe"  width="85%" height="730px" scrolling="no" />');
298      } // For Secure Acceptance Iframe
299
300
301      if ($('body').hasClass('sa_iframe_request_form')) {
302        document.form_iframe.submit();
303      } // For Secure Acceptance
304
305
306      if ($('body').hasClass('cyb_sa_request_form')) {
307        $('#loading').css('display', 'block');
308        document.ePayment.submit();
309      } // FOR POS
310
311
312      $('#entry-mode-pos_unittest select.input-select').change(function () {
313        if (this.value == 'swiped') {
314          $('#card-section, #sample-card-section').css('display', 'none');
315        } else if (this.value == 'keyed') {
316          $('#card-section, #sample-card-section').css('display', 'block');
317        }
318      });
319      /*
320      * If billing agreement ID already exists in the user profile then a different button
321      * is displayed on the the page. This function handles the action of that button.
322      * This functions directly calls checkstatusservice
323      */
324
325      $(document).on('click', '.billingAgreementExpressCheckout', function (e) {
326        e.preventDefault();
327        var paypalcallback = document.getElementById('paypal_callback').value;
328        var form = $('<form action="' + paypalcallback + '" method="post">' + '</form>');
329        $('body').append(form);
330        form.submit();
331      });
332      $(document).on('click', '.sa_silentpost, .sa_redirect, .alipay, .gpy, .eps, .sof, .mch, .idl , .klarna, .wechat', function (e) {
333        e.stopImmediatePropagation();
334        var CsSaType = $('li[data-method-id="CREDIT_CARD"]').attr('data-sa-type');
335        var paymentMethodID = $('input[name=dwfrm_billing_paymentMethod]').val();
336        var paymentMethodIds = ['KLARNA', 'ALIPAY', 'GPY', 'EPS', 'SOF', 'IDL', 'MCH', 'WECHAT'];
337        var paymentMethod = $.inArray(paymentMethodID, paymentMethodIds) > -1;
338
339        if (CsSaType != 'CREDIT_CARD' && paymentMethodID == 'CREDIT_CARD' || paymentMethod) {
340          var formaction = $(this).attr('data-action');
341          setTimeout(function () {
342            window.location.href = formaction;
343          }, 500);
344        }
345      });
346      /**
347      * @function
348      * @description function to Open the secure acceptance page inside Iframe if secure acceptance Iframe is selected
349      */
350
351      $(document).on('click', '.sa_iframe', function (e) {
352        e.stopImmediatePropagation();
353        var creditCardItem = $('li[data-method-id="CREDIT_CARD"]');
354        var CsSaType = $(creditCardItem).attr('data-sa-type');
355
356        if (CsSaType == 'SA_IFRAME') {
357          var formaction = $(this).attr('data-action');
358          $.ajax({
359            url: formaction,
360            type: 'POST',
361            success: function success(xhr, data) {
362              if (xhr) {
363                if (xhr.error == true) {
364                  $('#saspCardError').html(xhr.errorMsg);
365                  $('#saspCardError').addClass('error');
366                } else {
367                  $('#secureAcceptanceIframe').html(xhr);
368                  document.getElementById('submit-order').classList.add('d-none');
369                }
370              } else {
371                $('#saspCardError').html(xhr.errorMsg);
372                $('#saspCardError').addClass('error');
373              }
374
375              return true;
376            },
377            error: function error() {
378              $('#saspCardError').html(xhr.errorMsg).addClass('error');
379            }
380          });
381        } else {
382          return true;
383        }
384      });
385      $('#capturepaymenttype, #authreversalpaymenttype').change(function () {
386        if ($(this).val() == 'visacheckout') {
387          $('#orderRequestID').attr('required', 'required');
388          $('.orderRequestID').removeClass('hidden').addClass('show');
389        } else {
390          $('#orderRequestID').removeAttr('required');
391          $('.orderRequestID').removeClass('show').addClass('hidden');
392        }
393      });
394
395      if ($('#checkout-main').attr('data-checkout-stage') === 'placeOrder') {
396        var placeOrderBtn = $('#checkout-main').find('#submit-order'); //only disable the onclick when its not a plain credit card or paypal (standalone or through cybersource) order
397
398        if (!placeOrderBtn.hasClass('place-order') || !placeOrderBtn.hasClass('credit_card') && !placeOrderBtn.hasClass('PayPal') && !placeOrderBtn.hasClass('PAYPAL') && !placeOrderBtn.hasClass('PAYPAL_CREDIT') && !placeOrderBtn.hasClass('dw_google_pay')) {
399          $(placeOrderBtn).closest('.row').find('.next-step-button').removeClass('next-step-button');
400        }
401      }
402    }
403  };
404  var paypalhelper = {
405    paypalMini: function paypalMini() {
406      var config = init.initConfig();
407      var locale = $('#currentLocale').length > 0 ? document.getElementById('currentLocale').value : '';
408      config.paymentOption = {
409        express: true,
410        credit: false
411      };
412      config.locale = locale;
413      var isPaypalEnabled = false;
414
415      if (document.getElementById('paypal_enabled') != null) {
416        isPaypalEnabled = document.getElementById('paypal_enabled').value;
417      }
418
419      if (isPaypalEnabled && $('.paypal-button-container-mini').length > 0) {
420        paypal.Button.render(config, '.paypal-button-container-mini');
421      }
422    },
423    validateForms: function validateForms() {
424      var currentForm = $('data-checkout-stage').attr('data-checkout-stage');
425
426      if (currentForm == 'payment') {
427        false;
428      }
429
430      return true;
431    }
432  }; //AUTOBAHN MOD this is a globally accessed function
433
434  window.paypalhelper = paypalhelper;
435  var paypalvalidator = {
436    // toggleForm: function (actions) {
437    //     if (this.isValid()) { return actions.enable(); }
438    //     return actions.disable();
439    // },
440    // isValid: function () {
441    //     var paymentForm = $('#dwfrm_billing').serialize();
442    //     var isValidForm = false;
443    //     $('body').trigger('checkout:serializeBilling', {
444    //         form: $('#dwfrm_billing'),
445    //         data: paymentForm,
446    //         callback: function (data) { paymentForm = data; }
447    //     });
448    //     paypalvalidator.validateAddress(function (data) {
449    //         isValidForm = !data.error;
450    //         if (data.fieldErrors.length) {
451    //             data.fieldErrors.forEach(function (error) {
452    //                 if (Object.keys(error).length) {
453    //                     paypalvalidator.loadFormErrors('.payment-form', error);
454    //                 }
455    //             });
456    //         }
457    //     });
458    //     return isValidForm;
459    // },
460    // loadFormErrors: function (parentSelector, fieldErrors) {
461    //     $.each(fieldErrors, function (attr) {
462    //         $('*[name=' + attr + ']', parentSelector).addClass('is-invalid').siblings('.invalid-feedback').html(fieldErrors[attr]);
463    //     });
464    // },
465    paypalMini: function paypalMini() {
466      var config = init.initConfig();
467      var isPaypalEnabled = document.getElementById('paypal_enabled').value;
468
469      if (isPaypalEnabled && $('.paypal-button-container-mini').length > 0) {
470        paypal.Button.render(config, '.paypal-button-container-mini');
471      }
472    } // validateAddress: function (callback) {
473    //     var paymentForm = $('#dwfrm_billing').serialize();
474    //     $.ajax({
475    //         method: 'POST',
476    //         async: false,
477    //         data: paymentForm,
478    //         url: $('.paypal-address').attr('action'),
479    //         success: function (data) {
480    //             callback(data);
481    //         },
482    //         error: function (err) {
483    //         }
484    //     });
485    // },
486    // onChangeForm: function (handler) {
487    //     $('.billing-information').on('change', handler);
488    // }
489
490  };
491  $(document).ready(function () {
492    init.initConfig();
493    init.initPayPalButtons();
494    init.initFunctions();
495
496    if ($('#isGooglePayEnabled').val() == 'true') {
497      onGooglePayLoaded();
498    }
499  });
500}
501
502/***/ }),
503
504/***/ "../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js":
505/*!***********************************************************************************************************************************!*\
506  !*** ../rvw_integrations_core/cartridges/rvw_integrations_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js ***!
507  \***********************************************************************************************************************************/
508/*! no static exports found */
509/***/ (function(module, exports, __webpack_require__) {
510
511"use strict";
512
513/*
514 * Just have a simple pass through so we can use the site preference integration toggles
515 * in rvw_integrations_core as well as rvw_autobahn_core
516 */
517
518var core = __webpack_require__(/*! core/integrations/siteIntegrationsUtils */ "../rvw_autobahn_core/cartridges/rvw_autobahn_core/cartridge/client/default/js/integrations/siteIntegrationsUtils.js");
519
520module.exports = core;
521
522/***/ })
522
523
524/******/ });
525//# sourceMappingURL=cybersource-custom.js.map

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.