0

I'm trying to set up a success url for stripe payments that displays the customers name however I am getting the following error:

Error: Stripe: Argument "customer" must be a string, but got: [object Object] (on API request to GET /v1/customers/{customer})

My code looks like this:

app.get('/order/success', async (req, res) => {
    try{
        const session = await stripe.checkout.sessions.retrieve(req.query.session_id);
        const customer = await stripe.customers.retrieve(session);
        res.send(`<html><body><h1>Thanks for your order,${customer.name} !</h1></body></html>`);
    }catch(e){
        console.log(e);
        res.send(`Error`);
    }
  })

And my success url is set to:

success_url: "http://localhost:8080/order/success?session_id={CHECKOUT_SESSION_ID}",

Any help would be greatly appreciated as I am completely stuck

I was expecting to be redirected to the success url but instead recieve an error

  • This means you passed an object where a string was needed, and the function converted it to a string to use it. You probably needed to pass a property of the object rather than the whole object. – Barmar Apr 26 '23 at 14:41

0 Answers0