Merge pull request #14062 from civicrm/5.13
[civicrm-core.git] / CRM / Core / Payment.php
index fb465033e8a5faef76189755b7a13d3f774522f1..f7a5067668b064d83673c2ebf195e6772fe14485 100644 (file)
@@ -80,6 +80,9 @@ abstract class CRM_Core_Payment {
     RECURRING_PAYMENT_START = 'START',
     RECURRING_PAYMENT_END = 'END';
 
+  /**
+   * @var object
+   */
   protected $_paymentProcessor;
 
   /**
@@ -108,9 +111,9 @@ abstract class CRM_Core_Payment {
    *
    * (Deprecated parameter but used in some messages).
    *
+   * @var string
    * @deprecated
    *
-   * @var string
    */
   public $_processorName;
 
@@ -336,6 +339,15 @@ abstract class CRM_Core_Payment {
     return TRUE;
   }
 
+  /**
+   * Does this payment processor support refund?
+   *
+   * @return bool
+   */
+  public function supportsRefund() {
+    return FALSE;
+  }
+
   /**
    * Should the first payment date be configurable when setting up back office recurring payments.
    *
@@ -511,9 +523,9 @@ abstract class CRM_Core_Payment {
       case 'contributionPageRecurringHelp':
         // require exactly two parameters
         if (array_keys($params) == [
-            'is_recur_installments',
-            'is_email_receipt',
-          ]) {
+          '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.');
@@ -623,6 +635,7 @@ abstract class CRM_Core_Payment {
     if ($this->supports('changeSubscriptionAmount')) {
       return ['amount'];
     }
+    return [];
   }
 
   /**
@@ -901,7 +914,7 @@ abstract class CRM_Core_Payment {
    * @param int $billingLocationID
    *
    * @return array
-   *    Array of metadata for address fields.
+   *   Array of metadata for address fields.
    */
   public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
     if (!$billingLocationID) {
@@ -1003,8 +1016,8 @@ abstract class CRM_Core_Payment {
       'title' => ts('Country'),
       'cc_field' => TRUE,
       'attributes' => [
-          '' => ts('- select -'),
-        ] + CRM_Core_PseudoConstant::country(),
+        '' => ts('- select -'),
+      ] + CRM_Core_PseudoConstant::country(),
       'is_required' => TRUE,
     ];
     return $metadata;
@@ -1258,6 +1271,17 @@ abstract class CRM_Core_Payment {
     return $result;
   }
 
+  /**
+   * Refunds payment
+   *
+   * Payment processors should set payment_status_id if it set the status to Refunded in case the transaction is successful
+   *
+   * @param array $params
+   *
+   * @throws \Civi\Payment\Exception\PaymentProcessorException
+   */
+  public function doRefund(&$params) {}
+
   /**
    * Query payment processor for details about a transaction.
    *