I'm using Stripe Elements in my frontend (React) to take payment information and everything. Currently, I have a function handleSubmit
on the frontend that directly runs await stripe.confirmPayment({ elements, ... })
, where const elements = useElements();
and const stripe = useStripe();
. A backend server (Express) handles the publishable key and creating the payment intent and sends back the pk and client secret when the intent is created. However, I would like to move all my payment logic to the server to avoid any potential data fabrication client-side.
First of all, is this a good idea? And was confirming payments on the frontend a bad idea in the first place
Second, how will I actually send the user's payment data to the server? Is it safe to just do it through post requests, and does Stripe provide a way to do it (e.g. can I just send the client secret back to the server for the payment intent to be processed)?
Apologies if this is a dumb question. This is my first time dealing with payments and seriously worrying about security, I guess.