From: Eileen McNaughton Date: Thu, 14 Dec 2023 20:56:04 +0000 (+1300) Subject: Add check for mis-formatted amount X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=45fb05f1ce4ae659599fe45ef1552e90a1089063;p=civicrm-core.git Add check for mis-formatted amount --- diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index d2d3195c68..3bd2318dc7 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -205,7 +205,9 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); $propertyBag = PropertyBag::cast($params); - + if ((float) $propertyBag->getAmount() !== (float) $params['amount']) { + CRM_Core_Error::deprecatedWarning('amount should be passed through in machine-ready format'); + } // If we have a $0 amount, skip call to processor and set payment_status to Completed. // Conceivably a processor might override this - perhaps for setting up a token - but we don't // have an example of that at the mome. diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 0bb1e080bd..176649c4c8 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -2083,7 +2083,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'pay_later_receipt:::This is a pay later receipt', 'contributionPageId:::' . $contributionPageID, 'title:::Test Contribution Page', - 'amount:::100', + 'amount:::$100.00', ]); $mut->stop(); $this->revertTemplateToReservedTemplate(); diff --git a/tests/templates/message_templates/contribution_online_receipt_html.tpl b/tests/templates/message_templates/contribution_online_receipt_html.tpl index c64fc579bd..33faae6432 100644 --- a/tests/templates/message_templates/contribution_online_receipt_html.tpl +++ b/tests/templates/message_templates/contribution_online_receipt_html.tpl @@ -13,7 +13,7 @@ financialTypeName:::{$financialTypeName} contactID:::{$contactID} contributionID:::{$contributionID} - amount:::{$amount} + amount:::{contribution.total_amount} {if !empty($amount_level)} amount_level:::{$amount_level} {/if}