2015-11-09 23:36:52 +00:00
|
|
|
!function(e){function r(){var r=e("form.checkout, form#order_review");if(e("#payment_method_simplify_commerce").is(":checked")&&0===e("input.simplify-token").size()){r.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o=e("#simplify_commerce-card-number").val(),n=e("#simplify_commerce-card-cvc").val(),c=e.payment.cardExpiryVal(e("#simplify_commerce-card-expiry").val()),m=r.find("#billing_address_1").val(),l=r.find("#billing_address_2").val(),a=r.find("#billing_country").val(),f=r.find("#billing_state").val(),s=r.find("#billing_city").val(),t=r.find("#billing_postcode").val(),d=r.find("#billing_first_name").val()+" "+r.find("#billing_last_name").val();return o=o.replace(/\s/g,""),SimplifyCommerce.generateToken({key:Simplify_commerce_params.key,card:{number:o,cvc:n,expMonth:c.month,expYear:c.year-2e3,addressLine1:m,addressLine2:l,addressCountry:a,addressState:f,addressZip:t,addressCity:s,name:d}},i),!1}return!0}function i(r){var i=e("form.checkout, form#order_review"),o=e("#simplify_commerce-cc-form");if(r.error){if(e(".woocommerce-error, .simplify-token",o).remove(),i.unblock(),"validation"===r.error.code){for(var n=r.error.fieldErrors,c=n.length,m="",l=0;c>l;l++)m+="<li>"+Simplify_commerce_params[n[l].field]+" "+Simplify_commerce_params.is_invalid+" - "+n[l].message+".</li>";o.prepend('<ul class="woocommerce-error">'+m+"</ul>")}}else o.append('<input type="hidden" class="simplify-token" name="simplify_token" value="'+r.id+'"/>'),i.submit()}e(function(){e(document.body).on("checkout_error",function(){e(".simplify-token").remove()}),e("form.checkout").on("checkout_place_order_simplify_commerce",function(){return r()}),e("form#order_review").on("submit",function(){return r()}),e("form.checkout, form#order_review").on("change","#simplify_commerce-cc-form input",function(){e(".simplify-token").remove()})})}(jQuery);
|