#sintonz-rounding
1 messages ยท Page 1 of 1 (latest)
That is determined by your python code, not our API. You'll need to use a python format string for that. I think for you it will look something like:
print('{0:.2f}'.format(x.unit_amount / 100))
ah that worked thank you
i don't need to make the types float? x.unit_amount is an int
Do I need to use x.unit_amount_decimal?
From what you have described it sounds like you want a float
So what would it be then? Do I need a float on both the x.unit_amount and a float of 100 or 100.0?
I am not 100% familiar with how python does it but I think just unit_amount will do
Have you tried running this with that?
Awesome! Stole it from this StackOverflow https://stackoverflow.com/questions/1995615/how-can-i-format-a-decimal-to-always-show-2-decimal-places
but idk if it is what it should be with the types
That is your choice! Those values will be in cents and you can handle them however makes sense to you
which values are in cents?
Both. unit_amount is integer cents unit_amount_decimals is also cents but it can have decimal places for sub-cent prices
i am confused why stripe has both of them and not just 1
So a dollar would be unit_amount: 100 or unit_amount_decimals: 100.0
Some pricing schemes find it useful to have sub-cent prices. Most don't
Are you creating these prices yourself?
yes what i want to do is i need to get the price id and the amount so i could create a subscription
i don't want to store the price id in my db
Can you clarify that first part? What do you need to get here?
a price id of a certain amount
because you can have tons of price ids with different amounts
Why do you not want to store the price IDs on your side?
Are you currently trying to look up price ID by amount or something?
because my database is screwed up now since i have btcpayserver payments
i first configured my site to be stripe CC payments only
It looks like I need to do something like this
So the less data I could put in my db the better
It is not good practice to have a ton of NULLs like if I pay with crypto but not with stripe there will be a NULL price id in the db
And yes I am trying to get a price id of a certain interval based on a product id where the price id is the same amount as my pricing page
Maybe I could store the price id as an environment variable
Hello again ๐ I'm getting caught up on this thread, and am not certain what you're currently asking. Would you mind rephrasing your ask?
I think I am ok now all I really needed to know about was the decimal thing and I thought of a way to maybe use an environment variable for the price id. Unless you want to help me design/structure my db tables ๐
Glad to hear you found an approach. Haha, I wish I could help with the DB but that's outside of my wheelhouse and my advice probably wouldn't be great.