#kwac.
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- kwac., 2 days ago, 12 messages
- kwac., 6 days ago, 35 messages
- kwac-plugin-error, 6 days ago, 11 messages
Hello
async function handleSubmit(e) {
e.preventDefault();
const { setupIntent, error } = await stripe.confirmSetup({
elements,
confirmParams: {
return_url: "https://site.com/checkout",
},
redirect: 'if_required'
});
if(error){
if (error.type === "card_error" || error.type === "validation_error") {
showMessage(error.message);
} else {
showMessage("An unexpected error occurred.");
}
} else {
let payment_form = document.querySelector("#stripe_form_checkout")
var hiddenInput = document.createElement("input");
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'paymentMethod');
hiddenInput.setAttribute('value', setupIntent.payment_method);
payment_form.appendChild(hiddenInput);
}
}
If you log out the setupIntent after confirmSetup() resolves successfully then you will see the PaymentMethod ID
Can you give me more details about exactly what you are trying to do?
Yeah sorry I don't really understand at all what you are doing with a hidden input and what you mean by "it's not found"?
Like it is clearly created and you have the object ID
You can see that in your video
Still don't know why you are putting that in a hidden input
But that's a different question really
I followed the docs and added this. On form submit if successfully card was validated it appends payment method this part ** payment_form.appendChild(hiddenInput);**
But the problem is on form submission it as well starts processing the payment, for some reason on first submission paymentMethod is not found, (maybe because it's in validation card process) on second submit it's found, even though on first submission paymentMethod is already there(when card was validated)
Okay so that sounds like a bug in your code based on how you are talking to your backend
Really this isn't a Stripe-specific issue
My recommendation is to add logs throughout your code to see why that initial form submission is not doing what you expect
But this isn't really something I can help you with as it really is just your custom code and not something related to Stripe