PageSourceSearch

https://fishingtoendhunger.com/wp-content/plugins/charitable-pro/a…/charitable-stripe.min.js?ver=1.8.17.9

js fishingtoendhunger.com collected 2026-09-30 13:39:14 UTC 80,432 bytes, 1 lines download raw bytes

1(function($){if(typeof wpchar==="undefined"){var wpchar={debug:function(msg,type=""){if(!wpchar.isDebug()){return}if(type){type="("+type+")"}console.log("%cCharitable Debug: "+type,"color: #cd6622;",msg)},isDebug:function(){return window.location.hash&&"#charitabledebug"===window.location.hash}}}const style=document.createElement("style");style.textContent=`\n\t\t.charitable-stripe-overlay {\n\t\t\tposition: fixed;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground: rgba(255, 255, 255, 0.5);\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: center;\n\t\t\talign-items: center;\n\t\t\tz-index: 9999;\n\t\t}\n\t\t.charitable-stripe-spinner {\n\t\t\twidth: 50px;\n\t\t\theight: 50px;\n\t\t\tborder: 5px solid #f3f3f3;\n\t\t\tborder-top: 5px solid #3498db;\n\t\t\tborder-radius: 50%;\n\t\t\tanimation: spin 1s linear infinite;\n\t\t}\n\t\t@keyframes spin {\n\t\t\t0% { transform: rotate(0deg); }\n\t\t\t100% { transform: rotate(360deg); }\n\t\t}\n\t`;document.head.appendChild(style);var $body=$("body");var stripe;var stripeElementInstances={card_element:null,expressCheckoutElement:null,ach_direct_debit_payment_element:null,sepa_direct_debit_payment_element:null,becs_debit_payment_element:null,cash_app_payment_element:null,canadian_debit_payment_element:null};var get_stripe_connect_charge_owner=function(helper){var owner=helper.get_input("connect_charge_owner");return owner.length?owner.val():null};var get_stripe_connected_account=function(helper){var account=helper.get_input("connected_account");return account.length?account.val():null};var should_process_payment_on_connected_account=function(helper){return"direct"===get_stripe_connect_charge_owner(helper)||"platform"===get_stripe_connect_charge_owner(helper)&&helper.is_recurring_donation()};var get_stripe_options=function(helper,force){return"direct"===get_stripe_connect_charge_owner(helper)||force?{stripeAccount:get_stripe_connected_account(helper)}:null};var get_stripe_destination=function(helper){return"platform"===get_stripe_connect_charge_owner(helper)?get_stripe_connected_account(helper):null};var Checkout_Handler=function(){stripe=Stripe(CHARITABLE_STRIPE_VARS.key);$body.on("charitable:form:processed",function(event,response,helper){if(!response.success){return}if("make_donation"!==helper.get_input("charitable_action").val()){return}if("stripe"!==helper.get_payment_method()){return}event.preventDefault();helper.add_pending_process("stripe");var formData=helper.get_data();sessionStorage.setItem("charitable_donation_data",JSON.stringify({donation_id:response.donation_id,form_data:formData}));if(should_process_payment_on_connected_account(helper)){new_stripe=Stripe(CHARITABLE_STRIPE_VARS.key,get_stripe_options(helper,true))}else{new_stripe=stripe}new_stripe.redirectToCheckout({sessionId:response.session_id}).then(function(result){if(result.error){helper.add_error(result.error.message);helper.remove_pending_process_by_name("stripe")}})});if(window.location.search.indexOf("payment_intent=")!==-1){var urlParams=new URLSearchParams(window.location.search);var paymentIntent=urlParams.get("payment_intent");var storedData=JSON.parse(sessionStorage.getItem("charitable_donation_data")||"{}");if(paymentIntent&&storedData.donation_id){$.ajax({url:CHARITABLE_STRIPE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_express_checkout_confirmation",payment_intent:paymentIntent,donation_id:storedData.donation_id},success:function(response){if(response.success){sessionStorage.removeItem("charitable_donation_data");window.location.href=response.data.redirect_url}else{alert(response.data.message||"Payment confirmation failed")}},error:function(){alert("Error confirming payment")}})}}};function convertAmountToCents(amount,currency){var zeroDecimalCurrencies=["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"];var currentCurrency=currency||CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency.toUpperCase();var numAmount=parseFloat(amount)||0;if(zeroDecimalCurrencies.indexOf(currentCurrency)!==-1){return Math.abs(Math.round(numAmount))}var amountStr=numAmount.toString();var parts=amountStr.split(".");if(parts.length===1){return Math.abs(parseInt(parts[0])*100)}else{var wholePart=parts[0];var decimalPart=parts[1];while(decimalPart.length<2){decimalPart+="0"}decimalPart=decimalPart.substring(0,2);var cents=parseInt(wholePart)*100+parseInt(decimalPart);return Math.abs(cents)}}function Payment_Intents_Handler(helper){if(!document.getElementById("charitable_stripe_card_field")){return}var resolveVisibleField=function(id){var nodes=document.querySelectorAll("#"+id);for(var i=0;i<nodes.length;i++){if(nodes[i].offsetParent!==null){return nodes[i]}}return nodes[0]||null};stripe=Stripe(CHARITABLE_STRIPE_VARS.key);var processingFlag=false;var elements=stripe.elements();var $card=$("#charitable_stripe_card_field");var $errors=$("#charitable_stripe_card_errors");var $card_name=$(".charitable-donation-form [data-input=cc_name]");var $postcode=$(".charitable-donation-form [name=postcode]");wpchar.debug("Payment_Intents_Handler initialized","stripe");wpchar.debug(CHARITABLE_STRIPE_VARS,"stripe");$(".charitable-payment-divider").hide();amount=helper.get_amount();wpchar.debug("starting amount: "+amount,"stripe");if(amount===0){amount=$("form#charitable-donation-form").find(".charitable-your-donation-amount").find("p strong").text();wpchar.debug("starting amount2: "+amount,"stripe");if(amount===""){const firstSuggestedAmount=$('.donation-amounts.has-suggested-amounts .suggested-donation-amount input[type="radio"]').first();if(firstSuggestedAmount.length){firstSuggestedAmount.prop("checked",true);firstSuggestedAmount.trigger("click");amount=firstSuggestedAmount.val();amount=convertAmountToCents(amount)}else{const customAmountInput=$('input[name="custom_donation_amount"]');const expressCheckoutEnabled=typeof CHARITABLE_STRIPE_VARS.enable_express_checkout!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_express_checkout&&parseInt(CHARITABLE_STRIPE_VARS.enable_express_checkout)!==0;wpchar.debug(customAmountInput,"stripe");wpchar.debug(CHARITABLE_STRIPE_VARS.default_amount,"stripe");if(expressCheckoutEnabled&&customAmountInput.length&&CHARITABLE_STRIPE_VARS.default_amount){customAmountInput.val(CHARITABLE_STRIPE_VARS.default_amount);amount=convertAmountToCents(CHARITABLE_STRIPE_VARS.default_amount)}}}else{amount=amount.replace(/[^0-9.]/g,"");amount=convertAmountToCents(amount)}}else{amount=convertAmountToCents(amount)}wpchar.debug("starting amount10: "+amount,"stripe");var isValidAmount=(typeof amount==="number"||typeof amount==="string")&&!isNaN(parseFloat(amount))&&parseFloat(amount)>0;if(!isValidAmount){if(typeof CHARITABLE_STRIPE_VARS.enable_express_checkout!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_express_checkout&&parseInt(CHARITABLE_STRIPE_VARS.enable_express_checkout)!==0){wpchar.debug("Charitable Note: Payment_Intents_Handler has an invali
1d amount: "+amount,"stripe")}}if(isValidAmount){const options={mode:"payment",amount:amount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd"};var elements=stripe.elements(options)}else{var elements=stripe.elements()}cleanupStripeElements();var card_element=elements.create("card");stripeElementInstances.card_element=card_element;let expressCheckoutElement=null;var ach_direct_debit_elements=null,cash_app_elements=null,sepa_direct_debit_elements=null,becs_debit_elements=null;var ach_direct_debit_element=$("#charitable_stripe_ach_direct_debit_field"),ach_direct_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never"}}},ach_direct_debit_payment_element=false,ach_direct_debit_options={mode:"payment",amount:amount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["us_bank_account"]};if(typeof CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!==""&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!=="0"&&isValidAmount){wpchar.debug("ACH Direct Debit enabled: "+CHARITABLE_STRIPE_VARS.enable_ach_direct_debit,"stripe");wpchar.debug(ach_direct_debit_options,"stripe");setTimeout(function(){if(ach_direct_debit_element.length){wpchar.debug(ach_direct_debit_element,"stripe");wpchar.debug("ACH container before mounting:","stripe");wpchar.debug({display:ach_direct_debit_element.css("display"),visibility:ach_direct_debit_element.css("visibility"),height:ach_direct_debit_element.height(),isVisible:ach_direct_debit_element.is(":visible"),style:ach_direct_debit_element.attr("style")},"stripe");try{ach_direct_debit_elements=stripe.elements(ach_direct_debit_options);wpchar.debug("Stripe elements created successfully","stripe");ach_direct_debit_payment_element=ach_direct_debit_elements.create("payment",ach_direct_debit_payment_element_options);stripeElementInstances.ach_direct_debit_payment_element=ach_direct_debit_payment_element;wpchar.debug("ACH payment element created successfully","stripe");ach_direct_debit_payment_element.mount(resolveVisibleField("charitable_stripe_ach_direct_debit_field"));wpchar.debug("ACH Direct Debit element mounted successfully","stripe");setTimeout(function(){var $mountedElement=$("#charitable_stripe_ach_direct_debit_field");wpchar.debug("Post-mount check:","stripe");wpchar.debug({display:$mountedElement.css("display"),height:$mountedElement.height(),isVisible:$mountedElement.is(":visible"),iframeCount:$mountedElement.find("iframe").length,style:$mountedElement.attr("style")},"stripe");if($mountedElement.is(":hidden")||$mountedElement.css("display")==="none"){wpchar.debug("ACH container was hidden, making it visible","stripe");$mountedElement.show();$mountedElement[0].offsetHeight;wpchar.debug("ACH container after show:","stripe");wpchar.debug({display:$mountedElement.css("display"),height:$mountedElement.height(),isVisible:$mountedElement.is(":visible")},"stripe")}var computedStyles=window.getComputedStyle($mountedElement[0]);wpchar.debug("ACH Container CSS Analysis:","stripe");wpchar.debug({display:computedStyles.display,visibility:computedStyles.visibility,height:computedStyles.height,maxHeight:computedStyles.maxHeight,overflow:computedStyles.overflow,position:computedStyles.position,zIndex:computedStyles.zIndex},"stripe");var $parents=$mountedElement.parents();$parents.each(function(index){var $parent=$(this);var parentDisplay=$parent.css("display");var parentVisibility=$parent.css("visibility");if(parentDisplay==="none"||parentVisibility==="hidden"){wpchar.debug("Parent element hidden:","stripe");wpchar.debug({index:index,tag:this.tagName,id:this.id,class:this.className,display:parentDisplay,visibility:parentVisibility},"stripe")}})},500)}catch(error){wpchar.debug("Error in ACH mounting process: "+error,"stripe");wpchar.debug("Error details:","stripe");wpchar.debug({message:error.message,stack:error.stack,name:error.name},"stripe")}}else{wpchar.debug("ACH Direct Debit element not found in DOM","stripe");wpchar.debug("Looking for: #charitable_stripe_ach_direct_debit_field","stripe");wpchar.debug("Available elements with similar IDs:","stripe");$('[id*="ach"]').each(function(){wpchar.debug("Found element: "+$(this).attr("id"),"stripe")})}},100)}else{wpchar.debug("ACH Direct Debit not enabled or not properly configured or invalid amount","stripe");wpchar.debug("CHARITABLE_STRIPE_VARS.enable_ach_direct_debit: "+CHARITABLE_STRIPE_VARS.enable_ach_direct_debit,"stripe");wpchar.debug("isValidAmount: "+isValidAmount,"stripe");wpchar.debug("amount: "+amount,"stripe")}var sepa_direct_debit_element=$("#charitable_stripe_sepa_direct_debit_field"),sepa_direct_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never",address:{country:"never",line1:"never",line2:"never",city:"never",state:"never",postalCode:"never"}}}},sepa_direct_debit_payment_element=false,sepa_is_recurring_at_init=function(){var $rd=$('input[name="recurring_donation"]:checked');if($rd.length){var v=$rd.val();if(v&&v!==""&&v!=="once"){return true}}var $hidden=$('input[name="recurring_donation"][type="hidden"]');if($hidden.length){var hv=$hidden.val();if(hv&&hv!==""&&hv!=="once"){return true}}return false}(),sepa_direct_debit_options=sepa_is_recurring_at_init?{mode:"setup",currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"eur",paymentMethodTypes:["sepa_debit"]}:{mode:"payment",amount:amount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"eur",paymentMethodTypes:["sepa_debit"]};if(typeof CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit&&parseInt(CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit)!==0&&isValidAmount){if(sepa_direct_debit_element.length){sepa_direct_debit_elements=stripe.elements(sepa_direct_debit_options);sepa_direct_debit_payment_element=sepa_direct_debit_elements.create("payment",sepa_direct_debit_payment_element_options);stripeElementInstances.sepa_direct_debit_payment_element=sepa_direct_debit_payment_element;sepa_direct_debit_payment_element.mount(resolveVisibleField("charitable_stripe_sepa_direct_debit_field"));if(sepa_direct_debit_element.is(":hidden")){sepa_direct_debit_element.show()}}}var becs_debit_element=$("#charitable_stripe_becs_direct_debit_field"),becs_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never"}}},becs_debit_payment_element=false,becs_debit_options={mode:"payment",amount:amount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["au_becs_debit"]};if(typeof CHARITABLE_STRIPE_VARS.enable_becs_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_becs_direct_debit&&parseInt(CHARITABLE_STRIPE_VARS.enable_becs_direct_debit)!==0&&isValidAmount){if(becs_debit_element.length){becs_debit_elements=stripe.elements(becs_debit_options);becs_debit_payment_element=becs_debit_elements.create("payment",becs_debit_payment_element_options);stripeElementInstances.becs_debit_payment_element=becs_debit_payment_element;becs_debit_payment_element.mount(resolveVisibleField("charitable_stripe_becs_direct_debit_field"));if(becs_debit_element.is(":hidden")){becs_debit_element.show()}}}var cash_app_element=$("#charitable_stripe_cash_app_field"),cash_app_payment_element_options={},cash_app_payment_element=false,cash_app_options={mode:"payment",amount:amount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["cash
1app"]};if(typeof CHARITABLE_STRIPE_VARS.enable_cash_app!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_cash_app&&parseInt(CHARITABLE_STRIPE_VARS.enable_cash_app)!==0&&isValidAmount){if(cash_app_element.length){cash_app_elements=stripe.elements(cash_app_options);cash_app_payment_element=cash_app_elements.create("payment",cash_app_payment_element_options);stripeElementInstances.cash_app_payment_element=cash_app_payment_element;cash_app_payment_element.mount(resolveVisibleField("charitable_stripe_cash_app_field"));if(cash_app_element.is(":hidden")){cash_app_element.show()}}}var canadian_debit_element=$("#charitable_stripe_canadian_debit_field"),canadian_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never"}}},canadian_debit_payment_element=false,canadian_debit_elements=null,canadian_debit_options={mode:"payment",amount:amount,currency:"cad",paymentMethodTypes:["acss_debit"]};function initializeExpressCheckout(amount_in_cents,helper){if(amount_in_cents===0){$(".charitable-payment-divider").hide();$("#charitable_stripe_express_checkout_field").hide();return null}else{$(".charitable-payment-divider").show();if($("#charitable_stripe_express_checkout_field").is(":hidden")){$("#charitable_stripe_express_checkout_field").show()}}const appearance={theme:"stripe",variables:{borderRadius:"0px"}};const expressCheckoutOptions={buttonType:{applePay:"donate",googlePay:"donate",paypal:"buynow",klarna:"pay"},paymentMethods:{applePay:typeof CHARITABLE_STRIPE_VARS.enable_express_checkout!=="undefined"&&typeof CHARITABLE_STRIPE_VARS.enable_apple_pay!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_express_checkout&&CHARITABLE_STRIPE_VARS.enable_apple_pay&&CHARITABLE_STRIPE_VARS.enable_apple_pay!=="0"?"always":"never",googlePay:typeof CHARITABLE_STRIPE_VARS.enable_express_checkout!=="undefined"&&typeof CHARITABLE_STRIPE_VARS.enable_google_pay!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_express_checkout&&CHARITABLE_STRIPE_VARS.enable_google_pay&&CHARITABLE_STRIPE_VARS.enable_google_pay!=="0"?"always":"never",klarna:"auto",paypal:"auto",link:"auto",amazonPay:"auto"}};const elements=stripe.elements({locale:typeof CHARITABLE_STRIPE_VARS!=="undefined"&&CHARITABLE_STRIPE_VARS.locale?CHARITABLE_STRIPE_VARS.locale:"auto",mode:"payment",amount:amount_in_cents,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",appearance:appearance});if($("#charitable_stripe_express_checkout_field").length){let expressCheckoutElement;try{wpchar.debug("Initializing Express Checkout with options:","stripe");wpchar.debug(expressCheckoutOptions,"stripe");wpchar.debug("Amount in cents: "+amount_in_cents,"stripe");wpchar.debug("Currency: "+(CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd"),"stripe");expressCheckoutElement=elements.create("expressCheckout",expressCheckoutOptions);stripeElementInstances.expressCheckoutElement=expressCheckoutElement;wpchar.debug("Express Checkout element created successfully","stripe");expressCheckoutElement.mount(resolveVisibleField("charitable_stripe_express_checkout_field"));wpchar.debug("Express Checkout element mounted successfully","stripe");expressCheckoutElement.on("ready",function({availablePaymentMethods:availablePaymentMethods}){wpchar.debug("Express Checkout element is ready","stripe");if(!availablePaymentMethods||Object.keys(availablePaymentMethods).length===0){$("#charitable_stripe_express_checkout_field").hide();$(".charitable-payment-divider").hide()}});expressCheckoutElement.on("error",function(error){console.error("Express Checkout element error:",error);wpchar.debug("Express Checkout element error: "+JSON.stringify(error),"stripe")})}catch(error){console.error("Error creating/mounting Express Checkout element:",error);wpchar.debug("Error creating/mounting Express Checkout element: "+error.message,"stripe");wpchar.debug("Error stack: "+error.stack,"stripe");return null}const handleError=error=>{const messageContainer=document.querySelector("#charitable-form-errors");messageContainer.textContent=error.message;$("#charitable-form-errors").show()};expressCheckoutElement.on("confirm",async event=>{const{error:submitError}=await elements.submit();if(submitError){handleError(submitError);return}const overlay=document.createElement("div");
1overlay.className="charitable-stripe-overlay";overlay.innerHTML='<div class="charitable-stripe-spinner"></div>';document.body.appendChild(overlay);const formData=$(".charitable-donation-form").serializeArray().reduce(function(obj,item){if("[]"===item.name.slice(-2)){var name=item.name.slice(0,-2);if(!obj.hasOwnProperty(name)){obj[name]=[]}obj[name].push(item.value)}else{obj[item.name]=item.value}return obj},{});$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent",amount_in_cents:amount_in_cents,amount:amount_in_cents/100,nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:formData},success:async function(response){if(!response.success){console.error("response",response);console.error("Failed to create PaymentIntent:",response.data);overlay.remove();return}const{client_secret:clientSecret}=response.data;const{donation_id:donationId}=response.data;const{error:error}=await stripe.confirmPayment({elements:elements,clientSecret:clientSecret,confirmParams:{return_url:CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+donationId+"/"}});if(error){handleError(error);overlay.remove()}else{}},error:function(xhr,status,error){console.error("AJAX error:",error);overlay.remove()}})});return expressCheckoutElement}return null}if(typeof CHARITABLE_STRIPE_VARS.enable_express_checkout!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_express_checkout&&parseInt(CHARITABLE_STRIPE_VARS.enable_express_checkout)!==0){wpchar.debug("Express Checkout is enabled, checking amount: "+amount,"stripe");if(!isNaN(amount)&&amount>0){wpchar.debug("Amount is valid ("+amount+"), initializing Express Checkout","stripe");expressCheckoutElement=initializeExpressCheckout(amount,helper);stripeElementInstances.expressCheckoutElement=expressCheckoutElement}else{wpchar.debug("Amount is invalid or zero ("+amount+"), skipping Express Checkout initialization","stripe");if(expressCheckoutElement){expressCheckoutElement.unmount()}$(".charitable-payment-divider").hide()}$body.on("charitable:form:amount:changed",function(event,helper){const amount=convertAmountToCents(helper.get_amount());if(!isNaN(amount)&&amount>0){wpchar.debug("Amount changed: "+amount,"stripe");if(expressCheckoutElement){wpchar.debug("Unmounting existing Express Checkout element","stripe");expressCheckoutElement.unmount()}expressCheckoutElement=initializeExpressCheckout(amount,helper)}});$(".charitable-donation-form").on("input keyup",'input[name="custom_donation_amount"]',function(){const amount=convertAmountToCents($(this).val())||0;if(!isNaN(amount)&&amount>0){wpchar.debug("Custom amount changed: "+amount,"stripe");if(expressCheckoutElement){wpchar.debug("Unmounting existing Express Checkout element","stripe");expressCheckoutElement.unmount()}expressCheckoutElement=initializeExpressCheckout(amount,helper);stripeElementInstances.expressCheckoutElement=expressCheckoutElement}else if(expressCheckoutElement){wpchar.debug("Invalid amount, unmounting Express Checkout element","stripe");expressCheckoutElement.unmount()}})}var $targetElement=$(resolveVisibleField("charitable_stripe_card_field"));try{card_element.mount(resolveVisibleField("charitable_stripe_card_field"));if($("#charitable-form-errors").length===0){$targetElement.closest("form").prepend('<div id="charitable-form-errors" style="display:none;"></div>')}}catch(error){console.error("[STRIPE INIT DEBUG] ❌ Failed to mount card element:",error)}var setup_adaptive_styling=function(){var current_height=$card.height(),new_height=$card_name.innerHeight(),v_padding=(new_height-current_height)/2;$card.css({paddingTop:v_padding,paddingRight:$card_name.css("paddingRight"),paddingBottom:v_padding,paddingLeft:$card_name.css("paddingLeft"),border:$card_name.css("border"),borderRadius:$card_name.css("borderRadius"),background:$card_name.css("background")})}();function adjustStripeCardFieldHeight(){setTimeout(function(){var $cardField=$("#charitable_stripe_card_field");var $stripeElement=$cardField.find(".__PrivateStripeElement");var $ccNameElement=$("#charitable_field_cc_name_element");var isVisualForm=$cardField.closest(".charitable-visual-donation-form").length>0;var isModal=$cardField.closest('.charitable-modal, .lean-modal, [id*="modal"]').length>0;wpchar.debug("adjustStripeCardFieldHeight called - isModal: "+isModal+", isVisualForm: "+isVisualForm,"stripe");if(isVisualForm){wpchar.debug("Visual form detected - matching height to cc_name field","stripe");if($ccNameElement.length){var ccNameHeight=$ccNameElement.outerHeight(true);
1var ccNameOffsetHeight=$ccNameElement[0].offsetHeight;var ccNameWidth=$ccNameElement.outerWidth();var ccNameOffsetWidth=$ccNameElement[0].offsetWidth;wpchar.debug("ccNameHeight (outerHeight with margin): "+ccNameHeight,"stripe");wpchar.debug("ccNameOffsetHeight (offsetHeight): "+ccNameOffsetHeight,"stripe");wpchar.debug("ccNameWidth (outerWidth): "+ccNameWidth,"stripe");wpchar.debug("ccNameOffsetWidth (offsetWidth): "+ccNameOffsetWidth,"stripe");var targetHeight=ccNameOffsetHeight>0?ccNameOffsetHeight:ccNameHeight;var targetWidth=ccNameOffsetWidth>0?ccNameOffsetWidth:ccNameWidth;var MIN_VALID_HEIGHT=40;var MIN_VALID_WIDTH=200;if(targetHeight<MIN_VALID_HEIGHT||targetWidth<MIN_VALID_WIDTH){wpchar.debug("WARNING: Invalid dimensions detected (height: "+targetHeight+"px, width: "+targetWidth+"px). Elements may not be fully rendered yet.","stripe");var $fieldsGrid=$cardField.closest(".charitable-fields-grid");var $parentContainer=$cardField.parent();if(targetWidth<MIN_VALID_WIDTH){var parentWidth=$parentContainer.outerWidth();if(parentWidth>MIN_VALID_WIDTH){wpchar.debug("Using parent container width: "+parentWidth+"px","stripe");targetWidth=parentWidth}else if($fieldsGrid.length){var gridWidth=$fieldsGrid.outerWidth();if(gridWidth>MIN_VALID_WIDTH){wpchar.debug("Using fields grid width: "+gridWidth+"px","stripe");targetWidth=gridWidth}}}if(targetHeight<MIN_VALID_HEIGHT){wpchar.debug("Using fallback height: 42px","stripe");targetHeight=42}if(targetWidth<MIN_VALID_WIDTH){wpchar.debug("Using fallback width: 100% of parent","stripe");targetWidth=null}}if(targetWidth!==null){var $fieldsGrid=$cardField.closest(".charitable-fields-grid");if($fieldsGrid.length){var gridWidth=$fieldsGrid.outerWidth();if(gridWidth>0&&targetWidth>gridWidth){wpchar.debug("Parent .charitable-fields-grid width ("+gridWidth+"px) is smaller than cc_name width ("+targetWidth+"px), constraining to grid width","stripe");targetWidth=gridWidth}else{wpchar.debug("Parent .charitable-fields-grid width: "+gridWidth+"px, cc_name width: "+targetWidth+"px","stripe")}}}var cssProps={height:targetHeight+"px","min-height":targetHeight+"px"};if(targetWidth!==null){cssProps["width"]=targetWidth+"px";cssProps["max-width"]=targetWidth+"px"}else{cssProps["width"]="100%";cssProps["max-width"]="100%"}$cardField.css(cssProps);wpchar.debug("Set Stripe card field height to: "+targetHeight+"px","stripe");if(targetWidth!==null){wpchar.debug("Set Stripe card field width to: "+targetWidth+"px","stripe")}else{wpchar.debug("Set Stripe card field width to: 100%","stripe")}$cardField.css({"padding-top":"10px","padding-bottom":"10px","padding-left":"10px","padding-right":"10px"});if($stripeElement.length){$stripeElement.css("margin-top","0")}}else{wpchar.debug("cc_name element not found in visual form, using standard padding","stripe");$cardField.css({height:"","min-height":"42px","padding-top":"10px","padding-bottom":"10px","padding-left":"10px","padding-right":"10px"});if($stripeElement.length){$stripeElement.css("margin-top","0")}}return}if($ccNameElement.length){var ccNameHeight=$ccNameElement.outerHeight();wpchar.debug("ccNameHeight (with padding): "+ccNameHeight,"stripe");var computedStyle=window.getComputedStyle($ccNameElement[0]);var totalHeight=$ccNameElement[0].offsetHeight;wpchar.debug("totalHeight (offsetHeight): "+totalHeight,"stripe");wpchar.debug("computed padding-top: "+computedStyle.paddingTop,"stripe");wpchar.debug("computed padding-bottom: "+computedStyle.paddingBottom,"stripe");var finalHeight=totalHeight||ccNameHeight;if(isModal&&finalHeight<42){finalHeight=42;wpchar.debug("Modal context detected - setting minimum height to 42px","stripe")}$cardField.height(finalHeight);var cardFieldHeight=$cardField.height();wpchar.debug("cardFieldHeight after setting: "+cardFieldHeight,"stripe");wpchar.debug($stripeElement,"stripe");if($stripeElement.length&&cardFieldHeight>0){var stripeElementHeight=$stripeElement.height();var topPadding=Math.max(0,(cardFieldHeight-stripeElementHeight)/2);if(topPadding>cardFieldHeight*.4){topPadding=Math.max(10,cardFieldHeight*.2)}$stripeElement.css("margin-top",topPadding+"px");wpchar.debug("stripeElementHeight: "+stripeElementHeight,"stripe");wpchar.debug("topPadding: "+topPadding,"stripe");wpchar.debug("cardFieldHeight: "+cardFieldHeight,"stripe")}}else{var cardFieldHeight=$cardField.height();wpchar.debug("ccNameElement not found, using original logic","stripe");wpchar.debug("cardFieldHeight: "+cardFieldHeight,"stripe");wpchar.debug($stripeElement,"stripe");if($stripeElement.length&&cardFieldHeight>0){var topPadding=Math.max(10,Math.floor(cardFieldHeight*.3));$stripeElement.css("margin-top",topPadding+"px")}}},100)}function shouldInitializeStripe(){var $cardField=$("#charitable_stripe_card_field");var $stripeTab=$('.charitable-gateway-tab input[value="stripe"]:checked, input[name="gateway"][value="stripe"]:checked');var $stripeFields=$("#charitable-gateway-fields-stripe");wpchar.debug("Checking if Stripe should be initialized...","stripe");wpchar.debug("Stripe card field exists: "+($cardField.length>0),"stripe");wpchar.debug("Stripe card field visible: "+($cardField.length>0&&$cardField.is(":visible")),"stripe");wpchar.debug("Stripe tab checked: "+($stripeTab.length>0),"stripe");wpchar.debug("Stripe gateway fields container exists: "+($stripeFields.length>0),"stripe");wpchar.debug("Stripe gateway fields visible: "+($stripeFields.length>0&&$stripeFields.is(":visible")),"stripe");if($cardField.length>0&&$cardField.is(":visible")){wpchar.debug("Stripe card field found and visible - should initialize","stripe");return true}if($stripeTab.length>0){wpchar.debug("Stripe tab is checked - should initialize","stripe");return true}if($stripeFields.length>0&&$stripeFields.is(":visible")){wpchar.debug("Stripe gateway fields container visible (likely single gateway) - should initialize","stripe");return true}var $allGatewayTabs=$(".charitable-gateway-tab");var $visibleGatewayTabs=$(".charitable-gateway-tab:visible");if($allGatewayTabs.length===0&&$cardField.length>0){wpchar.debug("No gateway tabs found but Stripe field exists (single gateway scenario) - should initialize","stripe");return true}wpchar.debug("Stripe should NOT be initialized based on current conditions","stripe");return false}adjustStripeCardFieldHeight();setTimeout(function(){wpchar.debug("Additional check after initialization - verifying Stripe should be initialized","stripe");if(shouldInitializeStripe()){wpchar.debug("Stripe should be initialized - performing additional height adjustment","stripe");adjustStripeCardFieldHeight()}else{wpchar.debug("Stripe should NOT be initialized in additional check - skipping","stripe")}},500);$(document).on("charitable:modal:open",function(){wpchar.debug("charitable:modal:open event fired - checking Stripe initialization","stripe");setTimeout(function(){if(shouldInitializeStripe()){wpchar.debug("charitable:modal:open - Stripe should be initialized, calling adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight();setTimeout(function(){var $cardField=$("#charitable_stripe_card_field");var currentWidth=$cardField.outerWidth();var currentHeight=$cardField.outerHeight();if(currentWidth<200||currentHeight<40){wpchar.debug("charitable:modal:open - Retry: Dimensions still invalid (width: "+currentWidth+", height: "+currentHeight+"), retrying adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight()}},500)}else{wpchar.debug("charitable:modal:open - Stripe should NOT be initialized, skipping","stripe")}},600)});$(document).on("shown.bs.modal",function(){wpchar.debug("shown.bs.modal event fired - checking Stripe initialization","stripe");setTimeout(function(){if(shouldInitializeStripe()){wpchar.debug("shown.bs.modal - Stripe should be initialized, calling adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight();setTimeout(function(){var $cardField=$("#charitable_stripe_card_field");var currentWidth=$cardField.outerWidth();var currentHeight=$cardField.outerHeight();if(currentWidth<200||currentHeight<40){wpchar.debug("shown.bs.modal - Retry: Dimensions still invalid (width: "+currentWidth+", height: "+currentHeight+"), retrying adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight()}},500)}else{wpchar.debug("shown.bs.modal - Stripe should NOT be initialized, skipping","stripe")}},600)});$(document).on("charitable:modal:loaded",function(){wpchar.debug("charitable:modal:loaded event fired - checking Stripe initialization","stripe");setTimeout(function(){if(shouldInitializeStripe()){wpchar.debug("charitable:modal:loaded - Stripe should be initialized, calling adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight();setTimeout(function(){var $cardField=$("#charitable_stripe_card_field");var currentWidth=$cardField.outerWidth();var currentHeight=$cardField.outerHeight();if(currentWidth<200||currentHeight<40){wpchar.debug("charitable:modal:loaded - Retry: Dimensions still invalid (width: "+currentWidth+", height: "+currentHeight+"), retrying adjustStripeCardFieldHeight","stripe");adjustStripeCardFieldHeight()}},500)}else{wpchar.debug("charitable:modal:loaded - Stripe should NOT be initialized, skipping","stripe")}},600)});$(document).on("charitable:form:initialize",function(){wpchar.debug("Form initialized - adjusting Stripe card field height","stripe");setTimeout(adjustStripeCardFieldHeight,200)});$(document).on("charitable:form:loaded",function(){wpchar.debug("Form loaded - adjusting Stripe card field height","stripe");var $cardField=$("#charitable_stripe_card_field");var $stripeElement=$cardField.find('.__PrivateStripeElement, iframe[src*="js.stripe.com"]');if($stripeElement.length>0){setTimeout(adjustStripeCardFieldHeight,200)}else{wpchar.debug("Stripe Element not mounted yet, waiting longer for height adjustment","stripe");setTimeout(function(){$stripeElement=$cardField.find('.__PrivateStripeElement, iframe[src*="js.stripe.com"]');if($stripeElement.length>0){adjustStripeCardFieldHeight()}else{setTimeout(function(){adjustStripeCardFieldHeight()},500)}},400)}});$(document).on("charitable:stripe:adjust-height",function(){wpchar.debug("Custom height adjustment event received","stripe");adjustStripeCardFieldHeight()});$(document).on("DOMNodeInserted",".charitable-modal, .lean-modal",function(){setTimeout(function(){var $modal=$(this);if($modal.is(":visible")){wpchar.debug("Modal content inserted and visible - checking Stripe field","stripe");var $stripeTab=$modal.find('.charitable-gateway-tab input[value="stripe"]:checked, input[name="gateway"][value="stripe"]:checked');if($stripeTab.length>0){wpchar.debug("Stripe is active in newly inserted modal - adjusting height","stripe");setTimeout(adjustStripeCardFieldHeight,100)}}}.bind(this),50)});$(document).on("charitable:gateway:changed",function(event,gatewayId){if(gatewayId==="str
1ipe"){wpchar.debug("Stripe gateway selected - adjusting card field height","stripe");setTimeout(adjustStripeCardFieldHeight,200)}});setInterval(function(){var $modal=$('.charitable-modal, .lean-modal, [id*="modal"]');if($modal.length&&$modal.is(":visible")){var $cardField=$("#charitable_stripe_card_field");if($cardField.length&&$cardField.is(":visible")){var $stripeElement=$cardField.find(".__PrivateStripeElement");var $stripeTab=$('.charitable-gateway-tab input[value="stripe"]:checked, input[name="gateway"][value="stripe"]:checked');if($stripeTab.length>0&&$stripeElement.length){var currentHeight=$stripeElement.height();var currentMarginTop=parseInt($stripeElement.css("margin-top"))||0;if(currentHeight===0||currentHeight>0&&currentMarginTop===0){wpchar.debug("Detected Stripe element needing height adjustment in modal - adjusting","stripe");wpchar.debug("Current height: "+currentHeight+" Current margin-top: "+currentMarginTop,"stripe");adjustStripeCardFieldHeight()}}}}},2e3);card_element.on("change",function(event){$errors.text(event.error?event.error.message:"")});if($postcode.length){$postcode.on("change",function(event){card_element.update({value:{postalCode:event.target.value}})}).trigger("change")}wpchar.debug("loading page","stripe");var process_card=function(event,helper){event.preventDefault();if(""!==$errors.text()){if(helper.hasOwnProperty("prevent_scroll_to_top")){helper.prevent_scroll_to_top=true}helper.add_error($errors.text());helper.hide_processing();processingFlag=false;return}wpchar.debug("helper.errors: "+helper.errors,"stripe");if(helper.errors.length===0){helper.add_pending_process("stripe");wpchar.debug("adding pending process with email: "+helper.get_email(),"stripe");var email=helper.get_email(),phone=helper.get_input("phone"),address=function(){var address={},address_fields=[{field:"city",key:"city"},{field:"country",key:"country"},{field:"address",key:"line1"},{field:"address_2",key:"line2"},{field:"postcode",key:"postal_code"},{field:"state",key:"state"}];address_fields.forEach(function(field){var input=helper.get_input(field.field);if(input.length&&input.val().length){address[field.key]=input.val()}});return address}(),data={billing_details:function(){var billing={name:$card_name.val(),email:email,address:address};if(phone.length&&phone.val().length){billing.phone=phone.val()}return billing}()};wpchar.debug("creating payment method with data: "+JSON.stringify(data),"stripe");wpchar.debug(card_element,"stripe");stripe.createPaymentMethod("card",card_element,data).then(function(result){wpchar.debug(result,"stripe");if(result.error){if(helper.hasOwnProperty("prevent_scroll_to_top")){helper.prevent_scroll_to_top=true}else{wpchar.debug("adding error: "+result.error.message,"stripe");helper.add_error(result.error.message)}processingFlag=false}else{wpchar.debug("result.paymentMethod.id: "+result.paymentMethod.id,"stripe");helper.get_input("stripe_payment_method").val(result.paymentMethod.id);processingFlag=false}helper.remove_pending_process_by_name("stripe")}).catch(function(error){wpchar.debug("Stripe createPaymentMethod error: "+error.message,"stripe");helper.add_error("Payment method creation failed: "+error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false})}else{processingFlag=false}};var process_ach_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");ach_direct_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_ach_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){wpchar.debug("process_ach_direct_debit AJAX response: "+response,"stripe");if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();stripe.confirmPayment({elements:ach_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/"}}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_sepa_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");sepa_direct_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_sepa_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){wpchar.debug("process_sepa_direct_debit AJAX response: "+response,"stripe");if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();var city=helper.get_input("city").val()||"";var country=helper.get_input("country").val()||"";var line1=helper.get_input("address").val()||"";var line2=helper.get_input("address_2").val()||"";var postalCode=helper.get_input("postcode").val()||"";var state=helper.get_input("state").val()||"";var billingDetails={name:fullName,email:email,address:{city:city,country:country,line1:line1,line2:line2,postal_code:postalCode,state:state}};var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/";if(response.data.is_recurring){stripe.confirmSetup({elements:sepa_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:billingDetails},return_url:receiptUrl},redirect:"if_required"}).then(function(setupResult){if(setupResult.error){helper.add_error(setupResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_subscription_sepa_direct_debit",nonce:CHARITABLE_STRIPE_VARS.nonce,payment_method:setupResult.setupIntent.payment_method,customer_id:response.data.customer_id,donation_id:response.data.donation_id,donation_plan_id:response.data.donation_plan_id}
1,success:function(subResponse){if(!subResponse.success){helper.add_error(subResponse.data&&subResponse.data.message||"Failed to create subscription");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}window.location.href=receiptUrl},error:function(xhr,status,error){helper.add_error("Failed to create subscription: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})});return}stripe.confirmPayment({elements:sepa_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:billingDetails},return_url:receiptUrl}}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_becs_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");becs_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_becs_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){wpchar.debug("process_becs_direct_debit AJAX response: "+response,"stripe");if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();stripe.confirmPayment({elements:becs_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/"}}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_cash_app=function(event,helper){event.preventDefault();var originalPageUrl=window.location.href;if(typeof sessionStorage!=="undefined"){sessionStorage.setItem("charitable_cash_app_original_page_url",originalPageUrl)}helper.add_pending_process("stripe");cash_app_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_cash_app",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data(),original_page_url:originalPageUrl},success:function(response){wpchar.debug("process_cash_app AJAX response: "+response,"stripe");if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();var donationId=response.data.donation_id;var returnUrl=window.location.href;stripe.confirmPayment({elements:cash_app_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:returnUrl}}).then(function(result){if(result.error){helper.add_error(result.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}
1wpchar.debug("Cash App payment confirmation initiated","stripe");if(typeof sessionStorage!=="undefined"){sessionStorage.setItem("charitable_cash_app_donation_id",donationId)}}).catch(function(error){wpchar.debug("Cash App payment error: "+error.message,"stripe");helper.add_error("Payment failed: "+error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_canadian_pre_authorized_debit=function(event,helper){event.preventDefault();helper.add_error("Canadian Pre-Authorized Debit is not yet implemented.");helper.hide_processing();processingFlag=false};var process_ach_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");ach_direct_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_ach_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();stripe.confirmPayment({elements:ach_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/"}}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_becs_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");becs_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_becs_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();stripe.confirmPayment({elements:becs_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/"}}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};var process_cash_app=function(event,helper){event.preventDefault();var originalPageUrl=window.location.href;if(typeof sessionStorage!=="undefined"){sessionStorage.setItem("charitable_cash_app_original_page_url",originalPageUrl)}helper.add_pending_process("stripe");cash_app_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_cash_app",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data(),original_page_url:originalPageUrl},success:function(response){if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();var donationId=response.data.donation_id;stripe.confirmPayment({elements:cash_app_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:{name:fullName,email:email}},return_url:window.location.href}}).then(function(result){if(result.error){helper.add_error(result.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}if(typeof sessionStorage!=="undefined"){sessionStorage.setItem("charitable_cash_app_donation_id",donationId)}}).catch(function(error){helper.add_error("Payment failed: "+error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};$body.on("charitable:form:validate.stripe",function(event,helper){wpchar.debug("charitable:form:VALIDATE inside Payment_Intents_Handler","stripe");if("make_donation"!==helper.get_input("charitable_action").val()){return}if(processingFlag){wpchar.debug("Payment already being processed, skipping duplicate","stripe");return}
1wpchar.debug("helper.get_payment_method(): "+helper.get_payment_method(),"stripe");switch(helper.get_payment_method()){case"stripe_ach_direct_debit":processingFlag=true;return process_ach_direct_debit(event,helper);case"stripe_sepa_direct_debit":processingFlag=true;return process_sepa_direct_debit(event,helper);case"stripe":processingFlag=true;return process_card(event,helper);case"stripe_cash_app":processingFlag=true;return process_cash_app(event,helper);case"stripe_becs_direct_debit":processingFlag=true;return process_becs_direct_debit(event,helper);case"stripe_canadian_pre_authorized_debit":processingFlag=true;return process_canadian_pre_authorized_debit(event,helper)}});$body.on("charitable:form:processed.stripe",function(event,response,helper){if(!response.success){return}if(helper.is_recurring_donation()&&!response.requires_action){return}if("make_donation"!==helper.get_input("charitable_action").val()){return}if("stripe"!==helper.get_payment_method()){return}event.preventDefault();if(helper.errors.length===0){var new_stripe;helper.add_pending_process("stripe");if(should_process_payment_on_connected_account(helper)){new_stripe=Stripe(CHARITABLE_STRIPE_VARS.key,get_stripe_options(helper,true))}else{new_stripe=stripe}new_stripe.handleCardPayment(response.secret).then(function(result){if(result.error){$(document).trigger("Charitable_Custom_Event__Handle_Card_Payment_Fail",[event,result,response,CHARITABLE_STRIPE_VARS,helper.get_payment_method()]);helper.add_error(result.error.message)}else{if(response.redirect_to){window.location.href=response.redirect_to}}helper.remove_pending_process_by_name("stripe")})}});function handleCashAppPaymentRedirect(){var urlParams=new URLSearchParams(window.location.search);var paymentIntent=urlParams.get("payment_intent");var redirectStatus=urlParams.get("redirect_status");wpchar.debug("handleCashAppPaymentRedirect called","stripe");wpchar.debug("Current URL: "+window.location.href,"stripe");wpchar.debug("Payment Intent: "+paymentIntent,"stripe");wpchar.debug("Redirect Status: "+redirectStatus,"stripe");if(paymentIntent&&redirectStatus){wpchar.debug("Cash App payment redirect detected - Payment Intent: "+paymentIntent+", Status: "+redirectStatus,"stripe");var donationId=null;if(typeof sessionStorage!=="undefined"){donationId=sessionStorage.getItem("charitable_cash_app_donation_id");wpchar.debug("Donation ID from session: "+donationId,"stripe")}if(redirectStatus==="succeeded"){if(donationId){var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+donationId+"/";wpchar.debug("Using donation ID from session, redirecting to: "+receiptUrl,"stripe");window.location.href=receiptUrl}else{wpchar.debug("No donation ID in session, making AJAX call to get it","stripe");$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_get_donation_id_by_payment_intent",payment_intent:paymentIntent,nonce:CHARITABLE_STRIPE_VARS.nonce},success:function(response){wpchar.debug("AJAX response for donation ID lookup: "+JSON.stringify(response),"stripe");if(response.success&&response.data.donation_id){var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/";wpchar.debug("Redirecting to receipt URL: "+receiptUrl,"stripe");window.location.href=receiptUrl}else{var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/?payment_intent="+paymentIntent;wpchar.debug("AJAX failed, using fallback URL: "+receiptUrl,"stripe");window.location.href=receiptUrl}},error:function(xhr,status,error){wpchar.debug("AJAX error for donation ID lookup: "+error,"stripe");var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/?payment_intent="+paymentIntent;wpchar.debug("AJAX error, using fallback URL: "+receiptUrl,"stripe");window.location.href=receiptUrl}})}}else if(redirectStatus==="failed"){var originalPageUrl=null;if(typeof sessionStorage!=="undefined"){originalPageUrl=sessionStorage.getItem("charitable_cash_app_original_page_url")}if(originalPageUrl){var errorUrl=originalPageUrl+(originalPageUrl.includes("?")?"&":"?")+"donation_failed=cash_app";window.location.href=errorUrl}else{handleCashAppPaymentFailure(paymentIntent,donationId)}var cleanUrl=window.location.pathname;window.history.replaceState({},document.title,cleanUrl)}}}function handleCashAppPaymentFailure(paymentIntent,donationId){wpchar.debug("Handling Cash App payment failure","stripe");var errorMessage="Cash App payment was declined. Please try again or use a different payment method.";var $cashAppContainer=$("#charitable_stripe_cash_app_field");var $errorContainer=$cashAppContainer.find(".charitable-cash-app-error");
1if($errorContainer.length){$errorContainer.remove()}var $errorDiv=$('<div class="charitable-cash-app-error charitable-error">'+errorMessage+"</div>");$cashAppContainer.append($errorDiv);resetCashAppPaymentMethod();if(typeof sessionStorage!=="undefined"){sessionStorage.removeItem("charitable_cash_app_donation_id")}$("html, body").animate({scrollTop:$errorDiv.offset().top-100},500)}function resetCashAppPaymentMethod(){wpchar.debug("Resetting Cash App payment method selection","stripe");var $paymentMethodInputs=$('input[name="payment_method"]');if($paymentMethodInputs.length){$paymentMethodInputs.prop("checked",false)}if(typeof cash_app_elements!=="undefined"&&cash_app_elements){try{cash_app_elements.clear()}catch(e){wpchar.debug("Could not clear Cash App elements: "+e.message,"stripe")}}$(".charitable-processing").removeClass("charitable-processing")}function getDonationIdFromPaymentIntent(paymentIntentId){var donationForm=$("form#charitable-donation-form");if(donationForm.length){var donationIdInput=donationForm.find('input[name="donation_id"]');if(donationIdInput.length){return donationIdInput.val()}}return null}$(document).ready(function(){handleCashAppPaymentRedirect();addCashAppErrorStyling()});function addCashAppErrorStyling(){if($("#charitable-cash-app-styles").length){return}var styles=`\n\t\t\t\t<style id="charitable-cash-app-styles">\n\t\t\t\t\t.charitable-cash-app-error {\n\t\t\t\t\t\tmargin-top: 10px;\n\t\t\t\t\t\tpadding: 10px 15px;\n\t\t\t\t\t\tborder: 1px solid #dc3232;\n\t\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t\t\tbackground-color: #fff;\n\t\t\t\t\t\tcolor: #dc3232;\n\t\t\t\t\t\tfont-size: 14px;\n\t\t\t\t\t\tline-height: 1.4;\n\t\t\t\t\t}\n\n\t\t\t\t\t.charitable-cash-app-error:before {\n\t\t\t\t\t\tcontent: "⚠️ ";\n\t\t\t\t\t\tmargin-right: 5px;\n\t\t\t\t\t}\n\n\t\t\t\t\t#charitable_stripe_cash_app_field .charitable-cash-app-error {\n\t\t\t\t\t\tmargin-top: 15px;\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t`;$("head").append(styles)}}function Payment_Intents_Handler_Multiple(){var resolveVisibleField=function(id){var nodes=document.querySelectorAll("#"+id);for(var i=0;i<nodes.length;i++){if(nodes[i].offsetParent!==null){return nodes[i]}}return nodes[0]||null};var cardNumberEl=resolveVisibleField("charitable_stripe_card_number_field");if(!cardNumberEl){return}stripe=Stripe(CHARITABLE_STRIPE_VARS.key);var elements=stripe.elements();var $card=$("#charitable_stripe_card_field");var $errors=$("#charitable_stripe_card_errors");var $card_name=$(".charitable-donation-form [data-input=cc_name]");var $postcode=$(".charitable-donation-form [name=postcode]");var $card_field_name=$("#charitable_stripe_card_name_field");var $card_filed_number=$("#charitable_stripe_card_number_field");var $card_field_expiry=$("#charitable_stripe_card_expiration_field");var $card_field_cvc=$("#charitable_stripe_card_cvc_field");var cardNumber=elements.create("cardNumber");cardNumber.mount(cardNumberEl);var cardExpiry=elements.create("cardExpiry");cardExpiry.mount(resolveVisibleField("charitable_stripe_card_expiration_field"));var cardCvc=elements.create("cardCvc");cardCvc.mount(resolveVisibleField("charitable_stripe_card_cvc_field"));cardNumber.on("change",function(event){$errors.text(event.error?event.error.message:"")});cardExpiry.on("change",function(event){$errors.text(event.error?event.error.message:"")});cardCvc.on("change",function(event){$errors.text(event.error?event.error.message:"")});if($postcode.length){$postcode.on("change",function(event){cardNumber.update({value:{postalCode:event.target.value}})}).trigger("change")}var setup_adaptive_styling=function(){var current_height=$card.height(),new_height=$card_name.innerHeight(),v_padding=(new_height-current_height)/2;$card.css({paddingTop:v_padding,paddingRight:$card_name.css("paddingRight"),paddingBottom:v_padding,paddingLeft:$card_name.css("paddingLeft"),border:$card_name.css("border"),borderRadius:$card_name.css("borderRadius"),background:$card_name.css("background")})}();var processingFlag=false;var altAmount=0;var $checkedAmountInput=$('.suggested-donation-amount input[type="radio"]:checked');if($checkedAmountInput.length&&$checkedAmountInput.val()){altAmount=convertAmountToCents($checkedAmountInput.val())}if(!altAmount){var $amountText=$(".charitable-your-donation-amount p strong").text();if($amountText){altAmount=convertAmountToCents($amountText.replace(/[^0-9.]/g,""))}}var isValidAltAmount=altAmount>0;var sepa_direct_debit_elements=null,sepa_direct_debit_payment_element=false,sepa_direct_debit_element=$("#charitable_stripe_sepa_direct_debit_field"),sepa_direct_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never",address:{country:"never",line1:"never",line2:"never",city:"never",state:"never",postalCode:"never"}}}},sepa_is_recurring_at_init=function(){var $rd=$('input[name="recurring_donation"]:checked');if($rd.length){var v=$rd.val();if(v&&v!==""&&v!=="once"){return true}}var $hidden=$('input[name="recurring_donation"][type="hidden"]');if($hidden.length){var hv=$hidden.val();if(hv&&hv!==""&&hv!=="once"){return true}}return false}(),sepa_direct_debit_options=sepa_is_recurring_at_init?{mode:"setup",currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"eur",paymentMethodTypes:["sepa_debit"]}:{mode:"payment",amount:altAmount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"eur",paymentMethodTypes:["sepa_debit"]};if(typeof CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit&&parseInt(CHARITABLE_STRIPE_VARS.enable_sepa_direct_debit)!==0&&isValidAltAmount){if(sepa_direct_debit_element.length){try{
1sepa_direct_debit_elements=stripe.elements(sepa_direct_debit_options);sepa_direct_debit_payment_element=sepa_direct_debit_elements.create("payment",sepa_direct_debit_payment_element_options);stripeElementInstances.sepa_direct_debit_payment_element=sepa_direct_debit_payment_element;sepa_direct_debit_payment_element.mount(resolveVisibleField("charitable_stripe_sepa_direct_debit_field"));if(sepa_direct_debit_element.is(":hidden")){sepa_direct_debit_element.show()}wpchar.debug("SEPA Direct Debit element mounted (Multiple Fields handler)","stripe")}catch(e){wpchar.debug("SEPA init error in Multiple Fields handler: "+e.message,"stripe")}}}var ach_direct_debit_elements=null,ach_direct_debit_payment_element=false,ach_direct_debit_element=$("#charitable_stripe_ach_direct_debit_field"),ach_direct_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never"}}},ach_direct_debit_options={mode:"payment",amount:altAmount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["us_bank_account"]};if(typeof CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!==""&&CHARITABLE_STRIPE_VARS.enable_ach_direct_debit!=="0"&&isValidAltAmount){if(ach_direct_debit_element.length){try{ach_direct_debit_elements=stripe.elements(ach_direct_debit_options);ach_direct_debit_payment_element=ach_direct_debit_elements.create("payment",ach_direct_debit_payment_element_options);stripeElementInstances.ach_direct_debit_payment_element=ach_direct_debit_payment_element;ach_direct_debit_payment_element.mount(resolveVisibleField("charitable_stripe_ach_direct_debit_field"));if(ach_direct_debit_element.is(":hidden")){ach_direct_debit_element.show()}wpchar.debug("ACH Direct Debit element mounted (Multiple Fields handler)","stripe")}catch(e){wpchar.debug("ACH init error in Multiple Fields handler: "+e.message,"stripe")}}}var becs_debit_elements=null,becs_debit_payment_element=false,becs_debit_element=$("#charitable_stripe_becs_direct_debit_field"),becs_debit_payment_element_options={fields:{billingDetails:{name:"never",email:"never"}}},becs_debit_options={mode:"payment",amount:altAmount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["au_becs_debit"]};if(typeof CHARITABLE_STRIPE_VARS.enable_becs_direct_debit!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_becs_direct_debit&&parseInt(CHARITABLE_STRIPE_VARS.enable_becs_direct_debit)!==0&&isValidAltAmount){if(becs_debit_element.length){try{becs_debit_elements=stripe.elements(becs_debit_options);becs_debit_payment_element=becs_debit_elements.create("payment",becs_debit_payment_element_options);stripeElementInstances.becs_debit_payment_element=becs_debit_payment_element;becs_debit_payment_element.mount(resolveVisibleField("charitable_stripe_becs_direct_debit_field"));if(becs_debit_element.is(":hidden")){becs_debit_element.show()}wpchar.debug("BECS Direct Debit element mounted (Multiple Fields handler)","stripe")}catch(e){wpchar.debug("BECS init error in Multiple Fields handler: "+e.message,"stripe")}}}var cash_app_elements=null,cash_app_payment_element=false,cash_app_element=$("#charitable_stripe_cash_app_field"),cash_app_payment_element_options={},cash_app_options={mode:"payment",amount:altAmount,currency:CHARITABLE_STRIPE_VARS.currency&&CHARITABLE_STRIPE_VARS.currency!==""?CHARITABLE_STRIPE_VARS.currency.toLowerCase():"usd",paymentMethodTypes:["cashapp"]};if(typeof CHARITABLE_STRIPE_VARS.enable_cash_app!=="undefined"&&CHARITABLE_STRIPE_VARS.enable_cash_app&&parseInt(CHARITABLE_STRIPE_VARS.enable_cash_app)!==0&&isValidAltAmount){if(cash_app_element.length){try{cash_app_elements=stripe.elements(cash_app_options);cash_app_payment_element=cash_app_elements.create("payment",cash_app_payment_element_options);stripeElementInstances.cash_app_payment_element=cash_app_payment_element;cash_app_payment_element.mount(resolveVisibleField("charitable_stripe_cash_app_field"));if(cash_app_element.is(":hidden")){cash_app_element.show()}
1wpchar.debug("Cash App element mounted (Multiple Fields handler)","stripe")}catch(e){wpchar.debug("Cash App init error in Multiple Fields handler: "+e.message,"stripe")}}}var process_sepa_direct_debit=function(event,helper){event.preventDefault();helper.add_pending_process("stripe");sepa_direct_debit_elements.submit().then(async function(submitResult){if(submitResult.error){helper.add_error(submitResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_payment_intent_sepa_direct_debit",amount_in_cents:convertAmountToCents(helper.get_amount()),amount:helper.get_amount(),nonce:CHARITABLE_STRIPE_VARS.nonce,form_data:helper.get_data()},success:function(response){if(!response.success){helper.add_error(response.data.message||"Failed to create payment intent");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}var firstName=helper.get_input("first_name").val()||"";var lastName=helper.get_input("last_name").val()||"";var fullName=(firstName+" "+lastName).trim();var email=helper.get_email();var city=helper.get_input("city").val()||"";var country=helper.get_input("country").val()||"";var line1=helper.get_input("address").val()||"";var line2=helper.get_input("address_2").val()||"";var postalCode=helper.get_input("postcode").val()||"";var state=helper.get_input("state").val()||"";var billingDetails={name:fullName,email:email,address:{city:city,country:country,line1:line1,line2:line2,postal_code:postalCode,state:state}};var receiptUrl=CHARITABLE_STRIPE_VARS.home_url+"/"+CHARITABLE_STRIPE_VARS.donation_receipt_path+"/"+response.data.donation_id+"/";if(response.data.is_recurring){stripe.confirmSetup({elements:sepa_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:billingDetails},return_url:receiptUrl},redirect:"if_required"}).then(function(setupResult){if(setupResult.error){helper.add_error(setupResult.error.message);helper.remove_pending_process_by_name("stripe");processingFlag=false;return}$.ajax({url:CHARITABLE_VARS.ajaxurl,type:"POST",data:{action:"charitable_stripe_create_subscription_sepa_direct_debit",nonce:CHARITABLE_STRIPE_VARS.nonce,payment_method:setupResult.setupIntent.payment_method,customer_id:response.data.customer_id,donation_id:response.data.donation_id,donation_plan_id:response.data.donation_plan_id},success:function(subResponse){if(!subResponse.success){helper.add_error(subResponse.data&&subResponse.data.message||"Failed to create subscription");helper.remove_pending_process_by_name("stripe");processingFlag=false;return}window.location.href=receiptUrl},error:function(xhr,status,error){helper.add_error("Failed to create subscription: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})});return}stripe.confirmPayment({elements:sepa_direct_debit_elements,clientSecret:response.data.client_secret,confirmParams:{payment_method_data:{billing_details:billingDetails}},return_url:receiptUrl}).then(function(result){if(result.error){helper.add_error(result.error.message)}helper.remove_pending_process_by_name("stripe");processingFlag=false})},error:function(xhr,status,error){helper.add_error("Failed to process payment: "+error);helper.remove_pending_process_by_name("stripe");processingFlag=false}})})};$body.on("charitable:form:validate.stripe",function(event,helper){if("make_donation"!==helper.get_input("charitable_action").val()){return}if(processingFlag){return}switch(helper.get_payment_method()){case"stripe_sepa_direct_debit":if(sepa_direct_debit_elements){processingFlag=true;return process_sepa_direct_debit(event,helper)}helper.add_error("SEPA payment method is not available. Please refresh and try again.");return;case"stripe_ach_direct_debit":if(ach_direct_debit_elements){processingFlag=true;return process_ach_direct_debit(event,helper)}helper.add_error("ACH payment method is not available. Please refresh and try again.");return;case"stripe_becs_direct_debit":if(becs_debit_elements){processingFlag=true;return process_becs_direct_debit(event,helper)}helper.add_error("BECS payment method is not available. Please refresh and try again.");return;case"stripe_cash_app":if(cash_app_elements){processingFlag=true;return process_cash_app(event,helper)}helper.add_error("Cash App payment method is not available. Please refresh and try again.");return;case"stripe":break;default:return}if("stripe"!==helper.get_payment_method()){return}event.preventDefault();if(""!==$errors.text()){if(helper.hasOwnProperty("prevent_scroll_to_top")){helper.prevent_scroll_to_top=true}helper.add_error($errors.text());helper.hide_processing();return}if(helper.errors.length===0){helper.add_pending_process("stripe");event.preventDefault();var email=helper.get_email(),phone=helper.get_input("phone"),address={city:helper.get_input("city").val(),country:helper.get_input("country").val(),line1:helper.get_input("address").val(),line2:helper.get_input("address_2").val(),postal_code:helper.get_input("postcode").val(),state:helper.get_input("state").val()},billingDetails={name:$card_name.val(),email:email,address:address};if(phone.length&&phone.val().length){billingDetails.phone=phone.val()}stripe.createPaymentMethod({type:"card",card:cardNumber,billing_details:billingDetails}).then(function(result){if(result.error){helper.add_error(result.error.message)}else{helper.get_input("stripe_payment_method").val(result.paymentMethod.id)}helper.remove_pending_process_by_name("stripe")})}});$body.on("charitable:form:processed.stripe",function(event,response,helper){if(!response.success){return}
1if(helper.is_recurring_donation()&&!response.requires_action){return}if("make_donation"!==helper.get_input("charitable_action").val()){return}if("stripe"!==helper.get_payment_method()){return}event.preventDefault();if(helper.errors.length===0){var new_stripe;helper.add_pending_process("stripe");if(should_process_payment_on_connected_account(helper)){new_stripe=Stripe(CHARITABLE_STRIPE_VARS.key,get_stripe_options(helper,true))}else{new_stripe=stripe}var cardElementToUse;if(typeof CHARITABLE_STRIPE_VARS!=="undefined"&&typeof CHARITABLE_STRIPE_VARS.cc_fields_format!=="undefined"&&"multiple"===CHARITABLE_STRIPE_VARS.cc_fields_format){cardElementToUse=typeof cardNumber!=="undefined"?cardNumber:null}else{cardElementToUse=typeof card_element!=="undefined"?card_element:null}new_stripe.confirmCardPayment(response.secret,{payment_method:{card:cardElementToUse,billing_details:{name:$card_name.val(),email:helper.get_email(),address:{city:helper.get_input("city").val(),country:helper.get_input("country").val(),line1:helper.get_input("address").val(),line2:helper.get_input("address_2").val(),postal_code:helper.get_input("postcode").val(),state:helper.get_input("state").val()}}}}).then(function(result){if(result.error){$(document).trigger("Charitable_Custom_Event__Handle_Card_Payment_Fail",[event,result,response,CHARITABLE_STRIPE_VARS,helper.get_payment_method()]);helper.add_error(result.error.message)}else{if(response.redirect_to){window.location.href=response.redirect_to}}helper.remove_pending_process_by_name("stripe")})}})}function cleanupStripeElements(){console.log("[Stripe] Cleaning up existing Stripe Elements");if(stripeElementInstances.card_element){try{stripeElementInstances.card_element.unmount();console.log("[Stripe] Unmounted card_element")}catch(e){console.error("[Stripe] Error unmounting card_element:",e.message)}stripeElementInstances.card_element=null}if(stripeElementInstances.expressCheckoutElement){try{stripeElementInstances.expressCheckoutElement.unmount();console.log("[Stripe] Unmounted expressCheckoutElement")}catch(e){console.error("[Stripe] Error unmounting expressCheckoutElement:",e.message)}stripeElementInstances.expressCheckoutElement=null}var otherElements=["ach_direct_debit_payment_element","sepa_direct_debit_payment_element","becs_debit_payment_element","cash_app_payment_element","canadian_debit_payment_element"];otherElements.forEach(function(elementName){if(stripeElementInstances[elementName]){try{stripeElementInstances[elementName].unmount();console.log("[Stripe] Unmounted "+elementName)}catch(e){console.error("[Stripe] Error unmounting "+elementName+":",e.message)}stripeElementInstances[elementName]=null}});var $cardField=$("#charitable_stripe_card_field");if($cardField.length){$cardField.empty();console.log("[Stripe] Cleared card field DOM")}}var isReinitializing=false;function reinitializeStripeElements(helper){if(isReinitializing){console.log("[Stripe] Already reinitializing, skipping duplicate call");return}console.log("[Stripe] Reinitializing Stripe Elements after form reload");console.log("[Stripe] Helper passed to reinitializeStripeElements:",helper);var $cardField=$("#charitable_stripe_card_field");var $cardNumberField=$("#charitable_stripe_card_number_field");if(!$cardField.length&&!$cardNumberField.length){console.log("[Stripe] Stripe card field not found, skipping reinitialization");return}var $gatewayRadios=$('input[name="gateway"][type="radio"]');var $stripeSelected=$('.charitable-gateway-tab input[value="stripe"]:checked, input[name="gateway"][value="stripe"]:checked');if($gatewayRadios.length&&!$stripeSelected.length){console.log("[Stripe] Stripe is not the active payment method, skipping reinitialization");return}console.log("[Stripe] All checks passed - proceeding with reinitialization");isReinitializing=true;setTimeout(function(){console.log("[Stripe] Starting cleanup and reinitialization");$body.off("charitable:form:validate.stripe").off("charitable:form:processed.stripe");cleanupStripeElements();if("checkout"===CHARITABLE_STRIPE_VARS.mode){console.log("[Stripe] Reinitializing Checkout_Handler");CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Checkout_Handler}})}else{if(typeof CHARITABLE_STRIPE_VARS!=="undefined"&&typeof CHARITABLE_STRIPE_VARS.cc_fields_format!=="undefined"&&"multiple"===CHARITABLE_STRIPE_VARS.cc_fields_format){console.log("[
1Stripe] Reinitializing Payment_Intents_Handler_Multiple");CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Payment_Intents_Handler_Multiple}})}else{console.log("[Stripe] Reinitializing Payment_Intents_Handler with helper");CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Payment_Intents_Handler(helper)}})}}setTimeout(function(){isReinitializing=false;console.log("[Stripe] Reinitialization complete, flag reset");setTimeout(function(){console.log("[Stripe] Triggering height adjustment after reinitialization");$body.trigger("charitable:stripe:adjust-height")},300)},1e3)},100)}$body.on("charitable:form:initialize",function(event,helper){if("checkout"===CHARITABLE_STRIPE_VARS.mode){CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Checkout_Handler}})}else{if(typeof CHARITABLE_STRIPE_VARS!=="undefined"&&typeof CHARITABLE_STRIPE_VARS.cc_fields_format!=="undefined"&&"multiple"===CHARITABLE_STRIPE_VARS.cc_fields_format){CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Payment_Intents_Handler_Multiple}})}else{CharitableGatewayGuard.requireGlobal({gateway:"stripe",global:"Stripe",formSel:"#charitable-donation-form, .charitable-donation-form",run:function(){new Payment_Intents_Handler(helper)}})}}});$body.on("charitable:form:loaded",function(event,helper){if(isReinitializing){wpchar.debug("[Stripe] charitable:form:loaded - reinitialization in progress, skipping","stripe");return}if(!helper||!helper.form){wpchar.debug("charitable:form:loaded - no helper, skipping Stripe reinit","stripe");return}var $cardField=$("#charitable_stripe_card_field");var $stripeTab=$('.charitable-gateway-tab input[value="stripe"]:checked, input[name="gateway"][value="stripe"]:checked');if(!$cardField.length||!$stripeTab.length){wpchar.debug("charitable:form:loaded - no Stripe field or Stripe not selected, skipping reinit","stripe");return}var hasMountedElement=$cardField.find('.__PrivateStripeElement, iframe[src*="js.stripe.com"]').length>0;if(hasMountedElement){wpchar.debug("charitable:form:loaded - Stripe Element already mounted (initial load), skipping reinit","stripe");return}console.log("[Stripe] charitable:form:loaded - detected replaced form (empty Stripe field), reinitializing");reinitializeStripeElements(helper)});$body.on("charitable:form:replaced",function(event,helper){if(isReinitializing){wpchar.debug("[Stripe] charitable:form:replaced received but reinitialization in progress, skipping","stripe");return}if(!helper||!helper.form){wpchar.debug("[Stripe] charitable:form:replaced - no helper, skipping","stripe");return}console.log("[Stripe] charitable:form:replaced - reinitializing Stripe Elements");reinitializeStripeElements(helper)})})(jQuery);

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.