#tallmanpapi
1 messages · Page 1 of 1 (latest)
what does your current code for creating a CheckoutSession look like?
Hello @quiet wind ,
Currently looks like this.
import Stripe from 'stripe';
import { NextResponse } from 'next/server';
export async function POST(request?: any) {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2022-11-15',
});
let data = await request.json();
let priceId = 'price_1N2UwFHjh6rwfnNSgLo5XwJs';
const session = await stripe.checkout.sessions.create({
line_items: [
{
price: priceId,
quantity: 1,
},
],
mode: 'payment',
success_url: 'http://localhost:3000/?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'http://localhost:3000/',
});
return NextResponse.json(session.url);
}
This is everything.
I need some variables to add in with the metadata, that's why. So it would look like this for e.g.:
companyName: company.name
companyLocation: company.location
you just add
payment_intent_data:{
metadata:{
foo:"Bar"
}
},
in the arguments to checkout.sessions.create()
thankyou!!
have a nice day
Oh its not working
I use Next.js and TypeScript
@quiet wind
yeah I had a typo and I edited it but I guess you copy pasted too fast
it's payment_intent_data not payment_method_data
oh okay haha