Hi!
When the amount is sent to Ogone it contains 2 decimals.
Ogone fails to process and gives the following error:
amount too long or not numeric: length 6 MAX:15
E.g. for 100 euro: 100,00 is sent, but it should be 10000
Problem is located in the redirectData function where amount is rounded.
function redirectData(Payment $payment) {
....
$data = array(
'AMOUNT' => currency_load($payment->currency_code)->roundAmount($payment->totalAmount(TRUE)),
'PSPID' => $payment->method->controller_data['pspid'],
...
}
In the development version before issue 1955396 the amount was multiplied by 100.
The following change should also work for currencies with more than 2 decimals!
...
$currency = currency_load($payment->currency_code);
$data = array(
'AMOUNT' => $currency->roundAmount($payment->totalAmount(TRUE)) / $currency->getRoundingStep(),
...
Hope this helps! :)
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 8145887-10-adding_scale_to_bcmul.patch | 800 bytes | Anonymous (not verified) |
| #5 | ogone_2064443_5.patch | 856 bytes | xano |
| #3 | 2064443-2-currencies-sent-to-ogone-have-decimals.patch | 844 bytes | askibinski |
| #1 | 2064443-1-currencies-sent-to-ogone-have-decimals.patch | 902 bytes | askibinski |
Comments
Comment #1
askibinski commentedHere is a patch with above code.
I stumbled upon this myself today. Kinda major because ogone does not accept any payments now otherwise.
Comment #3
askibinski commentedThis one should work.
Comment #4
askibinski commentedstatus change...
Comment #5
xanoThis is a float division. Seeing as we use Currency anyway, we might as well use BC Math for this too. Also, the rounding step is configurable and as such cannot be used to 'move the comma'.
The patch uses the calculated number of decimals to find out how much to 'move the comma' and uses BC Math to perform the actual calculation.
Comment #6
xanoBump. Can someone review the patch?
Comment #7
Anonymous (not verified) commentedDid the job for me
Comment #8
xanoThanks for your help!
Comment #10
Anonymous (not verified) commentedhmm, apparently i'havent tested thoroughly, i've still got the decimals.. scaling the bcmul should do the job
Comment #11
Anonymous (not verified) commentedComment #12
xanoThis is not a fix to the original problem. Provided the currency is configured correctly,
$currency->roundAmount()should make sure there are not too many decimals, and thebcmul()withpow()should simply move the comma.Can you make sure the number of subunits is correctly set for the currency you are using and can you paste the expected and actual values here?
Comment #13
xanoBump.
Comment #14
xanoBump.
Comment #15
xanoClosing due to lack of response. If this problem persists, please open a new issue.