Add in deprecated warning if amount is not numeric and use filter var to return appro...
[civicrm-core.git] / CRM / Core / Payment.php
index 8064029670ca052daecd2106bf2e6f279ed6a799..e19da90c3a5e19e2617fef8ac78cf0a21befb0e5 100644 (file)
@@ -1164,7 +1164,11 @@ abstract class CRM_Core_Payment {
    * @throws \CRM_Core_Exception
    */
   protected function getAmount($params = []) {
-    return CRM_Utils_Money::format($params['amount'], NULL, NULL, TRUE);
+    if (!CRM_Utils_Rule::numeric($params['amount'])) {
+      CRM_Core_Error::deprecatedWarning('Passing Amount value that is not numeric is deprecated please report this in gitlab');
+      return filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
+    }
+    return $params['amount'];
   }
 
   /**