I'm trying to rewrite a certain project from Vite + React to Remix. I currently have this basic checkout flow using Stripe's custom <CardElement />, and processing the payments client-side, plus a simple Netlify function to handle some server-side logic for creating a PaymentIntent:
https://github.com/Insidiae/crwn-clothing/blob/main/src/components/PaymentForm.tsx
I'm browsing the Stripe docs for this checkout flow (https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements&html-or-react=react), but it basically has the same checkout flow I'm doing in my project:
- Send some data (containing the amount to be paid) to the Netlify function, which then creates the
PaymentIntent - Get the
PaymentIntentback from the request, use Stripe's custom hooks to get the data from the mounted<CardElement />, and then confirm the payment.
I'm thinking there's an opportunity here to move this client-side payment logic into the server, and take advantage of Remix's actions to handle creating the PaymentIntent and also confirm the payment with Stripe all in one place. Can some Stripe pros here help me out on how to move this logic into one Remix action?