#WW-checkout

1 messages · Page 1 of 1 (latest)

pure gale
#

Hi there! Do you have a link to your page where the checkout is?

pure gale
#

Do you mind sharing a code snippet please?

azure shuttle
#
router.get("/create-checkout-session", async (req, res) => {
  const { email } = req.query;
  if (email) {
    const customer = await stripe.customers.create({
      email: email,
    });
    const session = await stripe.checkout.sessions.create({
      billing_address_collection: "auto",
      line_items: [
        {
          price: STRIPE_PRICE_CODE,
          quantity: 1,
        },
      ],
      mode: "subscription",
      customer: customer.id,
      success_url: `${process.env.REACT_APP_BACKEND_URL}main/update-checkout-details?success=true&session_id={CHECKOUT_SESSION_ID}`,
      cancel_url: `${process.env.REACT_APP_BACKEND_URL}main/update-checkout-details?canceled=true`,
    });
    return res.redirect(303, session.url);
  }
  return res.redirect(303, process.env.REACT_APP_FRONTEND_URL);
});
#

@pure gale Code^

pure gale
#

Do you have a request id or account id please?

azure shuttle
azure shuttle
azure shuttle
#
  • We don't want user to input their email manually, that's why we are not using the static URL
azure shuttle
pure gale
#

Yes, this makes sense, after the customer enters their email once in your system, you create the Stripe Customer object and use its ID to create the Checkout Session.
This will prefill their email in the Checkout Session

#

The link I shared above is an example of how the format of the Checkout link looks like

azure shuttle
#

So what we are doing is, I have create a get API (The link which I have share above): there we are creating the customer and session (code I shared above) and then redirecting customer to stripe checkout return res.redirect(303, session.url);

pure gale
#

My suspicion is this is either not returned to the client correctly, or the client is not displaying it correctly

#

Do you mind trying with res.redirect(303, session.url);

#

Without the return

azure shuttle
#

hm let me try

azure shuttle
#

@pure gale removed the return, but it's still not working

#
  • same, working on local but not on prod
#

we don't need to do any whitelisting of URLs right?

pure gale
#

I am not sure if this is the issue.

#

Do you mind writing in via https://support.stripe.com please?

#

I will find someone in my team more familiar with Checkout and node to look into this for you.

#

Thank you 🙇