#lumio_api

1 messages ยท Page 1 of 1 (latest)

forest juncoBOT
#

๐Ÿ‘‹ 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.

fresh shell
#

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?

pearl juniper
# fresh shell Hi there ๐Ÿ‘‹ can you tell me more about what you're trying to accomplish. When/ho...

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.

fresh shell
#

Address isn't available when the Checkout Session is created. It has to be shown to the customer first.

pearl juniper
#

But how do i recieve the adress then? Should i listen to the webhook when the payment has been completed or what?

fresh shell
pearl juniper
fresh shell
#

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.

pearl juniper