Luigi Albanese
Luigi Albanese

Reputation: 23

square connect v2 api does not charge cents

square connect api is not charging cents. Example, if a client makes a purchase online for $17.25, my billing software shows paid for $17.25 but when I get my square report, it only collected or charged $17.00. So I'm short .25 cents.

My process-card.php file has this;

# Monetary amounts are specified in the smallest unit of the applicable currency.
# This amount is in cents. It's also hard-coded for $1.00, which isn't very useful.
    "amount_money" => array (
    "amount" => (int)$_POST['amount'] *100,
    "currency" => "CAD"

then for testing purpose, I changed the *100 to *111, figuring that it will charge the cents, but this time instead of collecting $17.25 from the invoice, square report showed, received $18.87.

any help would be great.

thank-you

Upvotes: 1

Views: 93

Answers (1)

tristansokol
tristansokol

Reputation: 4271

You are type casting your $_POST['amount']as an integer, which would remove anything after the decimal point.

Try removing the (int)

Upvotes: 1

Related Questions