1 2var type_cc = ""; 3var operationSessionId = "" 4var arrCoupon = []; 5var teaser_click = false; 6$(document).ready(function () { 7 8 // jQuery.noConflict(true); 9 var date = new Date(); 10 $(".box-cc").click(function (e) { 11 var uri_img = $(this).children('img').attr('src'); 12 var label_cc = $(this).children('label').text(); 13 type_cc = $(this).children('span').text(); 14 // $('.container-choice-cc').hide(); 15 $('.container-form-epay').show(); 16 $('.text-security').show(); 17 $(".cc-logo").attr("src", uri_img); 18 19 if ($('#edit-card-number').val().length > 10 && !checkCreditCard($('#edit-card-number').val(), $.trim(type_cc))) { 20 $('#edit-card-number').addClass("input-field-error"); 21 $('#error-cc').show() 22 $('#error-cc').text('Le numéro de carte ne correspond pas au type de carte '); 23 $('#edit-submit-epay').attr("disabled", "disabled"); 24 } else { 25 $('#edit-card-number').removeClass("input-field-error"); 26 $("#error-cc").hide(); 27 $('#edit-submit-epay').removeAttr("disabled"); 28 $('#edit-submit-epay').css("background", "#E30046"); 29 } 30 }); 31 32 $(".eye-password").click(function (e) { 33 var input = $("#edit-cvv"); 34 if (input.attr("type") === "password") { 35 input.attr("type", "text"); 36 $('.eye-open').show(); 37 $('.eye-close').hide(); 38 } else { 39 input.attr("type", "password"); 40 $('.eye-open').hide(); 41 $('.eye-close').show(); 42 } 43 }); 44 45 $('#edit-card-number').on('keypress', function (e) { 46 $(this).val(function (index, value) { 47 return value.replace(/\W/gi, '').replace(/[^\d\/]|^[\/]*$/g, '').replace(/(.{4})/g, '$1 '); 48 }); 49 $(this).removeClass("input-field-error"); 50 $("#error-cc").hide(); 51 }); 52 53 $('#mm').on('change', function () { 54 if ($(this).val() != "00") { 55 $('#mm').removeClass("input-field-error"); 56 $("#error-mmyy").hide(); 57 } 58 }); 59 60 $('#yy').on('change', function () { 61 if ($(this).val() != "00") { 62 $('#yy').removeClass("input-field-error"); 63 $("#error-mmyy").hide(); 64 } 65 }); 66 67 $('#edit-cvv').on('keyup', function () { 68 $(this).val(function (index, value) { 69 return value.replace(/[^\d\/]|^[\/]*$/g, '');; 70 }); 71 }); 72 73 $('#edit-card-number').blur(function () { 74 if (!$(this).val()) { 75 $(this).addClass("input-field-error"); 76 $("#error-cc").show(); 77 $('#error-cc').text('Le numéro de carte ne peut être vide '); 78 $('#edit-submit-epay').attr("disabled", "disabled"); 79 } else if ($(this).val().length < 10 || !checkCreditCard($(this).val(), $.trim(type_cc))) { 80 $(this).addClass("input-field-error"); 81 $('#error-cc').show() 82 $('#error-cc').text('Le numéro de carte ne correspond pas au type de carte '); 83 $('#edit-submit-epay').attr("disabled", "disabled"); 84 } else { 85 $(this).removeClass("input-field-error"); 86 $("#error-cc").hide(); 87 $('#edit-submit-epay').removeAttr("disabled"); 88 } 89 }); 90 91 $('#edit-cvv').blur(function () { 92 if (!$(this).val()) { 93 $(this).addClass("input-field-error"); 94 $("#error-cvv").show(); 95 $('#edit-submit-epay').attr("disabled", "disabled"); 96 } else { 97 $(this).removeClass("input-field-error"); 98 $("#error-cvv").hide(); 99 $('#edit-submit-epay').removeAttr("disabled"); 100 $('#edit-submit-epay').css("background", "#E30046"); 101 } 102 }); 103 104 var deviceType = "BROWSER"; 105 if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || 106 /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
106sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) { 107 deviceType = "MOBILE"; 108 } 109 var timezoneOffset = date.getTimezoneOffset(); 110 111 $("#deviceType").val(deviceType); 112 $("#screenHeight").val(screen.height); 113 $("#screenWidth").val(screen.width); 114 // $("#language").val(navigator.language); 115 $("#useragent").val(navigator.userAgent); 116 $("#javaenable").val(navigator.javaEnabled()); 117 $("#colordept").val(screen.colorDepth); 118 $("#offsettime").val(timezoneOffset); 119 $("#acceptheader").val(document.contentType); 120 121 $(".teasers .teaser").each(function () { 122 var formId = $(this).attr("form"); 123 $(this).children('.teaser-item').click(function () { 124 teaser_click = true; 125 if (window.subscrip) { 126 localStorage.setItem("formId", formId); 127 location.reload(true); 128 } else { 129 localStorage.removeItem("formId"); 130 $(".subscriptions-full-forms .subscriptions-form-wrapper").hide(); 131 $(".subscriptions-full-forms ." + formId + "-wrapper").show(); 132 $("html, body").animate({ scrollTop: $(".subscriptions-full-forms ." + formId + "-wrapper").offset().top }, 500); 133 } 134 addBlockFrontButton(formId); 135 }); 136 }); 137 138 $('.one-pdf-button').click(function () { 139 var formId = $(this).attr("form"); 140 addBlockFrontButton(formId); 141 }); 142 143 $.fn.extend({ 144 donetyping: function (callback, timeout) { 145 timeout = timeout || 500; // 1 second default timeout 146 var timeoutReference, 147 doneTyping = function (el) { 148 if (!timeoutReference) return; 149 timeoutReference = null; 150 callback.call(el); 151 }; 152 return this.each(function (i, el) { 153 var $el = $(el); 154 $el.is(':input') && $el.on('keyup keypress paste', function (e) { 155 if (e.type == 'keyup' && e.keyCode != 8) return; 156 if (timeoutReference) clearTimeout(timeoutReference); 157 timeoutReference = setTimeout(function () { 158 doneTyping(el); 159 }, timeout); 160 }).on('blur', function () { 161 doneTyping(el); 162 }); 163 }); 164 } 165 }); 166 167 var arrSubsId = ""; 168 function addBlockFrontButton(id) { 169 170 $('#container_epay').hide(); 171 var formActive = document.getElementById(id); 172 var chForm = formActive.children[0].children; 173 var contButton = "" 174 for (let i = 0; i < chForm.length; i++) { 175 if (chForm[i].getAttribute("class") == "submit-container form-wrapper") { 176 contButton = chForm[i].getAttribute("id"); 177 } 178 if (chForm[i].getAttribute("name") == "subscription-id") { 179 arrSubsId = chForm[i].getAttribute("value"); 180 } 181 } 182 183 var div = document.createElement("div"); 184 var att = document.createAttribute("class"); 185 att.value = "front-button"; 186 div.setAttributeNode(att); 187 document.getElementById(contButton).appendChild(div); 188 189 // createError(".front-button", false); 190 $(".front-button").click(function (e) { 191 e.preventDefault(); 192 if (window.subscrip) { 193 var divLoading = document.createRange().createContextualFragment('<div class="ajax-progress ajax-progress-throbber"><div class="throbber"> </div><div class="message">Veuillez patienter...</div></div>'); 194 document.getElementById(contButton).appendChild(divLoading); 195 submitFormSecond(id); 196 } 197 }); 198 199 200 $('.front-button').parent().parent().parent().find("input.field-coupon").each(function (e, a) { 201 arrCoupon.push(a.getAttribute('id')); 202 }); 203 204 for (let i = 0; i < arrCoupon.length; i++) { 205 $('#' + arrCoupon[i]).donetyping(function () { 206 var postCoupons = ajaxGetCoupons($('#' + arrCoupon[i]).val()); 207 $('.coupon-desc').remove(); 208 $('.field-errors-coupon').remove(); 209 if (postCoupons == "unset") { 210 failedCoupon(); 211 } else if (postCoupons != false) { 212 response = JSON.parse(postCoupons); 213 if (response.subscription_id == false || response.subscription_id == arrSubsId) { 214 $('#' + contButton).before("<div class='coupon-desc'>" + response.description_web + "</div>"); 215 $('.subscription-submit-button').removeAttr("style"); 216 } else { 217 $(".subscription-submit-button").css("pointer-events", "none"); 218 $(".subscription-submit-button").css("background", "grey"); 219 $("#" + arrCoupon[i]).before("<div class='field-errors-coupon' color='#cc0000'>Le coupon que vous avez renseigné n\'existe pas ou n\'est plus valable.</div>"); 220 } 221 } else if ($("#" + arrCoupon[i]).val().length > 0) { 222 $("#" + arrCoupon[i]).before("<div class='field-errors-coupon' color='#cc0000'>Le coupon que vous avez renseigné n\'existe pas ou n\'est plus valable.</div>"); 223 } 224 }); 225 } 226 } 227 228 function submitFormSecond(id) { 229 requestFormSecond(); 230 var url_formsubmit = window.location.origin + '/abonnements/formsubmit'; 231 $.ajax({ 232 type: 'post', 233 url: url_formsubmit, 234 data: $('#' + id).serialize(), 235 success: function (response) { 236 response = JSON.parse(response); 237 responseFormSecond(response); 238 }, 239 error: function (err) { 240 console.log("ERROR", err) 241 redirect(url_epaydirect, "POST", err); 242 } 243 }); 244 } 245 246 $(".teasers .teaser").each(function () { 247 if (localStorage.getItem("formId") == $(this).attr("form")) { 248 $(this).children('.teaser-item').trigger("click"); 249 } 250 }) 251}); 252 253$(window).on("load", function () { 254 var formID = ""; 255 $(".teasers .teaser").each(function () { 256 var formId = $(this).attr("form"); 257 $(this).children('.teaser-item').click(function () { 258 if (teaser_click == false) { 259 formID = formId 260 if (window.subscrip) { 261 localStorage.setItem("formId", formId); 262 location.reload(true); 263 } else { 264 localStorage.removeItem("formId"); 265 $(".subscriptions-full-forms .subscriptions-form-wrapper").hide(); 266 $(".subscriptions-full-forms ." + formId + "-wrapper").show(); 267 $("html, body").animate({ scrollTop: $(".subscriptions-full-forms ." + formId + "-wrapper").offset().top }, 500); 268 } 269 270 var formActive = document.getElementById(formID); 271 var chForm = formActive.children[0].children; 272 var contButton = "" 273 for (let i = 0; i < chForm.length; i++) { 274 if (chForm[i].getAttribute("class") == "submit-container form-wrapper") { 275 contButton = chForm[i].getAttribute("id"); 276 } 277 } 278 $("#" + formID).children().children().find("input.field-coupon").each(function (e, a) { 279 idC = a.getAttribute('id'); 280 $('#' + idC).donetyping(function () { 281 var postCoupons = ajaxGetCoupons($('#' + idC).val()); 282 $('.coupon-desc').remove(); 283 $('.field-errors-coupon').remove(); 284 if (postCoupons == "unset") { 285 failedCoupon(); 286 } else if (postCoupons != false) { 287 response = JSON.parse(postCoupons); 288 if (response.subscription_id == false || response.subscription_id == arrSubsId) { 289 $('#' + contButton).before("<div class='coupon-desc'>" + response.description_web + "</div>"); 290 $('.subscription-submit-button').removeAttr("style"); 291 } else { 292 $(".subscription-submit-button").css("pointer-events", "none"); 293 $(".subscription-submit-button").css("background", "grey"); 294 $("#" + idC).before("<div class='field-errors-coupon' color='#cc0000'>Le coupon que vous avez renseigné n\'existe pas ou n\'est plus valable.</div>"); 295 } 296 } else if ($("#" + idC).val().length > 0) { 297 $("#" + idC).before("<div class='field-errors-coupon' color='#cc0000'>Le coupon que vous avez renseigné n\'existe pas ou n\'est plus valable.</div>"); 298 } 299 }); 300 }) 301 } 302 }); 303 }); 304 305 $.fn.extend({ 306 donetyping: function (callback, timeout) { 307 timeout = timeout || 500; // 1 second default timeout 308 var timeoutReference, 309 doneTyping = function (el) { 310 if (!timeoutReference) return; 311 timeoutReference = null; 312 callback.call(el); 313 }; 314 return this.each(function (i, el) { 315 var $el = $(el); 316 $el.is(':input') && $el.on('keyup keypress paste', function (e) { 317 if (e.type == 'keyup' && e.keyCode != 8) return; 318 if (timeoutReference) clearTimeout(timeoutReference); 319 timeoutReference = setTimeout(function () { 320 doneTyping(el); 321 }, timeout); 322 }).on('blur', function () { 323 doneTyping(el); 324 }); 325 }); 326 } 327 }); 328 329}); 330 331function ajaxGetCoupons(valueCoupons) { 332 var response = "";
333 if (valueCoupons.length > 1) { 334 $.ajax({ 335 type: 'post', 336 url: window.location.origin + '/getcoupons', 337 data: { "coupon": valueCoupons }, 338 async: false 339 }).done(function (msg) { 340 response = msg 341 }).fail(function (jqXHR, textStatus) { 342 response = textStatus 343 }); 344 } else { 345 response = false; 346 } 347 return response 348} 349function ccc(token){ 350 //jQuery('.kr-embedded').remove(); 351 //jQuery('#bozo').remove(); 352 353 var script = document.createElement("script"); 354 script.src = "https://epaync.nc/static/js/krypton-client/V4.0/stable/kr-payment-form.min.js"; 355 script.setAttribute("id", "bozo"); 356 script.setAttribute("kr-public-key", "15578053:testpublickey_1xhxA8MgmKyFJJK8fS7EaNRPAHDJFTv9AzlF6ue2ZJU8o"); 357 document.getElementsByTagName("head")[0].appendChild(script); 358 359 jQuery('.tm_footer').append( 360 '<div class="kr-embedded" kr-form-token='+token+'>'+ 361 '<div class="kr-pan"></div>'+ 362 '<div class="kr-expiry"></div>'+ 363 '<div class="kr-security-code"></div>'+ 364 '<button class="kr-payment-button"></button>'+ 365 '<div class="kr-form-error"></div>'+ 366 '</div>' 367 ); 368 369} 370function requestFormSecond() { 371 $('#container_epay').show(); 372 $('body,html').animate({ scrollTop: $('#container_epay').offset().top }, 3500); 373 $('.epay-loader').show(); 374 $('.epay-submit-button').hide(); 375 376 //new-epay 377 $(".kr-payment-button").prop('disabled', true); 378 $(".kr-payment-button span").text('-'); 379 $(".kr-payment-button").css('background', 'rgb(155 155 155)'); 380 $(".kr-form-error").hide(); 381 382 var container_form = ""; 383 var tag_form = ""; 384 var value_amount = 0; 385 var tracit_renewal = 0; 386 var all_form = $('.subscriptions-full-forms').children(); 387 for (let i = 0; i < all_form.length; i++) { 388 if (all_form[i].getAttribute('style') == "display: block;") { 389 container_form = all_form[i] 390 } 391 } 392 393 for (let i = 0; i < container_form.childNodes.length; i++) { 394 if (container_form.childNodes[i].tagName == "FORM") { 395 tag_form = container_form.childNodes[i]; 396 } 397 } 398 if (tag_form.children.length <= 1) { 399 tag_form = tag_form.children[0] 400 } 401 for (let i = 0; i < tag_form.children.length; i++) { 402 if (tag_form.children[i].getAttribute('name') == 'subscription-lst-price') { 403 value_amount = tag_form.children[i].value; 404 } 405 if (tag_form.children[i].getAttribute('class') != null) { 406 var class_cuopon = tag_form.children[i].getAttribute('class').split(" ") 407 if (class_cuopon.indexOf('form-item-coupon') > 0) { 408 value_coupon = tag_form.children[i].lastElementChild.value; 409 idCoupon = tag_form.children[i].children[1].getAttribute("id"); 410 } 411 if (class_cuopon.indexOf('form-item-mail') > 0) { 412 userExist = tag_form.children[i].children[1].getAttribute('readonly'); 413 } 414 } 415 if (tag_form.children[i].getAttribute('name') == 'subscription-tacit-renewal') { 416 tracit_renewal = tag_form.children[i].value; 417 } 418 } 419 420 text_mois = tracit_renewal == 1 ? "/mois" : ""; 421 var initial_amount = 0; 422 var final_amount = 0; 423 var coupon_validity = 0; 424 var coupon_discount = 0; 425 var coupon_amount = 0; 426 var get_coupons = ajaxGetCoupons(value_coupon); 427 if (get_coupons == "unset") { 428 $('#container_epay').hide(); 429 failedCoupon(); 430 } else if (get_coupons != false) { 431 // console.log(get_coupons); 432 response = JSON.parse(get_coupons); 433 coupon_validity = parseInt(response.coupon_validity); 434 coupon_discount = parseFloat(response.discount_percentage); 435 coupon_amount = parseInt(response.amount); 436 if (coupon_amount > 0) { 437 initial_amount = coupon_amount; 438 } else { 439 initial_amount = coupon_discount * value_amount; 440 } 441 442 if (tracit_renewal == 1) { 443 if (coupon_validity > 0) { 444 final_amount = value_amount 445 } else { 446 final_amount = initial_amount 447 } 448 } 449 } else { 450 initial_amount = value_amount; 451 final_amount = tracit_renewal == 1 ? value_amount : false; 452 } 453 454 initial_amount = new Number(initial_amount).toLocaleString("fi-FI"); 455 final_amount = new Number(final_amount).toLocaleString("fi-FI"); 456 $("#couponValidity").val(parseInt(coupon_validity)); 457 if (parseInt(coupon_validity) >= 1 && tracit_renewal == 1) { 458 $('.amount-montant').text(initial_amount + "F/mois pendant " + coupon_validity + " mois, puis " + final_amount + "F/mois"); 459 } else if (parseInt(coupon_validity) == 0) { 460 $('.amount-montant').text(initial_amount + "F" + text_mois); 461 } else { 462 $('.amount-montant').text(initial_amount + "F" + text_mois); 463 } 464 console.log('initial_amount '+initial_amount+' final_amount '+final_amount+' tracit_renewal '+tracit_renewal); 465 console.log('coupon_validity '+coupon_validity+' coupon_amount '+coupon_amount+' coupon_discount '+coupon_discount); 466 // console.log(arrCoupon); 467 // for (let i = 0; i < arrCoupon.length; i++) { 468 // if ($('#' + arrCoupon[i]).val().length > 1) { 469 // $('#' + arrCoupon[i]).attr("readonly", "readonly"); 470 // $('#' + arrCoupon[i]).css("background", "#dedede"); 471 // } 472 // } 473 474 // if (value_coupon != undefined && value_coupon.length > 0) { 475 // $('.amount-montant').hide(); 476 // $('.loading-amount').show(); 477 // $('.container-form-epay').hide(); 478 // // $(".container-list-cc").css('cursor', 'wait');
479 // // $(".box-cc").css('pointer-events', 'none'); 480 // } 481 // value_amount = new Number(value_amount).toLocaleString("fi-FI"); 482 // $('.amount-montant').text(value_amount + "F"); 483 // if (tracit_renewal == 1) { 484 // $('.amount-montant').text(value_amount + "F/mois"); 485 // } 486} 487function failedCoupon() { 488 alert("La session d'abonnement a expiré, veuillez recharger cette page."); 489 location.reload(); 490} 491 492function responseFormSecond(response) { 493 var value_amount = 0; 494 var next_amount = 0; 495 $('.amount-montant').show(); 496 $('.loading-amount').hide(); 497 $(".container-list-cc").css('cursor', 'unset'); 498 $(".box-cc").css('pointer-events', 'unset'); 499 // console.log(response); 500 if (response != null) { 501 for (let i = 0; i < response.length; i++) { 502 if (response[i]["command"] == "datas") { 503 final_amount = 0; 504 coupon_validity = 0; 505 value_amount = response[i]["data"]["amount"]; 506 next_amount = response[i]["data"]["next_amount"]; 507 recurring = response[i]["data"]["recurring"]; 508 coupon_code = response[i]["data"]["coupon"]["code"]; 509 510 if(coupon_code.length > 0 && coupon_code !== ''){ 511 coupon_validity = parseInt(response[i]["data"]["coupon"]["coupon_validity"]); 512 coupon_discount = parseFloat(response[i]["data"]["coupon"]["discount_percentage"]); 513 coupon_amount = parseInt(response[i]["data"]["coupon"]["amount"]); 514 if (coupon_amount > 0) { 515 value_amount = coupon_amount; 516 } 517 //else { 518 // value_amount = coupon_discount * value_amount; 519 //} 520 521 if (recurring == 1) { 522 if (coupon_validity > 0) { 523 final_amount = next_amount; 524 } else { 525 final_amount = value_amount; 526 } 527 } 528 } 529 530 KR.setFormToken(response[i]["data"]["token"]).then( ({KR, result}) => { 531 btnText = ''; 532 if (parseInt(coupon_validity) >= 1 && recurring == 1) { 533 btnText = value_amount.toLocaleString('en-US').replace(",", " ") + "F/mois pendant " + coupon_validity + " mois, puis " + final_amount.toLocaleString('en-US').replace(",", " ") + "F/mois"; 534 } else if (parseInt(coupon_validity) == 0 && recurring == 1) { 535 btnText = value_amount.toLocaleString('en-US').replace(",", " ") + "F/mois"; 536 } else { 537 btnText = value_amount.toLocaleString('en-US').replace(",", " ") + "F"; 538 } 539 540 $(".kr-payment-button span").text(btnText); 541 $(".kr-payment-button").css('background', 'rgb(227 0 70)'); 542 }); 543 //$executetime = '<div id="executetime">create new user(save to drupal, send email and autologin): '+response[i]["data"]["save_user_drupal_time"]+'<br>save user to odoo: '+response[i]["data"]["save_user_time"]+'<br>create order odoo: '+response[i]["data"]["create_order_time"]+'<br>create token epay: '+response[i]["data"]["create_token_time"]+'<br>total (include minor process form validation & check login): '+response[i]["data"]["total_time"]+'<br></div>'; 544 545 //$('#container_epay').after($executetime); 546 547 // coupon = response[i]["data"]["coupon"]; 548 // text_mois = recurring == 1 ? "/mois" : ""; 549 // if (parseInt(coupon.coupon_validity) >= 1 && recurring == 1) { 550 // value_amount = new Number(value_amount).toLocaleString("fi-FI"); 551 // next_amount = new Number(next_amount).toLocaleString("fi-FI"); 552 // $('.amount-montant').text(value_amount + "F/mois pendant " + coupon.coupon_validity + " mois, puis " + next_amount + "F/mois"); 553 // } else if (parseInt(coupon.coupon_validity) == 0) { 554 // value_amount = new Number(value_amount).toLocaleString("fi-FI"); 555 // $('.amount-montant').text(value_amount + "F" + text_mois); 556 // } else { 557 // value_amount = new Number(value_amount).toLocaleString("fi-FI"); 558 // $('.amount-montant').text(value_amount + "F" + text_mois); 559 // } 560 if (userExist != "readonly") { 561 window.subscrip = true; 562 $('.front-button').show(); 563 } 564 // $("#couponValidity").val(parseInt(coupon.coupon_validity)); 565 $(".field-errors-coupon").remove(); 566 $('#container_epay').show(); 567 $(".kr-payment-button").prop('disabled', false); 568 $(".kr-payment-button").css('background', 'rgb(227 0 70)'); 569 } 570 $(".ajax-progress").remove(); 571 } 572 } 573 574 // $("html, body").animate({ scrollTop: $("#container_epay").offset().top }, 500); 575 $('.epay-loader').hide(); 576 $('.epay-submit-button').show(); 577} 578 579function getFieldCoupons() { 580 var container_form = ""; 581 var tag_form = ""; 582 var idCoupon = ""; 583 var all_form = $('.subscriptions-full-forms').children(); 584 for (let i = 0; i < all_form.length; i++) { 585 if (all_form[i].getAttribute('style') == "display: block;") { 586 container_form = all_form[i] 587 } 588 } 589 590 for (let i = 0; i < container_form.childNodes.length; i++) { 591 if (container_form.childNodes[i].tagName == "FORM") { 592 tag_form = container_form.childNodes[i]; 593 } 594 } 595 if (tag_form.children.length <= 1) { 596 tag_form = tag_form.children[0] 597 } 598 for (let i = 0; i < tag_form.children.length; i++) { 599 if (tag_form.children[i].getAttribute('class') != null) { 600 var class_cuopon = tag_form.children[i].getAttribute('class').split(" ") 601 if (class_cuopon.indexOf('form-item-coupon') > 0) { 602 value_coupon = tag_form.children[i].lastElementChild.value; 603 idCoupon = tag_form.children[i].children[1].getAttribute("id"); 604 } 605 } 606 } 607 return idCoupon; 608} 609 610$(function () { 611 var url_epaysubit = window.location.origin + '/epaysubmit'; 612 var url_epaydirect = window.location.origin + '/epaydirect'; 613 var this_is = ""; 614 $('.form-epay').on('submit', function (e) { 615 e.preventDefault(); 616 617 if ($('#edit-card-number').val().length < 10 || !checkCreditCard($('#edit-card-number').val(), $.trim(type_cc))) { 618 $('#edit-card-number').addClass("input-field-error"); 619 $("#error-cc").show(); 620 $('#error-cc').text('Le numéro de carte ne correspond pas au type de carte '); 621 return false;
622 } 623 624 if ($('#edit-card-number').val() == "") { 625 $('#edit-card-number').addClass("input-field-error"); 626 $("#error-cc").show(); 627 $('#error-cc').text('Le numéro de carte ne peut être vide '); 628 return false; 629 } 630 631 if ($('#mm').val() == "00") { 632 $('#mm').addClass("input-field-error"); 633 $("#error-mmyy").show(); 634 return false 635 } 636 637 if ($('#yy').val() == "00") { 638 $('#yy').addClass("input-field-error"); 639 $("#error-mmyy").show(); 640 return false 641 } 642 643 if ($('#edit-cvv').val() == "") { 644 $('#edit-cvv').addClass("input-field-error"); 645 $("#error-cvv").show(); 646 return false; 647 } 648 649 $("#instructionContainer").show(); 650 this_is = "abo"; 651 $.ajax({ 652 type: 'post', 653 url: url_epaysubit, 654 data: $('.form-epay').serialize(), 655 success: function (response) { 656 response = JSON.parse(response); 657 if (response.status == "SUCCESS" && response.answer._type == "V4/AuthenticationResponseData") { 658 operationSessionId = response.answer.operationSessionId; 659 createInstructionIframe(response.answer.value); 660 } else { 661 var m = JSON.stringify(response); 662 redirect(url_epaydirect, "POST", m); 663 } 664 }, 665 error: function (err) { 666 console.log("ERROR", err) 667 redirect(url_epaydirect, "POST", err); 668 } 669 }); 670 }); 671 672 673 function createInstructionIframe(instruction) { 674 container = document.getElementById('instructionContainer'); 675 container.innerHTML = ''; 676 var iframe = document.createElement('iframe'); 677 iframe.id = 'instructionIframe'; 678 iframe.name = 'instructionIframe'; 679 iframe.src = 'about:blank'; 680 iframe.style.width = instruction.target.width; 681 iframe.style.height = instruction.target.height; 682 iframe.style.visibility = instruction.target.visible ? 'visible' : 'hidden'; 683 684 if (instruction.timeout) { 685 setTimeout(() => { 686 const instructionResultTimeout = { 687 eventName: 'LYRA_AUTH_INSTRUCTION_RESULT', 688 value: { 689 name: instruction.name, 690 value: 'TIMEOUT', 691 protocol: this.currentProtocol, 692 }, 693 }; 694 window.postMessage(JSON.stringify(instructionResultTimeout), '*'); 695 }, instruction.timeout * 1000); 696 } 697 698 container.appendChild(iframe); 699 var form = document.createElement('form'); 700 form.id = 'instructionForm'; 701 form.name = 'instructionForm'; 702 form.target = 'instructionIframe'; 703 form.method = instruction.http.method; 704 form.action = instruction.http.url; 705 form.style = 'visibility: hidden'; 706 707 // Create form body 708 Object.keys(instruction.http.body).forEach(function (name) { 709 form.innerHTML += '<input name="' + name + '" value="' + instruction.http.body[name] + '">'; 710 }); 711 var body = document.createElement('form'); 712 container.appendChild(form); 713 form.submit(); 714 } 715 716 window.addEventListener('message', function (messageEvent) { 717 718 var data = messageEvent.data; 719 try { 720 var messageData = JSON.parse(data); 721 if (messageData.eventName === 'LYRA_AUTH_INSTRUCTION_RESULT' && this_is === "abo") { 722 try { 723 var m = JSON.stringify({ 'operationSessionId': operationSessionId, 'messageData': messageData }); 724 redirect(url_epaydirect, "POST", m); 725 } catch (err) { 726 redirect(url_epaydirect, "POST", err); 727 } 728 } 729 } catch (err) { 730 // console.log(err); 731 } 732 733 }, false); 734 735 var redirect = function (url, method, value) { 736 var form = document.createElement('form'); 737 form.method = method; 738 form.action = url; 739 740 var input = document.createElement("input"); 741 input.type = "hidden"; 742 input.name = "m"; 743 input.value = value; 744 form.appendChild(input); 745 document.body.appendChild(form); 746 form.submit(); 747 }; 748 749});
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.