#zach_api

1 messages ¡ Page 1 of 1 (latest)

worn forgeBOT
#

👋 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/1240764900301733920

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

peak burrow
#

I am actually trying to do this as a work around for a subscription change mid billing cycle on a metered billing.

#

I am basically trying to take the quantity metered so far in the billing cycle, and add it as a extra invoice item on the invoice.

#

In order to do so, i use meter event summaries to gather the quantity used thus far in the billing cycle.

#

Now since this is metered billing, the create invoice item api doesnt let me send a "recurring price", so i cannot just send the price ID

#

so my workaround right now is to go fetch the price amount and amount decimals, and then send that to the API, but it doesnt let me send both. I am suprised that I cannot send both, when they are dependent fields.

#

"You may only specify one of these parameters: unit_amount, unit_amount_decimal."
is what I get

loud grail
#

hey there, yes you cannot send both, you should send only unit_amount_decimal if you require that

#

What amount are you trying to represent?

peak burrow
#

.02

#

When I get that from my price

#

it gives unit_amount = 2

#

and unit_amount_decimal = 2

loud grail
#

If you're within the range of normal amounts, you may not need decimal at all'

peak burrow
loud grail
#

Does just using unit_amount=2 do what you expect?

peak burrow
#

this is what the stripe price gives me

loud grail
peak burrow
#

when i do a price read on price_1PEKx9Btu9lUy7zy2euvo5vB

#

which is my metered billing price

#

representing $.02

#

(2 cents)

loud grail
#

Sure, but but thats not a creation, reading back is different

peak burrow
#

it shows in stripe as unit_amount : 2 and unit_amount_decimal 2

#

so you are saying i can get 2 cents by sending 2? how does it know to do the currency shift?

loud grail
#

What currency shift? 2 is 2 cents if usd

peak burrow
#

I would of expected this to be 2 / 10^2

#

well for USD price there are only 2 decimals

#

but i am writing code to potential handle any scenario

#

so decimal amounts come into play

loud grail
#

then you would use unit_amount_decimal only

peak burrow
#

Let me give it a shot, perhaps i am misunderstanding why the read is giving me 2

#

one sec

#

OK that worked. Sorry for the question

#

I thought decimals was referring to decimal places for a shift

#

but seems it is simpler than I thought.

#

Thanks for your help and sorry for the trouble.

worn forgeBOT