function stripeResponseHandler(e,t){var o=$("#checkout-form");if(o.find(".card_details, .checkout-btn").prop("disabled",!1),t.error)o.find(".form-control:focus").blur(),Swal.fire({allowOutsideClick:!1,type:"error",html:t.error.message,showConfirmButton:!1,showCloseButton:!0}),o.find(".card_details, .checkout-btn").prop("disabled",!1);else{var r=t.id;o.find("#stripe_token").val(r);var i=o.serialize(),n=localStorage.getItem("cart_items_"+account_code);$.ajax({url:"scripts/checkout",type:"POST",dataType:"json",data:i+"&cart_items="+n,beforeSend:function(e){console.log(n)},success:function(e,t,r){2===e[0]?Swal.fire({allowOutsideClick:!1,type:"error",html:e[1],showConfirmButton:!1,showCloseButton:!0}):1===e[0]?(o.find(".form-control:focus").blur(),o.get(0).reset(),Swal.fire({allowOutsideClick:!1,type:"success",html:e[1],showConfirmButton:!1,showCloseButton:!0}),console.log(e[2]),clear_cart()):(console.log(JSON.stringify(e)),Swal.fire({allowOutsideClick:!1,type:"error",html:"Error! Please try again.",showConfirmButton:!1,showCloseButton:!0}),o.get(0).reset()),o.find("#stripe_token").val(""),o.find(".card_details, .checkout-btn").prop("disabled",!1)},error:function(e,t,r){alert(JSON.stringify(e)),o.find(".card_details, .checkout-btn").prop("disabled",!1),o.find("#stripe_token").val(""),Swal.fire({allowOutsideClick:!1,type:"error",html:"Error! Please try again.",showConfirmButton:!1,showCloseButton:!0})}})}}"AU"===stripe_account_country?Stripe.setPublishableKey("pk_test_HD5xKOKXeo5Ugw6ofVZN8VhH"):Stripe.setPublishableKey("pk_test_zWyPw9DizWtk72u99TLuO5Dq"),$(function(){var e=$("#checkout-form");e.submit(function(t){e.find("#form_message").text("").slideUp(),t.preventDefault();var o=e.find("#card_name").val(),r=e.find("#card_number").val(),i=e.find("#card_exp_month").val(),n=e.find("#card_exp_year").val(),a=e.find("#card_cvc").val();if(""===o||""===r||""===i||""===n||""===a){Swal.fire({type:"error",html:"Please enter correct form data",showConfirmButton:!1,showCloseButton:!0}),e.find(".checkout-btn").prop("disabled",!1);var l=e.find(".form-control");return $.each(l,function(e,t){var o=$(t).val();if(""===o)return $(t).focus(),!1}),!1}Swal.fire({allowOutsideClick:!1,html:"Processing...",onOpen:()=>{swal.showLoading()}}),e.find(".card_details, .checkout-btn").prop("disabled",!0),Stripe.card.createToken(e,stripeResponseHandler)})});