Add in deprecated warning if amount is not numeric and use filter var to return appro...
[civicrm-core.git] / CRM / Core / Payment.php
index d5bd619d7a9563b4965fcd4d60027184cfafad2c..e19da90c3a5e19e2617fef8ac78cf0a21befb0e5 100644 (file)
@@ -584,20 +584,10 @@ abstract class CRM_Core_Payment {
     // not documented clearly above.
     switch ($context) {
       case 'contributionPageRecurringHelp':
-        // require exactly two parameters
-        if (array_keys($params) == [
-          'is_recur_installments',
-          'is_email_receipt',
-        ]) {
-          $gotText = ts('Your recurring contribution will be processed automatically.');
-          if ($params['is_recur_installments']) {
-            $gotText .= ' ' . ts('You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.');
-          }
-          if ($params['is_email_receipt']) {
-            $gotText .= ' ' . ts('You will receive an email receipt for each recurring contribution.');
-          }
+        if ($params['is_recur_installments']) {
+          return ts('You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.');
         }
-        return $gotText;
+        return '';
 
       case 'contributionPageContinueText':
         return ts('Click the <strong>Continue</strong> button to proceed with the payment.');
@@ -1174,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'];
   }
 
   /**
@@ -1212,7 +1206,7 @@ abstract class CRM_Core_Payment {
   /**
    * Get URL to return the browser to on success.
    *
-   * @param $qfKey
+   * @param string $qfKey
    *
    * @return string
    */