Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Created January 26, 2017 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/34308325e0320c120488e30c3df7e466 to your computer and use it in GitHub Desktop.
Save salsalabs/34308325e0320c120488e30c3df7e466 to your computer and use it in GitHub Desktop.
Solution for changing a donation page so that it accepts cash or checks only -- no credit cards. Note that the payment type is stored in donation,Batch_Code and the check number is stored in donation.Notes.
<script type="text/javascript">
// Solution for changing a donation page so that it accepts cash or checks only -- no credit cards.
// Note that the payment type is stored in donation,Batch_Code and the check number is stored in
// donation.Notes.
document.addEventListener('DOMContentLoaded', function() {
document.querySelector('#credit_card_information').style.display = 'none';
document.querySelector('#cc_number').value = '1111111111111111';
document.querySelector('#ccExpMonth').value = '12';
document.querySelector('#ccExpYear').value = '27';
document.querySelector('#CVV2').value = '1111';
document.querySelector('#one_time').click();
document.querySelector('#recurring').parentNode.style.display = 'none';
document.querySelector('#one_time').parentNode.style.display = 'none';
document.querySelector('#form-of-payment-cash').addEventListener('click', formOfPaymentListener);
document.querySelector('#form-of-payment-check').addEventListener('click', formOfPaymentListener);
function formOfPaymentListener(event) {
var cashPayment = document.querySelector('#form-of-payment-cash');
var checkPayment = document.querySelector('#form-of-payment-check');
var checkNumberRow = document.querySelector('#check-number-row');
if (cashPayment.checked) {
cashPayment.value = cashPayment.getAttribute('x-value');
checkPayment.value = '';
checkNumberRow.style.display = 'none';
} else {
checkPayment.value = checkPayment.getAttribute('x-value');
cashPayment.value = '';
checkNumberRow.style.display = 'block';
}
}
formOfPaymentListener();
});
</script>
<fieldset id="form-of-payment">
<legend>Form of Payment?</legend>
<div class="formRow">
<input id="form-of-payment-cash" type="radio" name="Batch_Code" x-value="Cash" value="Cash" checked/>
<label for="form-of-payment-cash">Cash</label>
</div>
<div class="formRow">
<input id="form-of-payment-check" type="radio" name="Batch_Code" X-value="Check" value="" />
<label for="form-of-payment-check">Check</label>
<div style="display: none;" id="check-number-row" class="formRow">
<label for="form-of-payment-check-number">Check Number</label>
<input id="form-of-payment-check-number" type="text" maxlength="5" name="Notes" />
</div>
</div>
</fieldset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment