#lumio_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1441093214001168585
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there ๐ can you tell me more about what you're trying to accomplish. When/how are you trying to pull information from the Checkout Session, what problems are you running into so far?
So this is my code rn:
import { redirect } from "next/navigation";
import { NextRequest, NextResponse } from "next/server";
import { env } from "process";
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || '')
export async function POST(req: NextRequest) {
try {
const body = await req.json();
const { title, price } = body; // from client
const session = await stripe.checkout.sessions.create({
billing_address_collection: "required",
shipping_address_collection: {
allowed_countries: ["DE"]
},
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'eur',
product_data: {
name: title,
},
unit_amount: price * 100, // Stripe expects cents
},
quantity: 1,
},
],
mode: 'payment',
success_url: `${env.APP}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${env.APP}/cancel`,
});
return NextResponse.json({redi_url: session.url || "/error", address: )
} catch (err) {
console.error(err);
return NextResponse.json({ error: 'Stripe session creation failed' }, { status: 500 });
}
}
But the Problem is i cant seem to find the address.
Address isn't available when the Checkout Session is created. It has to be shown to the customer first.
ohhhh.
But how do i recieve the adress then? Should i listen to the webhook when the payment has been completed or what?
Depends on the type of payment methods you plan to accept and when you want to trigger fulfillment, but yup that's one approach.
https://docs.stripe.com/checkout/fulfillment
I only do one-time payments. I have a kind of marketplace thingy
It's moreso around the payment method types you want to accept, since some of those can be delayed-notification style payment methods, where you don't immediately know if the payment was successful. But we talk about all of that in that checkout fulfillment guide.
I will check that out. Thank you!