#nima_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/1230208254752194632
📝 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.
- nima_api, 6 days ago, 39 messages
Hi, can you reword what you're asking. I'm unsure that I understand what you're asking.
I want to get the quantity from the retrieve. So in this case it would be 20k Nok for 100 units and these 100 units would be 1 quantity.
I want to be able to retrieve the unit number for the product so I can create logic for it, such as step size of a input field.
price_1P4UL6Hc5XDVHTMyj0uWDOnr
That logic would be on your end. For instance, if you're creating a price for 20k for 1 unit, which you passed the unit amount here, https://dashboard.stripe.com/test/logs/req_JDY8A4U27rW0LA when creating the price you would need to track these on your end and charge the correct quantity when deciding to charge for it.
However, maybe you're looking for usage based pricing model? This allows you to record usage and charge accordingly at the end of the month for that usage. Can you review this, https://docs.stripe.com/products-prices/pricing-models and let me know if that is what you're looking for?
I am not looking to have monthly recurring payments. I am looking for buying products in a group of bulks.
So there is no field in the API for quantity (the amount of units)? So I would have no context of what that 20k is for, whenever that is 1 unit, or 200 units?
That 20k for 1 unit is what i need context for, whenever that one unit is compromised of for instance 200 units. And that 1 unit is what I am calling a quantity.
You can add that context on the metadata of the price, https://docs.stripe.com/api/prices/create#create_price-metadata. You can pass the 200 units data in there so you can later reference there
I'll try that then.
It just seems like a roundabout way, as it is not something that you can get information on out of the box. The dashboard knows that it is "20,000.00kr per group of 100" but the API has no access to that 100 that Stripe has access to internally.
Is there a dynamic way to set the value for the key in the stripe dashboard to that 100?
You can look at the update request https://dashboard.stripe.com/test/logs/req_ZnubMFmaPFlgn5 for the price, and the response does show:
transform_quantity: {
divide_by: "100",
round: "up",
},
It looks like you updated the price later and added this
Is that what you're looking for?
So I can run this?
const product = await stripe.products.retrieve(idProduct)
const price= await stripe.prices.retrieve(product.default_price)
const amountofUnits = price.transform_quantity.divide_by
And this would result in me getting the intended value? Would this only be the case due to me having updated the price? Would it universally still be this reference "price.transform_quantity.divide_by", even when I initially create the product the way that i updated it (by "package pricing")?
When you create the price, https://docs.stripe.com/api/prices/create#create_price-transform_quantity you can pass this and it would be on the object, yes.
Ye, that solved my question. Thanks a bunch ♥️
Happy to help!