'); var stylesheet = $(''); stylesheet.attr('href', 'https://www.unioncountycoc.com/wp-content/plugins/securesubmit/assets/checkout.css').attr('id', 'sss'); frame.contents().find('head').append(stylesheet); var frameBody = frame.contents().find('body'); var form = $('
', { id: prefix + '_form' }); frameBody.append(form); form.append(pFBojzkvbD_modal_html); function configureCleanUp() { $("#modal-launcher, #modal-background").click(function cleanUp() { content.fadeOut(400); background.toggleClass("active"); }); frameBody.find('.modal-close').click(function cleanUp() { content.fadeOut(400); background.toggleClass("active"); }); }; configureCleanUp(); $(function () { if ($.browser && $.browser.msie && $.browser.version <= 9) { frameBody.find("[placeholder]").focus(function () { if ($(this).val() == $(this).attr("placeholder")) $(this).val(""); }).blur(function () { if ($(this).val() == "") $(this).val($(this).attr("placeholder")); }).blur(); } }); function getPanel(panelName) { return frameBody.find('#pFBojzkvbD_' + panelName + '_panel'); } // Get Panels var billingPanel = getPanel('billing'); var additionalPanel = getPanel('additional'); var shippingPanel = getPanel('shipping'); var processingPanel = getPanel('processing'); var cardPanel = getPanel('card'); var successPanel = getPanel('success'); var failurePanel = getPanel('failure'); // Bind Panels // Billing Panel var billingButton = billingPanel.find('#pFBojzkvbD_billing_next_button'); billingPanel.show(); billingButton.on('click', function (event) { var continueProcessing = true; billingPanel.find('.required').each(function (i, obj) { if (continueProcessing) { if (jQuery(this).val() == '' || jQuery(this).val() == 'Select an option below') { var thisEle = jQuery(this); var elementText = thisEle.attr("placeholder"); alert('Please complete all required fields before proceeding. \n[' + elementText + '] must be entered'); continueProcessing = false; thisEle.focus(); return; } } }); if (continueProcessing) { billingPanel.hide(); if (pFBojzkvbD_requireAdditionalInfo) { additionalPanel.fadeIn(); } else if (pFBojzkvbD_requireShipping) { cardPanel.hide(); if (frameBody.find("#shipping_same").attr("checked")) { cardPanel.fadeIn(); frameBody.find("#shipping_name").val(frameBody.find("#cardholder_name").val()); frameBody.find("#shipping_address").val(frameBody.find("#cardholder_address").val()); frameBody.find("#shipping_city").val(frameBody.find("#cardholder_city").val()); frameBody.find("#shipping_state").val(frameBody.find("#cardholder_state").val()); frameBody.find("#shipping_zip").val(frameBody.find("#cardholder_zip").val()); } else { shippingPanel.fadeIn(); } } else { shippingPanel.hide(); cardPanel.fadeIn(); } } event.preventDefault(); }); // Additional Panel var additionalNext = additionalPanel.find("#pFBojzkvbD_additional_next_button"); var additionalBack = additionalPanel.find("#pFBojzkvbD_additional_back"); additionalPanel.hide(); additionalPanel.find('.securesubmitradio, .donation-dropdown').change( function () { if (this.value.indexOf("(") > 0 && this.value.indexOf(")") > 0) { var currentVal = this.value.substring(this.value.indexOf("(") + 2, this.value.indexOf(")")); frameBody.find('#donation_amount').val(currentVal); } } ); additionalNext.on("click", function (event) { var continueProcessing = true; additionalPanel.find('.required').each(function (i, obj) { if (jQuery(this).val() == '' || jQuery(this).val() == 'Select an option below') { var thisEle = jQuery(this); alert('Please complete all required fields before proceeding.'); continueProcessing = false; thisEle.focus(); return; } }); if (continueProcessing) { billingPanel.hide(); additionalPanel.hide(); if (pFBojzkvbD_requireShipping) { shippingPanel.fadeIn(); } else { cardPanel.fadeIn(); } } event.preventDefault(); }); additionalBack.on("click", function (event) { additionalPanel.hide(); billingPanel.fadeIn(); event.preventDefault(); }); // Shipping Panel var shippingNext = shippingPanel.find("#pFBojzkvbD_shipping_next_button"); var shippingBack = shippingPanel.find("#pFBojzkvbD_shipping_back"); shippingPanel.hide(); shippingNext.on("click", function (event) { var continueProcessing = true; shippingPanel.find('.required').each(function (i, obj) { if (continueProcessing) { if (jQuery(this).val() == '' || jQuery(this).val() == 'Select an option below') { var thisEle = jQuery(this); var elementText = thisEle.attr("placeholder"); alert('Please complete all required fields before proceeding. \n[' + elementText + '] must be entered'); continueProcessing = false; thisEle.focus(); return; } } }); if (continueProcessing) { billingPanel.hide(); shippingPanel.hide(); cardPanel.fadeIn(); } event.preventDefault(); }); if (pFBojzkvbD_requireShipping) { shippingBack.on("click", function (event) { billingPanel.fadeIn(); shippingPanel.hide(); cardPanel.hide(); event.preventDefault(); }); } // Processing Panel processingPanel.hide(); // Card Panel var cardPay = cardPanel.find("#pFBojzkvbD_pay_button"); var cardBack = cardPanel.find("#pFBojzkvbD_card_back"); cardPanel.hide(); function clearPaymentFields() { cardPanel.find('#card_number').val(''); cardPanel.find('#card_exp').val(''); cardPanel.find('#card_cvc').val(''); } function pFBojzkvbD_secureSubmitResponseHandler(response) { if (response.message) { processingPanel.hide(); failurePanel.show(); failurePanel.find('.transaction-error').text(response.message); configureCleanUp(); clearPaymentFields(); } else { form.find('#securesubmit_token').remove(); var token_html = ""; form.append(token_html); pFBojzkvbD_do_post(); } } function pFBojzkvbD_do_post() { var datastring = form.serialize(); var url = "https://www.unioncountycoc.com/wp-admin/admin-ajax.php"; if ($.browser && $.browser.msie && $.browser.version <= 9) { $(this).find('[placeholder]').each(function () { if ($(this).val() == $(this).attr("placeholder")) { $(this).val(""); } }); } $.post(url, datastring, function (response) { if (response.indexOf("successful") >= 0) { processingPanel.hide(); successPanel.show(); } else { processingPanel.hide(); failurePanel.show(); failurePanel.find(".transaction-error").text(response); } configureCleanUp(); clearPaymentFields(); }); } function pFBojzkvbD_tokenize() { var expirationParts = cardPanel.find('#card_exp').val().split("/"); var month = expirationParts[0]; var year = expirationParts[1]; var cardNumber = cardPanel.find('#card_number').val().replace(/\D/g, ''); // strip out non-numeric // we need the year as four-digits if (year && year.length === 2) { year = '20' + year; } hps.tokenize({ data: { public_key: '', number: cardNumber, cvc: cardPanel.find('#card_cvc').val(), exp_month: month, exp_year: year }, success: function (response) { pFBojzkvbD_secureSubmitResponseHandler(response); }, error: function (response) { pFBojzkvbD_secureSubmitResponseHandler(response); } }); } cardPay.on("click", function (event) { var continueProcessing = true; frameBody.find('.required').each(function (i, obj) { if (continueProcessing) { if (jQuery(this).val() == '' || jQuery(this).val() == 'Select an option below') { var thisEle = jQuery(this); var elementText = thisEle.attr("placeholder"); alert('Please complete all required fields before proceeding. \n[' + elementText + '] must be entered'); continueProcessing = false; thisEle.focus(); return; } } }); if (continueProcessing) { if (!frameBody.find('#donation_amount').val()) frameBody.find('#donation_amount').val(frameBody.find('#donation_amount').attr('placeholder')); frameBody.find('.donation-price').hide(); frameBody.find('.checkout-price').hide(); cardPanel.hide(); processingPanel.show(); $('#modal-launcher, #modal-background').unbind('click'); frameBody.find('.modal-close').unbind('click'); pFBojzkvbD_tokenize(); } event.preventDefault(); }); cardBack.on("click", function (event) { billingPanel.hide(); if ((pFBojzkvbD_requireShipping) && (!frameBody.find("#shipping_same").attr("checked"))) { shippingPanel.show(); } else { billingPanel.fadeIn(); } cardPanel.hide(); event.preventDefault(); }); // Success Panel successPanel.hide(); // Failure Panel var failureRetry = failurePanel.find("#pFBojzkvbD_retry_button"); failurePanel.hide(); failureRetry.on("click", function (event) { frameBody.find('.donation-price').show(); frameBody.find('.checkout-price').show(); failurePanel.hide(); cardPanel.fadeIn(); event.preventDefault(); }); }); content.append(frame); }