Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I send user data to stripe checkout

I’m currently creating a checkout page for my users. The users click on a button on the frontend whilst logged into their account. The checkout session.

        let stripe = null
        onMounted(async () => {
            stripe = await loadStripe(import.meta.env.VITE_STRIPE_KEY)
        })
        function buyTrialLesson()
        {
            stripe.redirectToCheckout({

                successUrl: "xxxx",
                cancelUrl: "xxx",
                lineItems: [{
                    price: "price_xxxxxxxxxxxxxx",
                    quantity: 1,
                }],
                mode: "payment"
            })
        }

When the user pays on checkout the webhook I have setup reads the email address entered when paid for and then finds that user on the database and adds the credits to their account like that. However if the user enters the wrong email at checkout the funds will not be added to their account… I would rather send the account ID directly.

I’m assuming I should create the checkout on the backend and then send it over like that. But I’ve got no idea where to start and how to send that checkout session to the user… any tips are appreciated.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Many thanks.

>Solution :

You can pass metadata while creating your checkout session:

Accepted flow for your requirement:

  1. Your backend server will create stripe checkout session (creating this session will pass details like success_url, cancel_url and line_items) and this will return you one stripe session id.
  2. Your front end will receive this session is via API and pass only session id to complete the payment.

refer doc

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading