#sintonz-rounding

1 messages ยท Page 1 of 1 (latest)

bleak swan
#

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))

grand trench
#

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?

bleak swan
#

From what you have described it sounds like you want a float

grand trench
#

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?

bleak swan
#

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?

grand trench
#

yes

#

your print statement worked

bleak swan
grand trench
#

but idk if it is what it should be with the types

bleak swan
#

That is your choice! Those values will be in cents and you can handle them however makes sense to you

grand trench
#

which values are in cents?

bleak swan
#

Both. unit_amount is integer cents unit_amount_decimals is also cents but it can have decimal places for sub-cent prices

grand trench
#

i am confused why stripe has both of them and not just 1

bleak swan
#

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?

grand trench
#

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

bleak swan
#

Can you clarify that first part? What do you need to get here?

grand trench
#

a price id of a certain amount

#

because you can have tons of price ids with different amounts

bleak swan
#

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?

grand trench
#

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

patent plinth
#

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?

grand trench
#

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 ๐Ÿ™‚

patent plinth
#

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.