What I found out for now is that something is wrong with this code:
var form = document.getElementById('subscription-form');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const { setupIntent, error } = await stripe.handleCardSetup(
clientSecret, cardElement, {
payment_method_data: {
billing_details: { name: cardHolderName.value }
}
}
);
if (error) {
// Display "error.message" to the user...
console.log('test');
console.log(error);
} else {
// The card has been verified successfully...
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'payment_method');
hiddenInput.setAttribute('value', setupIntent.payment_method);
form.appendChild(hiddenInput);
// Submit the form
form.submit();
}
The big problem is the hidden input gets not added through js to the form. When I add the hidden input manually everything works fine. The code is from the docs so it normally should work. Maybe someone could please help.
best