Add in deprecated warning if amount is not numeric and use filter var to return appro...
[civicrm-core.git] / CRM / Core / Payment.php
index 94bdfd88ec35af1d0633547d9b6bc16c31ea47be..e19da90c3a5e19e2617fef8ac78cf0a21befb0e5 100644 (file)
@@ -584,32 +584,13 @@ 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':
-        if ($params['amount'] <= 0) {
-          return ts('To complete this transaction, click the <strong>Continue</strong> button below.');
-        }
-        if ($this->_paymentProcessor['billing_mode'] == 4) {
-          return ts('Click the <strong>Continue</strong> button to go to %1, where you will select your payment method and complete the contribution.', [$this->_paymentProcessor['payment_processor_type']]);
-        }
-        if ($params['is_payment_to_existing']) {
-          return ts('To complete this transaction, click the <strong>Make Payment</strong> button below.');
-        }
-        return ts('To complete your contribution, click the <strong>Continue</strong> button below.');
+        return ts('Click the <strong>Continue</strong> button to proceed with the payment.');
 
       case 'cancelRecurDetailText':
         if ($params['mode'] === 'auto_renew') {
@@ -1183,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'];
   }
 
   /**
@@ -1221,7 +1206,7 @@ abstract class CRM_Core_Payment {
   /**
    * Get URL to return the browser to on success.
    *
-   * @param $qfKey
+   * @param string $qfKey
    *
    * @return string
    */
@@ -1688,7 +1673,8 @@ abstract class CRM_Core_Payment {
    * @param null $entity
    * @param string $action
    *
-   * @return string
+   * @return string|null
+   * @throws \CRM_Core_Exception
    */
   public function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel') {
     // Set URL