#stilo01

1 messages · Page 1 of 1 (latest)

upbeat pilotBOT
tight pilot
#

hey

little panther
#

The amount is an integer. So $100 is represented in the API as 10000

tight pilot
#

emh

#

I inputted 200 (which is 2 euros) and it doesn't work anyways

little panther
#

Can you share more context? What does your code look like?

tight pilot
#

this is the code

app.post('/create-checkout-session', async (req, res) => {
    let pricedatainputted = +req.body.price;
    console.log(pricedatainputted); // is 2000
    const session = await stripe.checkout.sessions.create({
        line_items: [{
            price_data: {
                currency: 'eur',
                product_data: {
                    name: req.body.price + ' sugar spoons',
                },
                unit_amount: pricedatainputted,
            },
            quantity: 1,
        }],
        mode: 'payment',
        ui_mode: 'embedded',
        return_url: 'localhost:8080/checkout/return?session_id={CHECKOUT_SESSION_ID}'
    });

    res.send({clientSecret: session.client_secret});
});
little panther
#

Do you have a request ID for the Checkout Session you've created with that code?

tight pilot
tight pilot
#

the error is quite long

little panther
#

So you got an API error. You can view that in your Dashboard logs. Those logs have a Request ID. I need the request ID

tight pilot
little panther
#

Can you copy/paste the Request ID? I'd rather not have to type it out if I can help it

tight pilot
#

sure

#

req_o7Kf3rL5XMQh5B

little panther
#

Also, you many want to fix the return_url before trying to fix the amount. Having successful requests will make it much easier to debug the amount issue

#

Can you create another Checkout Session with a valid URL, then post that Request ID?

tight pilot
#

can I do localhost:8080/complete?

little panther
#

Yup, I believe so, as long as it's in test mode.

#

It needs to be the full URL though --> http://localhost:8080/complete

upbeat pilotBOT
tight pilot
#

done

#

wait

#

it works...