Skip to content
Snippets Groups Projects
Commit 129c617e authored by Peter Hartmann's avatar Peter Hartmann
Browse files

add debug helper function

parent 1b664d15
No related branches found
No related tags found
No related merge requests found
...@@ -117,24 +117,29 @@ ...@@ -117,24 +117,29 @@
$form.submit(function (event) { $form.submit(function (event) {
// Don't handle submits generated by the CiviDiscount button. // Don't handle submits generated by the CiviDiscount button.
if ($form.data('cividiscount-dont-handle') == 1) { if ($form.data('cividiscount-dont-handle') == 1) {
debugging('pvjwy');
return true; return true;
} }
if (isWebform) { if (isWebform) {
var $processorFields = $('.civicrm-enabled[name$="civicrm_1_contribution_1_contribution_payment_processor_id]"]'); var $processorFields = $('.civicrm-enabled[name$="civicrm_1_contribution_1_contribution_payment_processor_id]"]');
if ($('#action').attr('value') == webformPrevious) { if ($('#action').attr('value') == webformPrevious) {
debugging('wmlfp');
return true; return true;
} }
if ($('#wf-crm-billing-total').length) { if ($('#wf-crm-billing-total').length) {
if ($('#wf-crm-billing-total').data('data-amount') == '0') { if ($('#wf-crm-billing-total').data('data-amount') == '0') {
debugging('qplfr');
return true; return true;
} }
} }
if ($processorFields.length) { if ($processorFields.length) {
if ($processorFields.filter(':checked').val() == '0') { if ($processorFields.filter(':checked').val() == '0') {
debugging('evxyh');
return true; return true;
} }
if (!($form.find('input[name="stripe_token"]').length)) { if (!($form.find('input[name="stripe_token"]').length)) {
debugging('irjfg');
return true; return true;
} }
} }
...@@ -150,6 +155,7 @@ ...@@ -150,6 +155,7 @@
if(typeof currentTotal !== 'undefined') { if(typeof currentTotal !== 'undefined') {
if (currentTotal == 0 && !additionalParticipants) { if (currentTotal == 0 && !additionalParticipants) {
// This is also hit when "Going back", but we already have stripe_token. // This is also hit when "Going back", but we already have stripe_token.
debugging('ozlkf');
return true; return true;
} }
} }
...@@ -161,11 +167,13 @@ ...@@ -161,11 +167,13 @@
if (($form.find('input[name="payment_processor"]:checked').length) || ($form.find('input[name="payment_processor_id"]:checked').length)) { 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()); 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)) { if (!($form.find('input[name="stripe_token"]').length) || ($('#stripe-id').length && $('#stripe-id').val() != processorId)) {
debugging('kfoej');
return true; return true;
} }
} }
else { else {
// No payment processor is checked. // No payment processor is checked.
debugging('qlmvy');
return true; return true;
} }
} }
...@@ -173,6 +181,7 @@ ...@@ -173,6 +181,7 @@
// Handle pay later (option value '0' in payment_processor radio group). // 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())) 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()))) { || ($form.find('input[name="payment_processor_id"]:checked').length && !parseInt($form.find('input[name="payment_processor_id"]:checked').val()))) {
debugging('ynhpz');
return true; return true;
} }
...@@ -180,12 +189,14 @@ ...@@ -180,12 +189,14 @@
if ($form.find("input#stripe-token").val()) { if ($form.find("input#stripe-token").val()) {
$form.find("input#credit_card_number").removeAttr('name'); $form.find("input#credit_card_number").removeAttr('name');
$form.find("input#cvv2").removeAttr('name'); $form.find("input#cvv2").removeAttr('name');
debugging('zpqef');
return true; return true;
} }
// If there's no credit card field, no use in continuing (probably wrong // If there's no credit card field, no use in continuing (probably wrong
// context anyway) // context anyway)
if (!$form.find('#credit_card_number').length) { if (!$form.find('#credit_card_number').length) {
debugging('gvzod');
return true; return true;
} }
...@@ -210,7 +221,14 @@ ...@@ -210,7 +221,14 @@
exp_year: cc_year exp_year: cc_year
}, stripeResponseHandler); }, stripeResponseHandler);
debugging('ywkvh');
return false; return false;
}); });
}); });
}(cj, CRM)); }(cj, CRM));
function debugging (errorCode) {
// Uncomment the following to debug unexpected returns.
// console.log(errorCode);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment