payfast icon indicating copy to clipboard operation
payfast copied to clipboard

Encoding of decimal for Amount field- hashing issue

Open Disflippant opened this issue 4 years ago • 3 comments

Edit: it appears the below may be related to a culture info issue- %2C is encoding for a comma, not a decimal point. #19

I've picked up an issue re url encoding of the decimal point for the amount property resulting in an incorrect signature hash. It appears that PayFast don't want it encoded (i.e. it must be a . instead of %2C). From their sandbox after encoding ...&amount=399.1&... From the PayFastRequest after encoding ...&amount=399%2C1&...

Suggestions on working around this? Rounding to the nearest rand isn't an option :)

Disflippant avatar Jul 27 '20 11:07 Disflippant

Hi,

sorry for the delay. I will be working on this library over the next day or so and will see how issues hold up

louislewis2 avatar Aug 01 '20 16:08 louislewis2

No hassle. I did a quick fix and a pull request and that you might want to panel beat.

Disflippant avatar Aug 01 '20 21:08 Disflippant

A quick fix that works in the meantime:

Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

Added to the start of the method that redirects to Payfast. Can obviously have some unintended side-effects so use with caution.

cjnaude avatar Oct 29 '20 14:10 cjnaude