From 129c617e60462da96dcbb14b04878cdc22c1b246 Mon Sep 17 00:00:00 2001 From: Peter Hartmann <peter@hartmanncomputer.com> Date: Wed, 8 Mar 2017 13:00:52 -0500 Subject: [PATCH] add debug helper function --- js/civicrm_stripe.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/civicrm_stripe.js b/js/civicrm_stripe.js index de71370a..d7185161 100644 --- a/js/civicrm_stripe.js +++ b/js/civicrm_stripe.js @@ -117,24 +117,29 @@ $form.submit(function (event) { // Don't handle submits generated by the CiviDiscount button. if ($form.data('cividiscount-dont-handle') == 1) { + debugging('pvjwy'); return true; } if (isWebform) { var $processorFields = $('.civicrm-enabled[name$="civicrm_1_contribution_1_contribution_payment_processor_id]"]'); if ($('#action').attr('value') == webformPrevious) { + debugging('wmlfp'); return true; } if ($('#wf-crm-billing-total').length) { if ($('#wf-crm-billing-total').data('data-amount') == '0') { + debugging('qplfr'); return true; } } if ($processorFields.length) { if ($processorFields.filter(':checked').val() == '0') { + debugging('evxyh'); return true; } if (!($form.find('input[name="stripe_token"]').length)) { + debugging('irjfg'); return true; } } @@ -150,6 +155,7 @@ if(typeof currentTotal !== 'undefined') { if (currentTotal == 0 && !additionalParticipants) { // This is also hit when "Going back", but we already have stripe_token. + debugging('ozlkf'); return true; } } @@ -161,11 +167,13 @@ if (($form.find('input[name="payment_processor"]:checked').length) || ($form.find('input[name="payment_processor_id"]:checked').length)) { processorId = $form.find(('input[name="payment_processor"]:checked')||('input[name="payment_processor_id"]:checked').val()); if (!($form.find('input[name="stripe_token"]').length) || ($('#stripe-id').length && $('#stripe-id').val() != processorId)) { + debugging('kfoej'); return true; } } else { // No payment processor is checked. + debugging('qlmvy'); return true; } } @@ -173,6 +181,7 @@ // Handle pay later (option value '0' in payment_processor radio group). if (($form.find('input[name="payment_processor"]:checked').length && !parseInt($form.find('input[name="payment_processor"]:checked').val())) || ($form.find('input[name="payment_processor_id"]:checked').length && !parseInt($form.find('input[name="payment_processor_id"]:checked').val()))) { + debugging('ynhpz'); return true; } @@ -180,12 +189,14 @@ if ($form.find("input#stripe-token").val()) { $form.find("input#credit_card_number").removeAttr('name'); $form.find("input#cvv2").removeAttr('name'); + debugging('zpqef'); return true; } // If there's no credit card field, no use in continuing (probably wrong // context anyway) if (!$form.find('#credit_card_number').length) { + debugging('gvzod'); return true; } @@ -210,7 +221,14 @@ exp_year: cc_year }, stripeResponseHandler); + debugging('ywkvh'); return false; }); }); }(cj, CRM)); + +function debugging (errorCode) { +// Uncomment the following to debug unexpected returns. +// console.log(errorCode); +} + -- GitLab