#jackisnotreal

1 messages ยท Page 1 of 1 (latest)

shell turtleBOT
spark ice
#

I think that answers my own question then, so here's a new one:

Is there an efficient way to use Stripe Checkout, and use custom prices on the fly?
My whole business is based around custom prices and invoices on-the-fly so constantly creating new prices in the dashboard would be a pain.

#

I essentially need to be able to specify a checkout session with 2 items:

  • The product cost (decided per-ticket)
  • The handling fees (10% of product cost, worked out by using Math and Float)
versed hatch
shell turtleBOT
versed hatch
spark ice
#

Oh sound, I was just about to ask. Thanks boss.

spark ice
serene birch
#

๐Ÿ‘‹ stepping in here as ynnoj needs to step away

spark ice
#

No worries, cheers.

serene birch
#

You are looking for an example on creating Prices inline?

#

Using price_data?

spark ice
#

Yes, for stripe checkout.

serene birch
#

So like: curl https://api.stripe.com/v1/checkout/sessions \ -u sk_test_123: \ --data-urlencode success_url="https://example.com/success" \ -d "line_items[0][price_data][currency]"="usd" \ -d "line_items[0][quantity]"=2 \ -d mode=payment

#

And then you would need more than just currency there

#

Imo the best thing to do is to just test this out yourself

spark ice
#
const session = await stripe.checkout.sessions.create({
        success_url: `https://pixelprojects.xyz/`,
        line_items: [
            {
                price_data: {
                    currency: 'usd',
                    product_data: {
                        name: 'Stubborn Attachments',
                    },
                    unit_amount: 2000,
                },
                quantity: 1,
            },

            
            { price_data: {
                currency: 'usd',
                product_data: {
                    name: '10% of this',
                },
                unit_amount: 200,
            },
            quantity: 1,
        },
        ]
    });```

Would this work in a node runtime?
serene birch
#

Yep that looks good at a glance

#

Think you missing mode

#

But overall you got the right idea

spark ice
#

Where would mode go? On each line item?

#

I could just be being super blind tho

#

ohhhhhhhhhhh yep i didnt scroll down enough, my bad ๐Ÿ˜…

serene birch
#

๐Ÿ™‚

spark ice
#

Okay I think I'm all set here. Cheers to the both of you for the amazing support - much better than I've had in live chat in the past ๐Ÿคฃ

#

Have a great day all!