To show the GoCardless Direct-Debit button only for recurring subscriptions and the Stripe Card button only for one-offs, paste this code under Advanced>Code end body:
<script>
/* Show payment options based on frequency choice */
const frequencyOptions = document.forms.paymentForm.elements.frequencyOptions,
paymentOptions = document.forms.paymentForm.elements.paymentOptions,
stripeButton = [...paymentOptions].filter(el => el.value == 'stripe')[0],
gocardlessButton = [...paymentOptions].filter(el => el.value == 'gocardless')[0];
function updatePaymentOptions() {
paymentOptions.forEach(el => el.parentNode.classList.add('d-none'));
if (frequencyOptions.value == 'one-off') {
stripeButton.parentNode.classList.remove('d-none');
} else {
gocardlessButton.parentNode.classList.remove('d-none');
}
}
frequencyOptions.forEach(el => el.addEventListener('change', updatePaymentOptions));
updatePaymentOptions();
</script>
Need more help? Not to worry! Just email our support team at [email protected] 🙂