diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js index f29d7dd90a1118f967ac3acc9fb456a88b6d4d1a..e3897acef1d7fcbc7993b60d4533218464a33678 100644 --- a/js/civicrm_stripe.js +++ b/js/civicrm_stripe.js @@ -94,12 +94,13 @@ CRM.$(function($) { window.onbeforeunload = null; // Load Stripe onto the form. - checkAndLoad(); - - // Store and remove any onclick Action currently assigned to the form. - // We will re-add it if the transaction goes through. - //onclickAction = submitButton.getAttribute('onclick'); - //submitButton.removeAttribute('onclick'); + var cardElement = document.getElementById('card-element'); + if ((typeof cardElement !== 'undefined') && (cardElement)) { + if (!cardElement.children.length) { + debugging('checkAndLoad from document.ready'); + checkAndLoad(); + } + } // Quickform doesn't add hidden elements via standard method. On a form where payment processor may // be loaded via initial form load AND ajax (eg. backend live contribution page with payproc dropdown) @@ -113,61 +114,66 @@ CRM.$(function($) { }); // Re-prep form when we've loaded a new payproc - $( document ).ajaxComplete(function( event, xhr, settings ) { + $(document).ajaxComplete(function(event, xhr, settings) { // /civicrm/payment/form? occurs when a payproc is selected on page // /civicrm/contact/view/participant occurs when payproc is first loaded on event credit card payment // On wordpress these are urlencoded - if ((settings.url.match("civicrm(\/|%2F)payment(\/|%2F)form") != null) - || (settings.url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") != null)) { + if ((settings.url.match("civicrm(\/|%2F)payment(\/|%2F)form") != null) || + (settings.url.match("civicrm(\/|\%2F)contact(\/|\%2F)view(\/|\%2F)participant") != null)) { + // See if there is a payment processor selector on this form // (e.g. an offline credit card contribution page). - if ($('#payment_processor_id').length > 0) { + if (typeof CRM.vars.stripe === 'undefined') { + return; + } + var paymentProcessorID = getPaymentProcessorSelectorValue(); + if (paymentProcessorID !== null) { // There is. Check if the selected payment processor is different // from the one we think we should be using. - var ppid = $('#payment_processor_id').val(); - if (ppid != CRM.vars.stripe.id) { - debugging('payment processor changed to id: ' + ppid); - // It is! See if the new payment processor is also a Stripe - // Payment processor. First, find out what the stripe - // payment processor type id is (we don't want to update - // the stripe pub key with a value from another payment processor). - CRM.api3('PaymentProcessorType', 'getvalue', { - "sequential": 1, - "return": "id", - "name": "Stripe" + if (paymentProcessorID !== parseInt(CRM.vars.stripe.id)) { + debugging('payment processor changed to id: ' + paymentProcessorID); + if (paymentProcessorID === 0) { + // Don't bother executing anything below - this is a manual / paylater + return notStripe(); + } + // It is! See if the new payment processor is also a Stripe Payment processor. + // (we don't want to update the stripe pub key with a value from another payment processor). + // Now, see if the new payment processor id is a stripe payment processor. + CRM.api3('PaymentProcessor', 'getvalue', { + "return": "user_name", + "id": paymentProcessorID, + "payment_processor_type_id": CRM.vars.stripe.paymentProcessorTypeID, }).done(function(result) { - // Now, see if the new payment processor id is a stripe - // payment processor. - var stripe_pp_type_id = result['result']; - CRM.api3('PaymentProcessor', 'getvalue', { - "sequential": 1, - "return": "password", - "id": ppid, - "payment_processor_type_id": stripe_pp_type_id, - }).done(function(result) { - var pub_key = result['result']; - if (pub_key) { - // It is a stripe payment processor, so update the key. - debugging("Setting new stripe key to: " + pub_key); - CRM.vars.stripe.publishableKey = pub_key; - } - else { - debugging("New payment processor is not Stripe, setting stripe-pub-key to null"); - CRM.vars.stripe.publishableKey = null; - } - // Now reload the billing block. - checkAndLoad(); - }); + var pub_key = result.result; + if (pub_key) { + // It is a stripe payment processor, so update the key. + debugging("Setting new stripe key to: " + pub_key); + CRM.vars.stripe.publishableKey = pub_key; + } + else { + return notStripe(); + } + // Now reload the billing block. + debugging('checkAndLoad from ajaxComplete'); + checkAndLoad(); }); } } - checkAndLoad(); } }); + function notStripe() { + debugging("New payment processor is not Stripe, clearing CRM.vars.stripe"); + //CRM.vars.stripe.publishableKey = null; + delete(CRM.vars.stripe); + if ((typeof card !== 'undefined') && (card)) { + card.unmount(); + } + } + function checkAndLoad() { if (typeof CRM.vars.stripe === 'undefined') { - debugging('CRM.vars.stripe not defined!'); + debugging('CRM.vars.stripe not defined! Not a Stripe processor?'); return; } @@ -190,7 +196,11 @@ CRM.$(function($) { } function loadStripeBillingBlock() { - stripe = Stripe(CRM.vars.stripe.publishableKey); + debugging('loadStripeBillingBlock'); + + if (typeof stripe === 'undefined') { + stripe = Stripe(CRM.vars.stripe.publishableKey); + } var elements = stripe.elements(); var style = { @@ -209,7 +219,7 @@ CRM.$(function($) { updateFormElementsFromCreditCardDetails(event); }); - // Get the form containing payment details + // Get the form containing payment details form = getBillingForm(); if (typeof form.length === 'undefined' || form.length === 0) { debugging('No billing form!'); @@ -227,21 +237,33 @@ CRM.$(function($) { '[type="submit"].cancel, ' + '[type="submit"].webform-previous'), i; for (i = 0; i < nonPaymentSubmitButtons.length; ++i) { - nonPaymentSubmitButtons[i].addEventListener('click', function () { - debugging('adding submitdontprocess'); - form.dataset.submitdontprocess = true; - }); + nonPaymentSubmitButtons[i].addEventListener('click', submitDontProcess()); + } + + function submitDontProcess() { + debugging('adding submitdontprocess'); + form.dataset.submitdontprocess = true; } - submitButton.addEventListener('click', function(event) { + submitButton.addEventListener('click', submitButtonClick); + + function submitButtonClick(event) { + if (form.dataset.submitted) { + return; + } + form.dataset.submitted = true; // Take over the click function of the form. + if (typeof CRM.vars.stripe === 'undefined') { + // Submit the form + return form.submit(); + } debugging('clearing submitdontprocess'); form.dataset.submitdontprocess = false; // Run through our own submit, that executes Stripe submission if // appropriate for this submit. return submit(event); - }); + } // Remove the onclick attribute added by CiviCRM. submitButton.removeAttribute('onclick'); @@ -271,17 +293,18 @@ CRM.$(function($) { event.preventDefault(); debugging('submit handler'); + if (typeof CRM.vars.stripe === 'undefined') { + debugging('Submitting - not a stripe processor'); + return true; + } + if (form.dataset.submitted === true) { debugging('form already submitted'); return false; } - var stripeProcessorId; - var chosenProcessorId; - - if (typeof CRM.vars.stripe !== 'undefined') { - stripeProcessorId = CRM.vars.stripe.id; - } + var stripeProcessorId = CRM.vars.stripe.id; + var chosenProcessorId = null; // Handle multiple payment options and Stripe not being chosen. // @fixme this needs refactoring as some is not relevant anymore (with stripe 6.0) @@ -296,8 +319,8 @@ CRM.$(function($) { } else { // Most forms have payment_processor-section but event registration has credit_card_info-section - if ((form.querySelector(".crm-section.payment_processor-section") !== null) - || (form.querySelector(".crm-section.credit_card_info-section") !== null)) { + if ((form.querySelector(".crm-section.payment_processor-section") !== null) || + (form.querySelector(".crm-section.credit_card_info-section") !== null)) { stripeProcessorId = CRM.vars.stripe.id; if (form.querySelector('input[name="payment_processor_id"]:checked') !== null) { chosenProcessorId = form.querySelector('input[name="payment_processor_id"]:checked').value; @@ -309,9 +332,8 @@ CRM.$(function($) { // - Is the selected processor ID pay later (0) // - Is the Stripe processor ID defined? // - Is selected processor ID and stripe ID undefined? If we only have stripe ID, then there is only one (stripe) processor on the page - if ((chosenProcessorId === 0) - || (stripeProcessorId == null) - || ((chosenProcessorId == null) && (stripeProcessorId == null))) { + if ((chosenProcessorId === 0) || (stripeProcessorId == null) || + ((chosenProcessorId == null) && (stripeProcessorId == null))) { debugging('Not a Stripe transaction, or pay-later'); return true; } @@ -384,7 +406,7 @@ CRM.$(function($) { function getBillingForm() { // If we have a stripe billing form on the page var billingFormID = $('div#card-element').closest('form').prop('id'); - if (!billingFormID.length) { + if ((typeof billingFormID === 'undefined') || (!billingFormID.length)) { // If we have multiple payment processors to select and stripe is not currently loaded billingFormID = $('input[name=hidden_processor]').closest('form').prop('id'); } @@ -467,4 +489,22 @@ CRM.$(function($) { form.appendChild(hiddenInput); } + /** + * Get the selected payment processor on the form + * @returns int + */ + function getPaymentProcessorSelectorValue() { + if ((typeof form === 'undefined') || (!form)) { + form = getBillingForm(); + if (!form) { + return null; + } + } + var paymentProcessorSelected = form.querySelector('input[name="payment_processor_id"]:checked'); + if (paymentProcessorSelected !== null) { + return parseInt(paymentProcessorSelected.value); + } + return null; + } + }); diff --git a/js/civicrm_stripe.min.js b/js/civicrm_stripe.min.js index daab8881a2c057f1deecc39ab2f58e17f2db8937..23d70781cbc5f610c0b3e758417765b4a69a4cf3 100644 --- a/js/civicrm_stripe.min.js +++ b/js/civicrm_stripe.min.js @@ -1 +1 @@ -CRM.$(function(d){var n;var b;var c;var a;var m=false;function s(y){f("paymentIntent confirmation success");var x=document.createElement("input");x.setAttribute("type","hidden");x.setAttribute("name","paymentIntentID");x.setAttribute("value",y.id);c.appendChild(x);c.submit()}function g(x){f("error: "+x.error.message);var y=document.getElementById("card-errors");y.style.display="block";y.textContent=x.error.message;document.querySelector("#billing-payment-block").scrollIntoView();window.scrollBy(0,-50);a.removeAttribute("disabled")}function v(){f("handle card payment");n.createPaymentMethod("card",b).then(function(x){if(x.error){g(x)}else{var y=CRM.url("civicrm/stripe/confirm-payment");d.post(y,{payment_method_id:x.paymentMethod.id,amount:o(),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id}).then(function(z){t(z)})}})}function t(x){f("handleServerResponse");if(x.error){g(x)}else{if(x.requires_action){p(x)}else{s(x.paymentIntent)}}}function p(x){n.handleCardAction(x.payment_intent_client_secret).then(function(y){if(y.error){g(y)}else{s(y.paymentIntent)}})}var l=null;d(document).ready(function(){window.onbeforeunload=null;j();d("select#payment_processor_id").on("change",function(){d("input.payproc-metadata").remove()})});d(document).ajaxComplete(function(y,A,x){if((x.url.match("civicrm(/|%2F)payment(/|%2F)form")!=null)||(x.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!=null)){if(d("#payment_processor_id").length>0){var z=d("#payment_processor_id").val();if(z!=CRM.vars.stripe.id){f("payment processor changed to id: "+z);CRM.api3("PaymentProcessorType","getvalue",{sequential:1,"return":"id",name:"Stripe"}).done(function(B){var C=B.result;CRM.api3("PaymentProcessor","getvalue",{sequential:1,"return":"password",id:z,payment_processor_type_id:C}).done(function(D){var E=D.result;if(E){f("Setting new stripe key to: "+E);CRM.vars.stripe.publishableKey=E}else{f("New payment processor is not Stripe, setting stripe-pub-key to null");CRM.vars.stripe.publishableKey=null}j()})})}}j()}});function j(){if(typeof CRM.vars.stripe==="undefined"){f("CRM.vars.stripe not defined!");return}if(typeof Stripe==="undefined"){if(m){return}m=true;f("Stripe.js is not loaded!");d.getScript("https://js.stripe.com/v3",function(){f("Script loaded and executed.");m=false;e()})}else{e()}}function e(){n=Stripe(CRM.vars.stripe.publishableKey);var B=n.elements();var z={base:{fontSize:"20px"}};b=B.create("card",{style:z});b.mount("#card-element");document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true);b.addEventListener("change",function(C){r(C)});c=h();if(typeof c.length==="undefined"||c.length===0){f("No billing form!");return}a=w();c.dataset.submitdontprocess=false;var x=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),y;for(y=0;y<x.length;++y){x[y].addEventListener("click",function(){f("adding submitdontprocess");c.dataset.submitdontprocess=true})}a.addEventListener("click",function(C){f("clearing submitdontprocess");c.dataset.submitdontprocess=false;return A(C)});a.removeAttribute("onclick");k();if(u()){d("[type=submit]").click(function(){q(this.value)});c.addEventListener("keydown",function(C){if(C.keyCode===13){q(this.value);A(event)}});d("#billingcheckbox:input").hide();d('label[for="billingcheckbox"]').hide()}function A(E){E.preventDefault();f("submit handler");if(c.dataset.submitted===true){f("form already submitted");return false}var G;var D;if(typeof CRM.vars.stripe!=="undefined"){G=CRM.vars.stripe.id}if(u()){G=CRM.vars.stripe.id;if(!d('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){D=G}else{D=c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').val()}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){G=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){D=c.querySelector('input[name="payment_processor_id"]:checked').value}}}if((D===0)||(G==null)||((D==null)&&(G==null))){f("Not a Stripe transaction, or pay-later");return true}else{f("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){f("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){f("non-payment submit detected - not submitting payment");return true}if(u()){if(d("#billing-payment-block").is(":hidden")){f("no payment processor on webform");return true}var F=d('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(F.length){if(F.filter(":checked").val()==="0"||F.filter(":checked").val()===0){f("no payment processor selected");return true}}}var C=o();if(C=="0"){f("Total amount is 0");return true}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}a.setAttribute("disabled",true);v();return true}}function u(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function h(){var x=d("div#card-element").closest("form").prop("id");if(!x.length){x=d("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(x)}function w(){var x=null;if(u()){x=c.querySelector('[type="submit"].webform-submit');if(!x){x=c.querySelector('[type="submit"].webform-button--submit')}}else{x=c.querySelector('[type="submit"].validate')}return x}function o(){var x=null;if(typeof calculateTotalFee=="function"){x=calculateTotalFee()}else{if(u()){d(".line-item:visible","#wf-crm-billing-items").each(function(){x+=parseFloat(d(this).data("amount"))})}}return x}function r(x){if(!x.complete){return}document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value=x.value.postalCode}function k(){cividiscountElements=c.querySelectorAll("input#discountcode");for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",function(x){if(x.keyCode===13){x.preventDefault();f("adding submitdontprocess");c.dataset.submitdontprocess=true}})}}function f(x){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+x)}}function q(y){var x=null;if(document.getElementById("action")!==null){x=document.getElementById("action")}else{x=document.createElement("input")}x.setAttribute("type","hidden");x.setAttribute("name","op");x.setAttribute("id","action");x.setAttribute("value",y);c.appendChild(x)}}); \ No newline at end of file +CRM.$(function(d){var p;var b;var c;var a;var o=false;function u(A){f("paymentIntent confirmation success");var z=document.createElement("input");z.setAttribute("type","hidden");z.setAttribute("name","paymentIntentID");z.setAttribute("value",A.id);c.appendChild(z);c.submit()}function g(z){f("error: "+z.error.message);var A=document.getElementById("card-errors");A.style.display="block";A.textContent=z.error.message;document.querySelector("#billing-payment-block").scrollIntoView();window.scrollBy(0,-50);a.removeAttribute("disabled")}function x(){f("handle card payment");p.createPaymentMethod("card",b).then(function(z){if(z.error){g(z)}else{var A=CRM.url("civicrm/stripe/confirm-payment");d.post(A,{payment_method_id:z.paymentMethod.id,amount:q(),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id}).then(function(B){v(B)})}})}function v(z){f("handleServerResponse");if(z.error){g(z)}else{if(z.requires_action){r(z)}else{u(z.paymentIntent)}}}function r(z){p.handleCardAction(z.payment_intent_client_secret).then(function(A){if(A.error){g(A)}else{u(A.paymentIntent)}})}var n=null;d(document).ready(function(){window.onbeforeunload=null;var z=document.getElementById("card-element");if((typeof z!=="undefined")&&(z)){if(!z.children.length){f("checkAndLoad from document.ready");l()}}d("select#payment_processor_id").on("change",function(){d("input.payproc-metadata").remove()})});d(document).ajaxComplete(function(B,C,A){if((A.url.match("civicrm(/|%2F)payment(/|%2F)form")!=null)||(A.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!=null)){if(typeof CRM.vars.stripe==="undefined"){return}var z=j();if(z!==null){if(z!==parseInt(CRM.vars.stripe.id)){f("payment processor changed to id: "+z);if(z===0){return k()}CRM.api3("PaymentProcessor","getvalue",{"return":"user_name",id:z,payment_processor_type_id:CRM.vars.stripe.paymentProcessorTypeID}).done(function(D){var E=D.result;if(E){f("Setting new stripe key to: "+E);CRM.vars.stripe.publishableKey=E}else{return k()}f("checkAndLoad from ajaxComplete");l()})}}}});function k(){f("New payment processor is not Stripe, clearing CRM.vars.stripe");delete (CRM.vars.stripe);if((typeof b!=="undefined")&&(b)){b.unmount()}}function l(){if(typeof CRM.vars.stripe==="undefined"){f("CRM.vars.stripe not defined! Not a Stripe processor?");return}if(typeof Stripe==="undefined"){if(o){return}o=true;f("Stripe.js is not loaded!");d.getScript("https://js.stripe.com/v3",function(){f("Script loaded and executed.");o=false;e()})}else{e()}}function e(){f("loadStripeBillingBlock");if(typeof p==="undefined"){p=Stripe(CRM.vars.stripe.publishableKey)}var F=p.elements();var C={base:{fontSize:"20px"}};b=F.create("card",{style:C});b.mount("#card-element");document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true);b.addEventListener("change",function(G){t(G)});c=h();if(typeof c.length==="undefined"||c.length===0){f("No billing form!");return}a=y();c.dataset.submitdontprocess=false;var z=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),B;for(B=0;B<z.length;++B){z[B].addEventListener("click",E())}function E(){f("adding submitdontprocess");c.dataset.submitdontprocess=true}a.addEventListener("click",A);function A(G){if(c.dataset.submitted){return}c.dataset.submitted=true;if(typeof CRM.vars.stripe==="undefined"){return c.submit()}f("clearing submitdontprocess");c.dataset.submitdontprocess=false;return D(G)}a.removeAttribute("onclick");m();if(w()){d("[type=submit]").click(function(){s(this.value)});c.addEventListener("keydown",function(G){if(G.keyCode===13){s(this.value);D(event)}});d("#billingcheckbox:input").hide();d('label[for="billingcheckbox"]').hide()}function D(I){I.preventDefault();f("submit handler");if(typeof CRM.vars.stripe==="undefined"){f("Submitting - not a stripe processor");return true}if(c.dataset.submitted===true){f("form already submitted");return false}var K=CRM.vars.stripe.id;var H=null;if(w()){K=CRM.vars.stripe.id;if(!d('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){H=K}else{H=c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').val()}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){K=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){H=c.querySelector('input[name="payment_processor_id"]:checked').value}}}if((H===0)||(K==null)||((H==null)&&(K==null))){f("Not a Stripe transaction, or pay-later");return true}else{f("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){f("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){f("non-payment submit detected - not submitting payment");return true}if(w()){if(d("#billing-payment-block").is(":hidden")){f("no payment processor on webform");return true}var J=d('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(J.length){if(J.filter(":checked").val()==="0"||J.filter(":checked").val()===0){f("no payment processor selected");return true}}}var G=q();if(G=="0"){f("Total amount is 0");return true}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}a.setAttribute("disabled",true);x();return true}}function w(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function h(){var z=d("div#card-element").closest("form").prop("id");if((typeof z==="undefined")||(!z.length)){z=d("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(z)}function y(){var z=null;if(w()){z=c.querySelector('[type="submit"].webform-submit');if(!z){z=c.querySelector('[type="submit"].webform-button--submit')}}else{z=c.querySelector('[type="submit"].validate')}return z}function q(){var z=null;if(typeof calculateTotalFee=="function"){z=calculateTotalFee()}else{if(w()){d(".line-item:visible","#wf-crm-billing-items").each(function(){z+=parseFloat(d(this).data("amount"))})}}return z}function t(z){if(!z.complete){return}document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value=z.value.postalCode}function m(){cividiscountElements=c.querySelectorAll("input#discountcode");for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",function(z){if(z.keyCode===13){z.preventDefault();f("adding submitdontprocess");c.dataset.submitdontprocess=true}})}}function f(z){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+z)}}function s(A){var z=null;if(document.getElementById("action")!==null){z=document.getElementById("action")}else{z=document.createElement("input")}z.setAttribute("type","hidden");z.setAttribute("name","op");z.setAttribute("id","action");z.setAttribute("value",A);c.appendChild(z)}function j(){if((typeof c==="undefined")||(!c)){c=h();if(!c){return null}}var z=c.querySelector('input[name="payment_processor_id"]:checked');if(z!==null){return parseInt(z.value)}return null}}); \ No newline at end of file