#bonnyy08
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Can you share which example code you are referring to? That button element isn't a custom Stripe element AFAIK but I want to make sure we are talking about the same thing.
<form id="payment-form" method="post" data-secret="{{ client_secret }}" style="margin:1rem 1rem;">
<div id="payment-element">
</div>
<div id="error-message">
<!-- Display error message to your customers here -->
</div>
<button id="submit">Pay</button>
</form>```
its a part of the the form
Im adding my own input fields for things such as name, and phonenumber
and id like to know if i can handle those values with the 'pay' button
Okay yeah in that example you still write the JavaScript code that handles the button click event yourself (even though we provide example code).
So it's entirely up to you
so the JavaScript that i attach to this button wont effect stripes functionality?
just for clarification
You would still need to call the Stripe function as a result. e.g. stripe.confirmPayment(). But you could add additional actions here if you wanted.
As long as the code we show here is still present that should be fine: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment
alright thank you!
Happy to help ๐
im sorry to ask again, so i want to send the values of the name input to my backend. which cant happen with the event.preventDefault() do you know if i can remove that line or if there is any way around that?
You absolutely can do this with event.preventDefault(). You would just make an additional JavaScript call to send the data to your back-end.
e.g.
const success = await fetch('/to-backend', {method: "POST", body: {name: input.value}});
This is just pseudocode though so don't take the syntax seriously
oh, alright, thank you!