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AASC,KAAOxB,EAASsB,YAEpC,IACCG,MAAK,WAAa,IAClBC,QAAO,WAAa,GACzB,CACF,CA9GAhD,EAAE,mBAAmBiD,MAAK,SAAUC,EAAGrD,GACrCG,EAAEH,GAAIsD,KAAK,SAAU,IAAIvD,EAAcC,IACvCG,EAAEH,GAAIsD,KAAK,UAAUhD,MACvB,G","sources":["webpack://disp0001/./src/widgets/bpoint-payment/bpoint-payment.js"],"sourcesContent":["$('.bpoint-payment').each(function (i, el) {\r\n $(el).data('bpoint', new BPointPayment(el))\r\n $(el).data('bpoint').init()\r\n})\r\n\r\nfunction BPointPayment(el) {\r\n const self = this\r\n self.el = $(el)\r\n self.events = new dbs.events()\r\n\r\n self.init = function () {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('BPointPayment init', self)\r\n }\r\n }\r\n\r\n self.ProcessPayment = function (result) {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPayment')\r\n }\r\n\r\n const expiryDate = self.el.find('.expiry-date').val().split('/')\r\n\r\n CBA.ProcessPayment({\r\n AuthKey: result.AuthenticationKey,\r\n CardNumber: self.el.find('.cardnumber').val(),\r\n Cvn: self.el.find('.cvv').val(),\r\n ExpiryMonth: expiryDate[0],\r\n ExpiryYear: expiryDate[1],\r\n StoreCard: true,\r\n CallbackFunction: self.ProcessPaymentCallBack,\r\n Type: 'CREDITCARD',\r\n })\r\n }\r\n\r\n self.ProcessPaymentCallBack = function (response) {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPaymentCallBack')\r\n }\r\n\r\n let errors = []\r\n\r\n if (response.AjaxResponseType === 0) {\r\n if (response.ApiResponseCode === 0) {\r\n // Redirect to the result URL - we could process the result directly (via result.ResultKey) in this case\r\n // but we have to support the external redirect path anyway so may as well keep it simple\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPaymentCallBack', '\"Redirect to the result URL\"')\r\n }\r\n\r\n self.ProcessPaymentResult(response.RedirectionUrl)\r\n } else if (response.ApiResponseCode === 300) {\r\n // Redirect has been explicitly requested - this is likely to be an external (VbV or 3DS) URL\r\n // which in turn will redirect back to our result URL\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPaymentCallBack', '\"Redirect has been explicitly requested\"')\r\n }\r\n\r\n if (response.RedirectionUrl !== null && response.RedirectionUrl.length > 0) {\r\n self.ProcessPaymentResult(response.RedirectionUrl)\r\n } else {\r\n errors = response.Errors\r\n }\r\n } else {\r\n errors = response.Errors\r\n }\r\n } else if (response.AjaxResponseType === 1 || response.AjaxResponseType === 2) {\r\n errors = response.Errors\r\n }\r\n\r\n if (errors.length > 0) {\r\n window.dbs.globalEvents.emit('bpoint_payment_error', errors)\r\n }\r\n }\r\n\r\n self.ProcessPaymentResult = function (url) {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPaymentResult')\r\n }\r\n\r\n $.ajax({\r\n url: url,\r\n type: 'GET',\r\n })\r\n .done(function (response) {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[BPOINT]', 'self.ProcessPaymentResult', 'DONE', response)\r\n }\r\n\r\n // CW-8299 [add_payment_info] Event success of purchase of order\r\n if (response.RawDataLayerEvents && response.RawDataLayerEvents['add_payment_info']) {\r\n ;(function () {\r\n const dataLayerAsJson = JSON.parse(response.RawDataLayerEvents['add_payment_info'])\r\n // TODO verify data layer object\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log(`CW-8299 event ${dataLayerAsJson.event}`, JSON.stringify(dataLayerAsJson, null, 2))\r\n }\r\n window.dataLayer = window.dataLayer || [] // Create a data layer\r\n dataLayer.push({ ecommerce: null }) // Clear the previous ecommerce object\r\n dataLayer.push(dataLayerAsJson)\r\n })()\r\n }\r\n\r\n if (response.RedirectUrl) {\r\n window.location.href = response.RedirectUrl\r\n }\r\n })\r\n .fail(function () {})\r\n .always(function () {})\r\n }\r\n}\r\n"],"names":["BPointPayment","el","self","this","$","events","dbs","init","process","ProcessPayment","result","expiryDate","find","val","split","CBA","AuthKey","AuthenticationKey","CardNumber","Cvn","ExpiryMonth","ExpiryYear","StoreCard","CallbackFunction","ProcessPaymentCallBack","Type","response","errors","AjaxResponseType","ApiResponseCode","RedirectionUrl","length","ProcessPaymentResult","Errors","window","globalEvents","emit","url","ajax","type","done","RawDataLayerEvents","dataLayerAsJson","JSON","parse","dataLayer","push","ecommerce","RedirectUrl","location","href","fail","always","each","i","data"],"sourceRoot":""}