adixon / ca.civicrm.iats

[deprecated] CiviCRM Extension for IATS Web Services Payment Processor
3 stars 0 forks source link

In 4.3.4 and lower there is an issue with contributions over $1,000.00. #2

Closed lolaslade closed 10 years ago

lolaslade commented 10 years ago

In versions of CiviCRM at 4.3.4 and lower we found that CiviCRM passes the $params['amount'] to IATS with a comma even though it does not allow you to enter one on the contribution page. The value iATS receives is "1,000.00" which it submits to the payment processor. This gets recorded as $1.00. This appears to be related to the formatting of the amount on the confirmation page. It is fixed in 4.4.2 so I am reporting it here rather than in core since they will probably not support older versions. You may want to submit a fix to the long term support version.

Here is a possible workaround on line 194 of ca.civicrm.iats/CRM/Core/Payment/iATSService.php:

$request['total'] = sprintf('%01.2f', str_replace(',', '', $params['amount']));

or alternately:

$params['amount'] = CRM_Utils_Rule::cleanMoney($params['amount'])
$request['total'] = sprintf('%01.2f', $params['amount']);

The same issue applies to the older iATS in core. In that case the issue is on line 127 of CRM/Core/Payment/IATS.php.

jdkoelsch commented 10 years ago

We also ran into the issue, and fixed it using code similar to the second alternative that lolas-freeform provided. Other similar issues in civi core have been addressed using CRM_Utils_Rule::cleanMoney (like http://issues.civicrm.org/jira/browse/CRM-10974), so it seemed like the best way to fix the issue in the IATS extension.

adixon commented 10 years ago

Perfect, the clean money version is implemented.