Add check for mis-formatted amount
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 14 Dec 2023 20:56:04 +0000 (09:56 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 14 Dec 2023 22:06:30 +0000 (11:06 +1300)
CRM/Core/Payment/Dummy.php
tests/phpunit/api/v3/ContributionTest.php
tests/templates/message_templates/contribution_online_receipt_html.tpl

index d2d3195c689b1a2d2d7f1c81ce866493e7b920c0..3bd2318dc797a7efc7f505649385976c4be6b9e3 100644 (file)
@@ -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.
index 0bb1e080bd685c3b3550f2bc7e10954d005fab34..176649c4c8f05117c2c129522b752d42e45fc906 100644 (file)
@@ -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();
index c64fc579bdacc9fe7e6d34f1b7fa6f4c1c92d82d..33faae643240f4f4f7438b3a392d363df78d3583 100644 (file)
@@ -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}