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.
*
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.
*
return TRUE;
}
+ /**
+ * Does this payment processor support refund?
+ *
+ * @return bool
+ */
+ public function supportsRefund() {
+ return TRUE;
+ }
+
+ /**
+ * Submit a refund payment
+ *
+ * @throws \Civi\Payment\Exception\PaymentProcessorException
+ *
+ * @param array $params
+ * Assoc array of input parameters for this transaction.
+ */
+ public function doRefund(&$params) {}
+
/**
* Generate error object.
*
],
];
}
+
+/**
+ * Action refund.
+ *
+ * @param array $params
+ *
+ * @return array
+ * API result array.
+ * @throws CiviCRM_API3_Exception
+ */
+function civicrm_api3_payment_processor_refund($params) {
+ $processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']);
+ $processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', array('id' => $params['payment_processor_id'])));
+ if (!$processor->supportsRefund()) {
+ throw API_Exception('Payment Processor does not support refund');
+ }
+ $result = $processor->doRefund($params);
+ return civicrm_api3_create_success(array($result), $params);
+}
+
+/**
+ * Action Refund.
+ *
+ * @param array $params
+ *
+ */
+function _civicrm_api3_payment_processor_refund_spec(&$params) {
+ $params['payment_processor_id'] = [
+ 'api.required' => 1,
+ 'title' => ts('Payment processor'),
+ 'type' => CRM_Utils_Type::T_INT,
+ ];
+ $params['amount'] = [
+ 'api.required' => TRUE,
+ 'title' => ts('Amount to refund'),
+ 'type' => CRM_Utils_Type::T_MONEY,
+ ];
+}