hps / heartland-php

Heartland Payment Systems Payment Gateway PHP SDK
https://developer.heartlandpaymentsystems.com/SecureSubmit/
GNU General Public License v2.0
25 stars 23 forks source link

Cannot charge 0 dollar transaction #16

Closed dgerrells closed 6 years ago

dgerrells commented 8 years ago

The check that is made for zero dollar transactions is using a '==' instead of '===' in HpsInputValidation.

Additionally, bypassing the check and sending to the gateway results in returning an invalid exception during the validation of a gateway response. I think this could also be due to a '==' not being a '==='

Reproducing this should be as simple as passing in '0' to a charge transaction.

slogsdon commented 8 years ago

Hi @dgerrells. Thanks for the report!

In the latest version of the SDK, I'm only seeing the conditional $amount < 0 || $amount == null which only ensures that the amount is not negative and is not null. Is the null check the one you are referring to? Are you using an older version of it by any chance?

At any rate, I'll make a test script to check on this and ensure the behavior is correct.

psaintjust commented 8 years ago

You need to use the === operator to check for null because (0 == null) returns true: http://www.php.net/manual/en/types.comparisons.php

slogsdon commented 6 years ago

Apologies for not circling back here. We ended up pushing an update to correct this behavior (see https://github.com/hps/heartland-php/commit/22abebcea59c2ad35d54d6b59c8ce9f476d39778#diff-88a5fe91e9f6221ea73545f4867f7b71R9)