#aleksfr

1 messages · Page 1 of 1 (latest)

crude swallowBOT
hushed sable
#

Hello! Is this with Stripe Checkout?

pearl wraith
# hushed sable Hello! Is this with Stripe Checkout?

Not sure, im new to stripe haha.

heres an example:
User1 lists a bike on my website
User2 wants to purchase the bike

How can i make stripe work with that so i dont have to make a product for each new item listed, so User2 pays me i see User2 is trying to buy User1 bike and then do all the processes that are needed to be done

hushed sable
#

It depends on what products/APIs you're using in your integration.

pearl wraith
hushed sable
#

I mean what Stripe APIs you're using.

#

Are you creating Checkout Sessions? Payment Links? Payment Intents? Something else? The answer is different based on what you're using.

hushed sable
#

Okay, then my original answer above applies.

pearl wraith
#

im still a bit confused

hushed sable
#

Happy to answer more questions!

#

What are you confused about specifically?

pearl wraith
# hushed sable What are you confused about specifically?
import {NextApiRequest, NextApiResponse} from "next";

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
    if (req.method === 'POST') {
        try {
            // Create Checkout Sessions from body params.
            const session = await stripe.checkout.sessions.create({
                line_items: [
                    {
                        // Provide the exact Price ID (for example, pr_1234) of the product you want to sell
                        price: 'ID',
                        quantity: 1,
                    },
                ],
                mode: 'payment',
                success_url: `${req.headers.origin}/?success=true`,
                cancel_url: `${req.headers.origin}/?canceled=true`,
                automatic_tax: {enabled: true},
            });
            res.redirect(303, session.url);
            //@ts-ignore
        } catch (err: Error) {
            res.status(err.statusCode || 500).json(err.message);
        }
    } else {
        res.setHeader('Allow', 'POST');
        res.status(405).end('Method Not Allowed');
    }
}

this is my current checkout_session

but what if the user wants to pay for what a user listed on the website? the price will be diffrent each time

#

how would i be able to set it so i can just charge the user a price with my own unique identifier possibly, or is their another way?

hushed sable
#

Instead of specifying a price you would specify price_data.

#

And inside price_data you would specify the details, like the amount, for that specific thing.