#San_jen

1 messages · Page 1 of 1 (latest)

broken kernelBOT
winged rock
brazen axle
#

req_nQI2kxcPG6vnTD

#

I'll be away for an hr, I'll reply once get back if you have any questions

What I want is pass customer id somehow and tax rate along with the checkoutsession create

winged rock
#

Customer parameter only accepts string with cus_xxx format. However, your request sent an array string in the customer parameter

#

Could you share the code how you create the checkout session?

#

It's likely that you set the incorrect customer value in the code

brazen axle
#

Here's the backend code
export async function createcheckout(customerid, line_items, shiprate, sessionid) {
const stripe = require('stripe')(apiKey);
const session = await stripe.checkout.sessions.create({
cancel_url: 'https://example.com/failure',
line_items: line_items,
customer: customerid,
mode: 'payment',
automatic_tax: {
enabled: true,
},
shipping_options:[{
shipping_rate: shiprate
}],
success_url: 'https://sotansy.wixsite.com/sotansy/checkout-session-success?orderid=' +sessionid,
});

return session;

}

winged rock
#

where did you set customer?

brazen axle
#

Sorry edited that

frontend
createCustomer(customer)
.then((id) => {
console.log(id);
customerId = id;
createcheckout(customerId , stripeLineitems, stripship, item._id)

winged rock
#

Could you console log the customer ID before stripe.checkout.sessions.create()? What value did you get?