芝麻web文件管理V1.00
编辑当前文件:/var/www/cognitio.in/wp-content/plugins/stripe-payments/public/assets/js/pp-handler.min.js
var aspTaxVariationsNG=function(data){var parent=this;parent.init=function(){vars.data.default_tax=vars.data.tax;parent.billingSwitch=document.getElementById("same-bill-ship-addr");parent.bCountrySelect=document.getElementById("country");parent.bState=document.getElementById("state");parent.bCity=document.getElementById("city");parent.sCountrySelect=document.getElementById("shipping_country");parent.sState=document.getElementById("shipping_state");parent.sCity=document.getElementById("shipping_city");if(parent.bCountrySelect){parent.bCountrySelect.addEventListener("change",function(){if(this.value==="0"){return}doAddonAction("billingAddressChanged");if(parent.billingSwitch&&parent.billingSwitch.checked){doAddonAction("shippingAddressChanged")}})}if(parent.bState){parent.bState.addEventListener("change",function(){doAddonAction("billingAddressChanged")})}if(parent.bCity){parent.bCity.addEventListener("change",function(){doAddonAction("billingAddressChanged")})}if(parent.sCountrySelect){parent.sCountrySelect.addEventListener("change",function(){if(this.value==="0"){return}doAddonAction("shippingAddressChanged")})}if(parent.sState){parent.sState.addEventListener("change",function(){doAddonAction("shippingAddressChanged")})}if(parent.sCity){parent.sCity.addEventListener("change",function(){doAddonAction("shippingAddressChanged")})}if(parent.billingSwitch){parent.billingSwitch.addEventListener("change",function(){doAddonAction("billingAddressChanged");doAddonAction("shippingAddressChanged")})}doAddonAction("billingAddressChanged")};parent.billingAddressChanged=function(){var bS="";if(parent.bState){bS=parent.bState.value}var bC="";if(parent.bCity){bC=parent.bCity.value}if(vars.data.tax_variations_type!=="b"){if(parent.billingSwitch&&!parent.billingSwitch.checked){return}}if(!parent.bCountrySelect){if(vars.data.new_bill_addr&&vars.data.new_bill_addr.country){parent.doTaxVariations(vars.data.new_bill_addr.country,vars.data.new_bill_addr.state,vars.data.new_bill_addr.city)}return}parent.doTaxVariations(parent.bCountrySelect.value,bS,bC)};parent.shippingAddressChanged=function(){if(!parent.billingSwitch){if(vars.data.new_ship_addr&&vars.data.new_ship_addr.country){parent.doTaxVariations(vars.data.new_ship_addr.country,vars.data.new_ship_addr.state,vars.data.new_ship_addr.city)}return}if(vars.data.tax_variations_type==="s"){if(parent.billingSwitch.checked){doAddonAction("billingAddressChanged")}else{if(!parent.sCountrySelect){return}var sS="";if(parent.sState){sS=parent.sState.value}var sC="";if(parent.sCity){sC=parent.sCity.value}parent.doTaxVariations(parent.sCountrySelect.value,sS,sC)}}};this.doTaxVariations=function(cCode,state,city){var newTax=0;var applied=0;vars.data.tax_variations.forEach(function(v){switch(v.type){case"0":if(cCode&&v.loc===cCode){newTax+=v.amount;applied++}break;case"1":if(state&&v.loc.toLowerCase()===state.toLowerCase()){newTax+=v.amount;applied++}break;case"2":if(city&&v.loc.toLowerCase()===city.toLowerCase()){newTax+=v.amount;applied++}break;default:break}if(applied>0){vars.data.tax=newTax;updateAllAmounts()}else if(vars.data.tax!==vars.data.default_tax){vars.data.tax=vars.data.default_tax;updateAllAmounts()}})}};!function(){"use strict";function t(t){if(t)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=l;else if(a){var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var r="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1);var s=!e&&"object"==typeof self,h=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;h?i=global:s&&(i=self);var f=!i.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o="function"==typeof define&&define.amd,a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var b=function(r){return function(e){return new t(!0).update(e)[r]()}},v=function(){var r=b("hex");h&&(r=w(r)),r.create=function(){return new t},r.update=function(t){return r.create().update(t)};for(var e=0;e
>2]|=t[f]<
>6,u[h++]=128|63&s):s<55296||s>=57344?(u[h++]=224|s>>12,u[h++]=128|s>>6&63,u[h++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++f)),u[h++]=240|s>>18,u[h++]=128|s>>12&63,u[h++]=128|s>>6&63,u[h++]=128|63&s);else for(h=this.start;f
>2]|=s<
>2]|=(192|s>>6)<
>2]|=(128|63&s)<
=57344?(n[h>>2]|=(224|s>>12)<
>2]|=(128|s>>6&63)<
>2]|=(128|63&s)<
>2]|=(240|s>>18)<
>2]|=(128|s>>12&63)<
>2]|=(128|s>>6&63)<
>2]|=(128|63&s)<
=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>2]|=u[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var t,r,e,i,s,h,f=this.blocks;this.first?r=((r=((t=((t=f[0]-680876937)<<7|t>>>25)-271733879<<0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+f[1]-117830708)<<12|i>>>20)+t<<0)&(-271733879^t))+f[2]-1126478375)<<17|e>>>15)+i<<0)&(i^t))+f[3]-1316259209)<<22|r>>>10)+e<<0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+f[0]-680876936)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[1]-389564586)<<12|i>>>20)+t<<0)&(t^r))+f[2]+606105819)<<17|e>>>15)+i<<0)&(i^t))+f[3]-1044525330)<<22|r>>>10)+e<<0),r=((r+=((t=((t+=(i^r&(e^i))+f[4]-176418897)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[5]+1200080426)<<12|i>>>20)+t<<0)&(t^r))+f[6]-1473231341)<<17|e>>>15)+i<<0)&(i^t))+f[7]-45705983)<<22|r>>>10)+e<<0,r=((r+=((t=((t+=(i^r&(e^i))+f[8]+1770035416)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[9]-1958414417)<<12|i>>>20)+t<<0)&(t^r))+f[10]-42063)<<17|e>>>15)+i<<0)&(i^t))+f[11]-1990404162)<<22|r>>>10)+e<<0,r=((r+=((t=((t+=(i^r&(e^i))+f[12]+1804603682)<<7|t>>>25)+r<<0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+f[13]-40341101)<<12|i>>>20)+t<<0)&(t^r))+f[14]-1502002290)<<17|e>>>15)+i<<0)&(i^t))+f[15]+1236535329)<<22|r>>>10)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[1]-165796510)<<5|t>>>27)+r<<0)^r))+f[6]-1069501632)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[11]+643717713)<<14|e>>>18)+i<<0)^i))+f[0]-373897302)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[5]-701558691)<<5|t>>>27)+r<<0)^r))+f[10]+38016083)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[15]-660478335)<<14|e>>>18)+i<<0)^i))+f[4]-405537848)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[9]+568446438)<<5|t>>>27)+r<<0)^r))+f[14]-1019803690)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[3]-187363961)<<14|e>>>18)+i<<0)^i))+f[8]+1163531501)<<20|r>>>12)+e<<0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+f[13]-1444681467)<<5|t>>>27)+r<<0)^r))+f[2]-51403784)<<9|i>>>23)+t<<0)^t&((e=((e+=(t^r&(i^t))+f[7]+1735328473)<<14|e>>>18)+i<<0)^i))+f[12]-1926607734)<<20|r>>>12)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[5]-378558)<<4|t>>>28)+r<<0))+f[8]-2022574463)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[11]+1839030562)<<16|e>>>16)+i<<0))+f[14]-35309556)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[1]-1530992060)<<4|t>>>28)+r<<0))+f[4]+1272893353)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[7]-155497632)<<16|e>>>16)+i<<0))+f[10]-1094730640)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[13]+681279174)<<4|t>>>28)+r<<0))+f[0]-358537222)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[3]-722521979)<<16|e>>>16)+i<<0))+f[6]+76029189)<<23|r>>>9)+e<<0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+f[9]-640364487)<<4|t>>>28)+r<<0))+f[12]-421815835)<<11|i>>>21)+t<<0)^t)^(e=((e+=(h^r)+f[15]+530742520)<<16|e>>>16)+i<<0))+f[2]-995338651)<<23|r>>>9)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[0]-198630844)<<6|t>>>26)+r<<0)|~e))+f[7]+1126891415)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[14]-1416354905)<<15|e>>>17)+i<<0)|~t))+f[5]-57434055)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[12]+1700485571)<<6|t>>>26)+r<<0)|~e))+f[3]-1894986606)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[10]-1051523)<<15|e>>>17)+i<<0)|~t))+f[1]-2054922799)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[8]+1873313359)<<6|t>>>26)+r<<0)|~e))+f[15]-30611744)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[6]-1560198380)<<15|e>>>17)+i<<0)|~t))+f[13]+1309151649)<<21|r>>>11)+e<<0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+f[4]-145523070)<<6|t>>>26)+r<<0)|~e))+f[11]-1120210379)<<10|i>>>22)+t<<0)^((e=((e+=(t^(i|~r))+f[2]+718787259)<<15|e>>>17)+i<<0)|~t))+f[9]-343485551)<<21|r>>>11)+e<<0,this.first?(this.h0=t+1732584193<<0,this.h1=r-271733879<<0,this.h2=e-1732584194<<0,this.h3=i+271733878<<0,this.first=!1):(this.h0=this.h0+t<<0,this.h1=this.h1+r<<0,this.h2=this.h2+e<<0,this.h3=this.h3+i<<0)},t.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&e,e>>8&255,e>>16&255,e>>24&255,255&i,i>>8&255,i>>16&255,i>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var t,r,e,i="",s=this.array(),h=0;h<15;)t=s[h++],r=s[h++],e=s[h++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=s[h],i+=p[t>>>2]+p[t<<4&63]+"=="};var _=v();f?module.exports=_:(i.md5=_,o&&define(function(){return _}))}();var closeBtn=document.getElementById("modal-close-btn");closeBtn.addEventListener("click",function(){if(typeof checkAgeInterval!=="undefined"){clearInterval(checkAgeInterval);checkAgeInterval=undefined}window.history.replaceState(null,"",null);window.history.go(-1)});const initTime=Date.now();var checkAgeInterval;checkAge();popstateAttachEvent();var errorCont=document.getElementById("global-error");if(vars.fatal_error){showPopup();throw new Error(vars.fatal_error)}try{var stripe=Stripe(vars.stripe_key,{apiVersion:vars.stripe_api_ver});var elements=stripe.elements({locale:vars.data.checkout_lang})}catch(error){showPopup();errorCont.innerHTML=error;errorCont.style.display="block";document.getElementById("payment-form").style.display="none";throw new Error(error)}vars.data.visitor_token=md5(navigator.userAgent+vars.data.button_key);vars.data.temp=[];if(vars.data.amount_variable&&vars.data.hide_amount_input!=="1"){var amountInput=document.getElementById("amount");var amountErr=document.getElementById("amount-error");amountInput.addEventListener("change",function(){amount=validate_custom_amount();if(amount!==false){vars.data.item_price=amount;updateAllAmounts()}})}if(vars.data.custom_quantity){var quantityInput=document.getElementById("quantity");var quantityErr=document.getElementById("quantity-error");quantityInput.addEventListener("change",function(){quantity=validate_custom_quantity();if(quantity!==false){vars.data.quantity=quantity;updateAllAmounts()}})}if(vars.data.currency_variable){var currencyInput=document.getElementById("currency");currencyInput.addEventListener("change",function(){vars.data.currency=currencyInput.value||currencyInput.options[currencyInput.selectedIndex];vars.currencyFormat.s=currencyInput.options[currencyInput.selectedIndex].getAttribute("data-asp-curr-sym");updateAllAmounts()})}if(vars.data.custom_field){var customFieldInput=document.getElementById("asp-custom-field");var customFieldErr=document.getElementById("custom-field-error");if(customFieldInput){customFieldInput.addEventListener("change",function(){validate_custom_field()})}}if(vars.data.coupons_enabled){var couponBtn=document.getElementById("apply-coupon-btn");var couponRemoveBtn=document.getElementById("remove-coupon-btn");var couponResCont=document.getElementById("coupon-res-cont");var couponInputCont=document.getElementById("coupon-input-cont");var couponInput=document.getElementById("coupon-code");var couponErr=document.getElementById("coupon-err");var couponInfo=document.getElementById("coupon-info");couponInput.addEventListener("keydown",function(event){if(event.keyCode===13){event.preventDefault();couponBtn.click();return false}});couponBtn.addEventListener("click",function(event){event.preventDefault();couponErr.style.display="none";if(couponInput.value===""){return false}couponBtn.disabled=true;smokeScreen(true);var ajaxData="action=asp_pp_check_coupon&product_id="+vars.data.product_id+"&coupon_code="+couponInput.value;new ajaxRequest(vars.ajaxURL,ajaxData,function(res){console.log(res);var resp=JSON.parse(res.responseText);if(resp.err){delete vars.data.coupon;console.log(resp.err);showFormInputErr(resp.err,couponErr,couponInput)}else{vars.data.coupon=resp;console.log(vars.data.coupon);calcTotal();couponInfo.innerHTML=vars.data.coupon.code+": "+" - ";if(vars.data.coupon.discount_type==="perc"){couponInfo.innerHTML=couponInfo.innerHTML+vars.data.coupon.discount+"%"}else{couponInfo.innerHTML=couponInfo.innerHTML+formatMoney(amount_to_cents(vars.data.coupon.discount,vars.data.currency))}if(vars.data.is_trial){couponInfo.innerHTML=couponInfo.innerHTML+vars.str.strforRecurringPayments}couponResCont.style.display="block";couponInputCont.style.display="none";if(is_full_discount()){jQuery('[data-pm-id="def"]').click();jQuery("#pm-select-cont").hide();jQuery("#card-cont").hide()}}updateAllAmounts();couponBtn.disabled=false;smokeScreen(false)},function(res,errMsg){errorCont.innerHTML=errMsg;errorCont.style.display="block";couponBtn.disabled=false;smokeScreen(false)})});couponRemoveBtn.addEventListener("click",function(){if(is_full_discount()){jQuery("#pm-select-cont").show();jQuery("#card-cont").show();if(vars.data.shipping_orig){vars.data.shipping=vars.data.shipping_orig}}delete vars.data.coupon;jQuery("#order-coupon-line").remove();couponInput.value="";couponResCont.style.display="none";couponInputCont.style.display="block";updateAllAmounts()})}var amount=vars.data.amount;var clientSecAmount=0;var clientSecCurrency="";var style={base:{fontSize:"16px"}};var submitBtn=document.getElementById("submit-btn");var piInput=document.getElementById("payment-intent");var cardErrorCont=document.getElementById("card-errors");var form=document.getElementById("payment-form");if(vars.data.tos){var tosInput=document.getElementById("tos");var tosInputErr=document.getElementById("tos-error");tosInput.addEventListener("change",function(){tosInputErr.style.display="none"})}if(!jQuery.isEmptyObject(vars.data.variations)){var varInputs=document.getElementsByClassName("variations-input");vars.data.temp.prePopupDisplayVariationsUpdate=true;for(var i=0;i
0){jQuery("#order-tax-line").show()}jQuery("#shipping").html(formatMoney(vars.data.shipping));if(vars.data.coupon&&!vars.data.is_trial){if(jQuery("tr#order-coupon-line").length===0){var couponOrderLine='
'+vars.str.strCoupon+' "'+vars.data.coupon.code+'"
-
';if(jQuery("tr.variation-line").last().length!==0){jQuery("tr.variation-line").last().after(couponOrderLine)}else{jQuery("tr#order-item-line").after(couponOrderLine)}}var couponDiscountAmount=vars.data.coupon.discount_amount;if(vars.data.coupon.discount_amount>vars.data.coupon.amount_before_discount){couponDiscountAmount=vars.data.coupon.amount_before_discount}jQuery("#order-coupon").html(formatMoney(couponDiscountAmount))}if(vars.data.variations.applied){for(grpId=0;grpId
')}var varNames="";var varPrices="";if(vars.data.variations.applied[grpId]instanceof Array){for(varId=0;varId
";varPrices+=formatMoney(amount_to_cents(vars.data.variations.prices[grpId][varId],vars.data.currency)*vars.data.quantity)+"
"}}}else{varNames=vars.data.variations.names[grpId][vars.data.variations.applied[grpId]];varPrices=formatMoney(amount_to_cents(vars.data.variations.prices[grpId][vars.data.variations.applied[grpId]],vars.data.currency)*vars.data.quantity)}if(!varNames&&!varPrices){jQuery("tr#order-variation-"+grpId+"-line").remove()}else{varNames=vars.data.variations.groups[grpId]+"
"+varNames;varPrices="
"+varPrices;jQuery("#order-variation-"+grpId+"-line").find(".variation-name").html(varNames);jQuery("#order-variation-"+grpId+"-line").find(".variation-price").html(varPrices)}}}}}doAddonAction("allAmountsUpdated")}function calcTotal(){var itemSubt=vars.data.item_price;var tAmount=0;var grpId;var i;if(vars.data.items){for(i=0;i
=0?1:-1;return parseFloat((Math.round(num*Math.pow(10,dec)+num_sign*1e-4)/Math.pow(10,dec)).toFixed(dec))}function is_zero_cents(curr){if(vars.zeroCents.indexOf(curr.toUpperCase())===-1){return false}return true}function cents_to_amount(amount,curr){if(!is_zero_cents(curr)){amount=PHP_round(amount/100,2)}else{amount=PHP_round(amount,0)}return amount}function amount_to_cents(amount,curr){amount=parseFloat(amount);if(!is_zero_cents(curr)){amount=amount*100}return PHP_round(amount,0)}function showFormInputErr(msg,el,inp){el.innerHTML=msg;jQuery(el).show().hide().fadeIn();jQuery(inp).focus()}function showPopup(){if(typeof jQuery!=="undefined"){jQuery("#global-spinner").hide();jQuery("#Aligner-item").addClass("popup-show").hide().fadeIn()}else{document.getElementById("global-spinner").style.display="none";document.getElementById("Aligner-item").classList.add("popup-show")}}function smokeScreen(show){if(show){display="flex"}else{display="none"}document.getElementById("smoke-screen").style.display=display}function formatMoney(n){var negative=false;if(n<0){n=0-n;negative=true}n=cents_to_amount(n,vars.data.currency);var c=isNaN(c=Math.abs(vars.currencyFormat.c))?2:vars.currencyFormat.c,d=vars.currencyFormat.d,t=vars.currencyFormat.t,s=n<0?"-":"",i=String(parseInt(n=Math.abs(Number(n)||0).toFixed(c))),j=(j=i.length)>3?j%3:0;var result=s+(j?i.substr(0,j)+t:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):"");result=vars.currencyFormat.pos!=="right"?vars.currencyFormat.s+result:result+vars.currencyFormat.s;return negative?"- "+result:result}function inIframe(){try{return window.self!==window.top}catch(e){return true}}function is_full_discount(){if(vars.data.coupon&&(vars.data.coupon.discount_type==="perc"&&parseFloat(vars.data.coupon.discount)===100||vars.data.coupon.discount_amount>=vars.data.coupon.amount_before_discount)){return true}return false}function triggerEvent(el,type){var evt;if("createEvent"in document){evt=new Event(type,{bubbles:true,cancelable:true});el.dispatchEvent(evt)}else{evt=document.createEventObject();evt.eventType=type;el.fireEvent("on"+evt.eventType,evt)}}function validate_custom_field(){if(!customFieldInput){return true}if(vars.custom_field_validation_regex!==""){try{var re=new RegExp(vars.data.custom_field_validation_regex)}catch(error){showFormInputErr(vars.str.strInvalidCFValidationRegex+" "+vars.data.custom_field_validation_regex+"\n"+error,errorCont,customFieldInput);return false}}if(customFieldInput.type==="text"&&customFieldInput.value&&!re.test(customFieldInput.value)){showFormInputErr(vars.data.custom_field_validation_err_msg,customFieldErr,customFieldInput);return false}customFieldErr.style.display="none";return true}function validate_custom_quantity(){var custom_quantity_orig;var errObj;if(vars.data.custom_quantity){errObj=quantityErr;custom_quantity_orig=quantityInput.value}else{errObj=errorCont;custom_quantity_orig=vars.data.quantity}var custom_quantity=parseInt(custom_quantity_orig);if(isNaN(custom_quantity)){showFormInputErr(vars.str.strEnterQuantity,errObj,quantityInput);return false}else if(custom_quantity_orig%1!==0){showFormInputErr(vars.str.strQuantityIsFloat,errObj,quantityInput);return false}else if(custom_quantity<=0){showFormInputErr(vars.str.strQuantityIsZero,errObj,quantityInput);return false}else if(vars.data.stock_control_enabled===true&&custom_quantity>vars.data.stock_items){showFormInputErr(vars.str.strStockNotAvailable.replace("%d",vars.data.stock_items),errObj,quantityInput);return false}errObj.style.display="none";vars.data.quantity=custom_quantity;return custom_quantity}function validate_custom_amount(){var cAmount=amountInput.value;if(vars.amountOpts.applySepOpts!=0){cAmount=cAmount.replace(vars.amountOpts.thousandSep,"");cAmount=cAmount.replace(vars.amountOpts.decimalSep,".")}else{cAmount=cAmount.replace(/\$/g,"");cAmount=cAmount.replace(/,/g,"");cAmount=cAmount.replace(/ /g,"")}cAmount=parseFloat(cAmount);if(isNaN(cAmount)){showFormInputErr(vars.str.strEnterValidAmount,amountErr,amountInput);return false}var displayAmount=cAmount.toFixed(2).toString();if(vars.amountOpts.applySepOpts!=0){displayAmount=displayAmount.replace(".",vars.amountOpts.decimalSep)}if(!is_zero_cents(vars.data.currency)){cAmount=PHP_round(cAmount*100,0)}if(vars.data.min_amount!==0&&vars.data.min_amount>cAmount){showFormInputErr(vars.str.strMinAmount+" "+formatMoney(vars.data.min_amount),amountErr,amountInput);return false}if(typeof vars.minAmounts[vars.data.currency]!=="undefined"){if(vars.minAmounts[vars.data.currency]>cAmount){showFormInputErr(vars.str.strMinAmount+" "+formatMoney(vars.minAmounts[vars.data.currency]),amountErr,amountInput);return false}}else if(50>cAmount){showFormInputErr(vars.str.strMinAmount+" "+formatMoney(50),amountErr,amountInput);return false}amountErr.style.display="none";amountInput.value=displayAmount;return cAmount}function canProceed(){if(vars.data.amount_variable&&vars.data.hide_amount_input!=="1"){amount=validate_custom_amount(); if(amount===false){return false}vars.data.item_price=amount}if(vars.data.custom_quantity){quantity=validate_custom_quantity();if(quantity===false){return false}vars.data.quantity=quantity}if(vars.data.custom_field){var custom_field_valid=validate_custom_field();if(custom_field_valid===false){return false}}if(piInput.value!==""){jQuery("#btn-spinner").hide();jQuery("#checkmark-cont").css("display","flex");var isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);setTimeout(function(){jQuery("#Aligner-item").fadeOut(function(){smokeScreen(false);jQuery("#global-spinner").show();if(isSafari){form.submit()}})},1500);if(!inIframe()||window.doSelfSubmit){console.log("Self-submitting");for(var i=0;i
'+vars.str.strPleaseCheckCheckbox+"").fadeIn())}else{jQuery(el).after(jQuery('
'+vars.str.strPleaseFillIn+"
").fadeIn())}return false}});if(autoRequiredEmpty){return false}if(vars.data.tos){if(!tosInput.checked){showFormInputErr(vars.str.strMustAcceptTos,tosInputErr,tosInput);return false}}vars.data.canProceed=true;doAddonAction("submitCanProceed");if(!vars.data.canProceed){return false}return true}function handlePayment(){var billingNameInput=document.getElementById("billing-name");var emailInput=document.getElementById("email");var billingDetails={name:billingNameInput.value,email:encodeURIComponent(emailInput.value)};if(vars.data.billing_address){var bAddr=document.getElementById("address");var bCity=document.getElementById("city");var bCountry=document.getElementById("country");var bState=document.getElementById("state");var bPostcode=document.getElementById("postcode");billingDetails.address={line1:bAddr.value,city:bCity.value,state:bState===null?null:bState.value,country:bCountry.value||bCountry.options[bCountry.selectedIndex].value};var postal_code=bPostcode.value;if(postal_code){billingDetails.address.postal_code=postal_code}}if(vars.data.shipping_address){var shippingDetails={name:billingNameInput.value};var sAddr=document.getElementById("shipping_address");var sCity=document.getElementById("shipping_city");var sCountry=document.getElementById("shipping_country");var sState=document.getElementById("shipping_state");var sPostcode=document.getElementById("shipping_postcode");shippingDetails.address={line1:sAddr.value,city:sCity.value,state:sState===null?null:sState.value,country:sCountry.value||sCountry.options[sCountry.selectedIndex].value};var spostal_code=sPostcode.value;if(spostal_code){shippingDetails.address.postal_code=spostal_code}}if(vars.data.billing_address&&vars.data.shipping_address&&billshipSwitch.checked){shippingDetails=JSON.parse(JSON.stringify(billingDetails));delete shippingDetails.email}var opts={payment_method:{card:card,billing_details:billingDetails}};if(shippingDetails){opts.shipping=shippingDetails}vars.data.billingDetails=billingDetails;doAddonAction("csBeforeRegen");if(vars.data.doNotProceed){return false}if(!is_full_discount()&&!vars.data.token_not_required&&(vars.data.client_secret===""||vars.data.amount!==clientSecAmount||vars.data.currency!==clientSecCurrency)){var reqStr="action=asp_pp_create_pi&nonce="+vars.asp_pp_ajax_create_pi_nonce+"&amount="+vars.data.amount+"&curr="+vars.data.currency+"&product_id="+vars.data.product_id;reqStr=reqStr+"&quantity="+vars.data.quantity;if(vars.data.cust_id){reqStr=reqStr+"&cust_id="+vars.data.cust_id}if(vars.data.client_secret!==""){reqStr=reqStr+"&pi="+vars.data.pi_id}reqStr=reqStr+"&billing_details="+JSON.stringify(billingDetails);if(shippingDetails){reqStr=reqStr+"&shipping_details="+JSON.stringify(shippingDetails)}reqStr+="&token="+vars.data.visitor_token;vars.data.csRegenParams=reqStr;doAddonAction("csBeforeRegenParams");console.log("Doing asp_pp_create_pi");new ajaxRequest(vars.ajaxURL,vars.data.csRegenParams,function(res){try{var resp=JSON.parse(res.responseText);console.log(resp);if(typeof resp.stock_items!=="undefined"){if(vars.data.stock_items!==resp.stock_items){vars.data.stock_items=resp.stock_items;validate_custom_quantity()}}if(!resp.success){submitBtn.disabled=false;errorCont.innerHTML=resp.err;errorCont.style.display="block";smokeScreen(false);return false}vars.data.client_secret=resp.clientSecret;vars.data.pi_id=resp.pi_id;vars.data.cust_id=resp.cust_id;clientSecAmount=vars.data.amount;clientSecCurrency=vars.data.currency;doAddonAction("csRegenCompleted");if(vars.data.doNotProceed){return false}handlePayment();return true}catch(e){console.log(e);alert("Caught Exception: "+e)}},function(res,errMsg){submitBtn.disabled=false;errorCont.innerHTML=errMsg;errorCont.style.display="block";smokeScreen(false)});return false}doAddonAction("csReady");if(vars.data.doNotProceed){return false}if(!is_full_discount()&&vars.data.create_token){console.log("Creating token");opts={name:billingNameInput.value};if(vars.data.billing_address){opts.address_line1=bAddr.value;opts.address_city=bCity.value;opts.address_state=bState===null?"":bState.value;opts.address_country=bCountry.value||bCountry.options[bCountry.selectedIndex].value;if(postal_code){opts.address_zip=postal_code}}var ct_reqStr="&product_id="+vars.data.product_id;if(vars.data.cust_id){ct_reqStr=ct_reqStr+"&cust_id="+vars.data.cust_id}if(vars.data.currency_variable){ct_reqStr=ct_reqStr+"¤cy="+vars.data.currency}if(vars.data.amount_variable&&vars.data.hide_amount_input!=="1"){ct_reqStr=ct_reqStr+"&amount="+vars.data.item_price}if(vars.data.quantity>1){ct_reqStr=ct_reqStr+"&quantity="+vars.data.quantity}if(vars.data.coupon){ct_reqStr=ct_reqStr+"&coupon="+vars.data.coupon.code}ct_reqStr=ct_reqStr+"&billing_details="+JSON.stringify(billingDetails);if(shippingDetails){ct_reqStr=ct_reqStr+"&shipping_details="+JSON.stringify(shippingDetails)}ct_reqStr+="&token="+vars.data.visitor_token;vars.confirmToken_reqStr=ct_reqStr;doAddonAction("preConfirmToken");ct_reqStr=vars.confirmToken_reqStr;if(vars.data.pm_id){ct_reqStr="action=asp_pp_confirm_token&asp_pm_id="+vars.data.pm_id+ct_reqStr;confirmToken(ct_reqStr);return true}stripe.createToken(card,opts).then(function(result){console.log(result);if(result.error){submitBtn.disabled=false;errorCont.innerHTML=result.error.message;errorCont.style.display="block";smokeScreen(false)}else{ct_reqStr="action=asp_pp_confirm_token&asp_token_id="+result.token.id+ct_reqStr;vars.data.token_id=result.token.id;confirmToken(ct_reqStr)}});return false}if(vars.data.no_action_required){return true}if(is_full_discount()){handleCardPaymentResult({paymentIntent:{id:vars.data.coupon.zero_value_id}});return false}if(vars.data.do_card_setup){if(opts.shipping){opts.shipping=undefined}console.log("Doing confirmCardSetup()");stripe.confirmCardSetup(vars.data.client_secret,opts).then(function(result){console.log(result);if(result.error){submitBtn.disabled=false;errorCont.innerHTML=result.error.message;errorCont.style.display="block";smokeScreen(false)}else{piInput.value=document.getElementById("sub_id").value;if(!vars.data.coupon&&couponInput){couponInput.value=""}triggerEvent(form,"submit")}});return}if(!vars.data.dont_save_card&&!vars.data.dont_setup_future_usage){opts.save_payment_method=true;opts.setup_future_usage="off_session"}if(vars.data.stripe_receipt_email){opts.receipt_email=encodeURIComponent(emailInput.value)}if(vars.data.pm_id||vars.data.token_id){confirmPI();return}var c_opts={name:billingNameInput.value};if(vars.data.billing_address){c_opts.address_line1=bAddr.value;c_opts.address_city=bCity.value;c_opts.address_state=bState===null?"":bState.value;c_opts.address_country=bCountry.value||bCountry.options[bCountry.selectedIndex].value;if(postal_code){c_opts.address_zip=postal_code}}console.log("Doing createToken()");stripe.createToken(card,c_opts).then(function(result){console.log(result);if(result.error){submitBtn.disabled=false;errorCont.innerHTML=result.error.message;errorCont.style.display="block";smokeScreen(false)}else{vars.data.token_id=result.token.id;confirmPI();return}});function confirmPI(){delete opts.payment_method;if(!vars.data.pm_confirmed){opts.payment_method_data={type:"card"};opts.payment_method_data.card={token:vars.data.token_id};if(vars.data.dont_save_card){opts.payment_method_data.billing_details={name:billingNameInput.value,email:encodeURIComponent(emailInput.value)}}}else{delete opts.save_payment_method;delete opts.setup_future_usage}vars.confirmCardPayment={};vars.confirmCardPayment.opts=opts;doAddonAction("confirmCardPaymentOpts");console.log("Doing asp_pp_confirm_pi");opts=vars.confirmCardPayment.opts;new ajaxRequest(vars.ajaxURL,"action=asp_pp_confirm_pi&nonce="+vars.asp_pp_ajax_nonce+"&product_id="+vars.data.product_id+"&pi_id="+vars.data.pi_id+"&token="+vars.data.visitor_token+"&opts="+JSON.stringify(opts),function(response){console.log(response);var resp=JSON.parse(response.response);if(resp.err){vars.data.token_id=null;vars.data.pm_id=null;vars.data.pm_confirmed=false;submitBtn.disabled=false;errorCont.innerHTML=resp.err;errorCont.style.display="block";smokeScreen(false);return false}if(resp.redirect_to){if(resp.use_iframe){console.log("3D Secure init");jQuery("#btn-spinner").hide();jQuery("#redirect-spinner").fadeIn();jQuery("#asp-3ds-popup").remove();jQuery("#Aligner").append('
');jQuery("#asp-3ds-popup").on("load",function(){jQuery(this).fadeIn();jQuery("#threeds-iframe-close-btn").show();jQuery(this).off("load")})}else{console.log("3D Secure redirect");saveFormData(function(){jQuery("#btn-spinner").hide();jQuery("#redirect-spinner").fadeIn();if(!inIframe||window.doSelfSubmit){window.location.href=resp.redirect_to}else{window.top.location.href=resp.redirect_to}},null)}return}piInput.value=vars.data.pi_id;if(!vars.data.coupon&&couponInput){couponInput.value=""}triggerEvent(form,"submit")},function(response,errMsg){submitBtn.disabled=false;errorCont.innerHTML=errMsg;errorCont.style.display="block";smokeScreen(false)})}}function ThreeDSCompleted(pi_cs){console.log("3D Secure completed");jQuery("#asp-3ds-popup").remove();jQuery("#threeds-iframe-close-btn").hide();jQuery("#redirect-spinner").hide();jQuery("#btn-spinner").fadeIn();stripe.retrievePaymentIntent(pi_cs).then(function(result){console.log(result);if(result.error||result.paymentIntent.status!=="requires_confirmation"&&result.paymentIntent.status!=="succeeded"){vars.data.token_id=null;vars.data.pm_id=null;vars.data.pm_confirmed=false;submitBtn.disabled=false;errorCont.innerHTML=vars.str.str3DSecureFailed;errorCont.style.display="block";smokeScreen(false)}else{vars.data.pm_confirmed=true;handlePayment()}})}function handleCardPaymentResult(result){if(result.error){submitBtn.disabled=false;errorCont.innerHTML=result.error.message;errorCont.style.display="block";smokeScreen(false)}else{piInput.value=result.paymentIntent.id;if(!vars.data.coupon&&couponInput){couponInput.value=""}jQuery(form).trigger("submit");return true}}function confirmToken(reqStr){vars.data.confirmTokenStr=reqStr;vars.data.canProceed=true;console.log("Doing action asp_pp_confirm_token");doAddonAction("confirmToken");if(!vars.data.canProceed){return false}new ajaxRequest(vars.ajaxURL,reqStr,function(res){try{var resp=JSON.parse(res.responseText);console.log(resp);if(!resp.success){submitBtn.disabled=false;errorCont.innerHTML=resp.err;errorCont.style.display="block";smokeScreen(false);return false}var inputSubId=document.getElementById("sub_id");inputSubId.value=resp.sub_id;if(resp.cust_id){vars.data.cust_id=resp.cust_id}if(resp.pi_cs){vars.data.client_secret=resp.pi_cs;vars.data.create_token=false;if(resp.do_card_setup){vars.data.do_card_setup=true}vars.data.pi_id=resp.pi_id;vars.data.pm_confirmed=true;handlePayment()}else{piInput.value=resp.pi_id;if(resp.no_action_required){vars.data.no_action_required=true}if(!vars.data.coupon&&couponInput){couponInput.value=""}vars.data.pi_id=resp.pi_id;submitForm()}}catch(e){console.log(e);alert("Caught Exception: "+e)}},function(res,errMsg){submitBtn.disabled=false;errorCont.innerHTML=errMsg;errorCont.style.display="block";smokeScreen(false)})}function submitForm(){triggerEvent(form,"submit")}function doAddonAction(action){vars.data.doNotProceed=false;if(vars.data.addons){vars.data.addons.forEach(function(addon){if(typeof addon.obj==="undefined"&&typeof window[addon.handler]!=="undefined"){addon.obj=new window[addon.handler](vars.data)}if(typeof addon.obj!=="undefined"&&typeof addon.obj[action]==="function"){console.log(addon.name+": "+action);addon.obj[action]()}})}}function toggleRequiredElements(els,hide){els.forEach(function(el){if(hide){jQuery("#"+el).hide()}else{jQuery("#"+el).show()}});if(hide){jQuery("#payment-form").find("[required]").not(":visible").each(function(id,el){jQuery(el).prop("required",false);jQuery(el).attr("data-required-hidden",1)})}else{jQuery("#payment-form").find('[data-required-hidden="1"]').each(function(id,el){jQuery(el).prop("required",true);jQuery(el).attr("data-required-hidden",0)})}}function saveFormData(success_cb,error_cb){var reqStr="action=asp_pp_save_form_data&nonce="+vars.asp_pp_ajax_nonce+"&form_data="+encodeURIComponent(jQuery(form).serialize());new ajaxRequest(vars.ajaxURL,reqStr,success_cb,error_cb)}function popStateListener(){if(typeof parent.WPASPClosePaymentPopup==="function"){window.removeEventListener("popstate",popStateListener);window.history.replaceState(null,"",null);this.closeBtn.focus();parent.WPASPClosePaymentPopup()}else{window.history.go(-1)}}function popstateAttachEvent(){if(typeof history.pushState==="function"&&typeof parent.WPASPClosePaymentPopup==="function"){window.addEventListener("popstate",popStateListener);window.history.pushState({aspPopup:1},"",null)}}function popupDisplayed(){checkAge();popstateAttachEvent()}function checkAge(){if(typeof checkAgeInterval==="undefined"){checkAgeInterval=setInterval(checkAge,6e4)}if(vars.data.initTime+3600
=0){return url.replace(pattern,"$1"+paramValue+"$2")}url=url.replace(/[?#]$/,"");return url+(url.indexOf("?")>0?"&":"?")+paramName+"="+paramValue}var ajaxRequest=function(URL,reqStr,doneFunc,failFunc){var parent=this;this.URL=URL;this.reqStr=reqStr;this.doneFunc=doneFunc;this.failFunc=failFunc;this.XMLHttpReq=new XMLHttpRequest;if(!this.XMLHttpReq){alert("Cannot create an XMLHTTP instance");return false}parent.XMLHttpReq.onreadystatechange=function(){if(parent.XMLHttpReq.readyState===XMLHttpRequest.DONE){if(parent.XMLHttpReq.status===200){if(parent.doneFunc){parent.doneFunc(parent.XMLHttpReq)}}else{console.log("ajaxRequest failed");console.log(parent.XMLHttpReq);var errMsg="Error occurred:"+" "+parent.XMLHttpReq.statusText+"\n";errMsg+="URL: "+parent.XMLHttpReq.responseURL+"\n";errMsg+="Code: "+parent.XMLHttpReq.status;if(parent.failFunc){parent.failFunc(parent.XMLHttpReq,errMsg)}}}};parent.XMLHttpReq.open("POST",parent.URL);parent.XMLHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");parent.XMLHttpReq.send(reqStr)};jQuery("#threeds-iframe-close-btn").on("click",function(){if(confirm(vars.str.strAbort3DSecure)){console.log("3d Secure check aborted");jQuery("#asp-3ds-popup").remove();jQuery("#threeds-iframe-close-btn").hide();jQuery("#redirect-spinner").hide();jQuery("#btn-spinner").fadeIn();vars.data.token_id=null;vars.data.pm_id=null;vars.data.pm_confirmed=false;submitBtn.disabled=false;errorCont.innerHTML=vars.str.str3DSecureFailed;errorCont.style.display="block";smokeScreen(false)}});