I already read this post and confirmed that I am sending a whole number 100
but for some reason I keep getting the error
I am receiving the charge amount from a POST
like
$charge_amount = $_POST['charge_amount'];
then in my API I am sending it as
$request_body = array (
"customer_id" => $customer->getId(),
"customer_card_id" => $card->getId(),
"amount_money" => array (
"amount" => $charge_amount,
"currency" => 'USD'
),
"idempotency_key" => uniqid(),
);
but that didn't work. So I decided to change the value statically like so
$request_body = array (
"customer_id" => $customer->getId(),
"customer_card_id" => $card->getId(),
"amount_money" => array (
"amount" => 100,
"currency" => 'USD'
),
"idempotency_key" => uniqid(),
);
and that worked.
Why is the POST
not working? I confirmed that the value of 100
is coming in through the post with echo $charge_amount
. I even tried changing to "amount" => "$charge_amount",
but that didn't work as well.
The error I am getting at the end of all this is
[HTTP/1.1 400 Bad Request] {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"EXPECTED_INTEGER","detail":"Expected an integer value.","field":"amount_money.amount"}]}