Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to hide the credit card number, expiration date and CVV2 when a donor chooses PayPal from the list of credit card types. Notice that using PayPal is *only* available on Salsa if you have chose Payflow Pro as your merchant gateway and Express Checkout is enabled.
<script type="text/javascript">
(function() {
// Script to hide the credit card information when a donor chooses PayPal. Shows it again
// if the donor chooses another payment type. Works on donations, events and storefronts.
// @see https://help.salsalabs.com/hc/en-us/articles/115000082413
document.addEventListener('DOMContentLoaded', function() {
var e = document.querySelector('#cc_type');
if (e != null) {
e.addEventListener('change', ccTypeChangeHandler);
ccTypeChangeHandler();
}
});
function ccTypeChangeHandler(event) {
var e = document.querySelector('#cc_type');
var display = e.value == 'paypal' ? 'none' : 'block';
"cc_number ccExpYear ccExpMonth CVV2".split(' ').forEach(function(x) {
var e = document.getElementById(x);
if (e != null) {
e.value = '';
p = e.parentNode;
if (/select/.test(e.type)) { p = p.parentNode; }
p.style.display = display;
}
});
};
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.