#kasun_code
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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.
- kasun_error, 1 day ago, 21 messages
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
Is this for a one-time payment though? Or subscription?
Ah ok this only works for subscriptions
๐ฆ
Really the only way is to just use a smaller price
Or define price inline with amount
thats not possible...
we have products in stripe created via api
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
but how can we assign it to a specific product?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You can still pass product id
The price would just be a custom amount
All this within the price_data hash
yeah
and user can then simply use allow_promotion_code
exactly
thanks
No problem
what's your language of choice
NodeJS
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?
so setting unit amount will override the price for checkout session right?
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
cool, so it will just set the price for session
yes
yeah