#DeadlyData - Invalid Integer
1 messages · Page 1 of 1 (latest)
Hello! Can you provide the request ID showing that error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Also, can you share the code that leads to that error? Specifically the code that's calculating that value?
req_CEZ77YORRMTEVd
This is the information being sent over from Android to my server
usd
request body {
currency: 'usd',
items: [ { amount: '2566.70', id: 'photo_subscription' } ]
}
currency usd
2566.70
I think amount should be an integer given in cents in case of usd
That amount is not valid, you need to pass an integer, not a float/decimal/etc. See here: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount
ah i see okay
Correct. You should add logic on your server to validate a positive integer is being provided.
If you're getting an amount in dollars you should multiply it by 100 to get the amount in cents.
so for return it should be something like items[0].amount*100?
Yes, plus the validation logic.
So i did that wrote logic test if a positive integer is provided and i* the dollars by 100
but i am still gettting an error
req_3U9nOjmnQokZlL
Says invalid integer still
Hi, I'm stepping in here to further assist. Let me get caught up here.
Hello, oaky
okay*
this is how my server code looks
This is the data being sent over
StripeInvalidRequestError: Invalid integer: 256669.99999999997
req_3U9nOjmnQokZlL
{
amount: "256669.99999999997",
currency: "usd"
}
shows to have been passed to us
So we are receiving amount: 256669.99999999997 on our end for that request. From looking at one of your other requests, we are seeing it working as expected: req_IpLcuJn69p6F4J.
So why's it coming as an error here?
On that amount, can you try 256670? We charge the smallest currency unit.
https://stripe.com/docs/api/payment_intents/create#create_payment_intent-amount
Hello again! To clarify, any number with a decimal will not work, as such a number is not an integer. You need to add code to convert decimals into integers (the exact method depends on your business needs) and then send those integers to the Stripe API.
okay i see, so it would be best to convert the double to a decimal then send it to stripe? i tried without a decimal and it was sucessful.
For example, if the amount you start with is $23.456 you would first multiply it by 100 to get the amount in cents: 2345.6, then you need to figure out how you want to handle the fraction of a cent. You can round up or round down, but at the end you should end up with an integer that is either 2345 or 2346 with no decimal.