#kasun_code

1 messages ยท Page 1 of 1 (latest)

kindred saddleBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

fast coyoteBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

merry drum
#

So yeah you'll only be able to have a single discount. If you want to allow the customer to enter a promo code and also have your own discount on top of that you'll need to do this through negative amount invoice items to credit them

ebon bramble
#

ohh how we can do that

#

?

#

can we apply it to a checkout session

merry drum
#

Is this for a one-time payment though? Or subscription?

ebon bramble
#

one time checkout session

#

for subscriptions we dont do this

merry drum
#

Ah ok this only works for subscriptions

ebon bramble
#

๐Ÿ˜ฆ

merry drum
#

Really the only way is to just use a smaller price

#

Or define price inline with amount

ebon bramble
#

we have products in stripe created via api

merry drum
ebon bramble
#

and usually people buy them

#

problem is, we sell courses

#

and we sell course bundles

#

when an user buys a course bundle, we wanna give them a discount based on the other courses they purchased

merry drum
#

Yeah really the only way to do this is to pass the amount in instead of a price id

#

That way you can just calculate how much they should pay and pass in that amount

ebon bramble
#

but how can we assign it to a specific product?

merry drum
#

You can still pass product id

#

The price would just be a custom amount

#

All this within the price_data hash

ebon bramble
#

oh nice

#

that would do

#

so we calc new price and set it as custom

merry drum
#

yeah

ebon bramble
#

and user can then simply use allow_promotion_code

merry drum
#

exactly

ebon bramble
#

thanks

merry drum
#

No problem

ebon bramble
#

can you show me a sample request?

#

like this

merry drum
#

what's your language of choice

ebon bramble
#

NodeJS

merry drum
#

Something like this:

  success_url: 'https://example.com/success',
  line_items: [
    {
      price_data: {
        product: 'prod_123',
        unit_amount: 2000,
      },
      quantity: 2,
    },
  ],
  mode: 'payment',
});```
#

Make sense?

ebon bramble
#

so setting unit amount will override the price for checkout session right?

merry drum
#

It doesn't override anything. It is the price

#

sorry product id should be prod_123

#

edited the snippet

#

You pass product id for the product (products can have multiple prices, so that doesn't set price)

#

You set the price by passing unit_amount

ebon bramble
#

cool, so it will just set the price for session

merry drum
#

yes

ebon bramble
#

without changing the product

#

right?

merry drum
#

yeah

ebon bramble
#

thanks ๐Ÿ™‚

#

that works

merry drum
#

No problem

#

You'll also need to specify currency within price_data. Forgot to include that in snippet

ebon bramble
#

got it

#

thanks