#Marcin

1 messages · Page 1 of 1 (latest)

modern parcelBOT
fallen owl
#

Where are you getting a 403?

#

What's the error message?

left pulsar
#

I've got a form with action to api with POST method

#

now I'm getting different error

fallen owl
#

That's not a stripe error

#

We can help debug issues with the stripe api, but this is an issue with your server or configuration

left pulsar
#

I'm using next.js 13 with the app structure and new API routes, do you have any examples how it should be implemented with prebulid checkout?

#

but also I've added a custom domain

#

not on my localhost

fallen owl
#

Oh you see the cloudfront error when going to the checkout session? Can you paste the checkout session id in here?

#

The one that starts with cs_test_

left pulsar
#

cs_test_a1gjFCbaHQjH07rpNWLH5VtYol0GH50iqbu4M8JBsskSiCviv62VBysHHL#fid1d2BpamRhQ2prcSc%2FJ0twa2xxaicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaMDRLTnRAV0I1fX1zYFFCTn0waURSVEk0XFd9cks3UkYwTnNzN1A0Q2hBcmN2NjF3an9ybm9GN1VCTW9MbGRjVmtxYEtXXF9dRFwwQjBkbXxISkZ8MDNpS1Q1NU53NDxoam50JyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl

#

Request ID: 8FSZCiYYuXEW0qVBJwkU1vJ2Y4Vte3YO1UqPA4hbfIVooQ72EZrCpw==

fallen owl
#

Odd

#

I can load the url just fine

#

Are you using a vpn or proxy or anything like that?

left pulsar
#

when I paste the url it works fine but it should redirect from my api call

#
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
    typescript: true,
    apiVersion: "2022-11-15",
});

export async function POST(req: NextRequest) {
    console.log(req.body)
    try {
        const session = await stripe.checkout.sessions.create({
            line_items: [
                {
                    price: 'price_1NLPN0G0xxveTGKxC1uKQCPp',
                    quantity: 1
                }
            ],
            mode: 'subscription',
            success_url: 'http://localhost:3000/?success',
            cancel_url: 'http://localhost:3000/?cancelled'
        })
        return NextResponse.redirect(session.url)
        // return NextResponse.json({ url: session.url });
        // return new NextResponse(session.payment_link, { status: 200 });
    } catch (error: any) {
        return new NextResponse(error, {
            status: 400,
        });
    }
}```
#

return NextResponse.redirect(session.url) i'm getting the session url correctly

#

but its not redirecting properly

fallen owl
#

Oh I see

#

Try redirecting client side not server side

#

So return the url at that endpoint

#

And then in your javascript do the redirect to the returned url