X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPayment%2FFirstData.php;h=f6968c7e71fc45a14beef86c214b4c2491a024bd;hb=19a93bccf7714cb49387b48ecef29ce52e3f00df;hp=c51c3ff769d924ea63bc939f740df0782e442c35;hpb=64aa560db1b9afecf26162220cf0eb8153ff5a11;p=civicrm-core.git diff --git a/CRM/Core/Payment/FirstData.php b/CRM/Core/Payment/FirstData.php index c51c3ff769..f6968c7e71 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -138,12 +138,29 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { * This function sends request and receives response from * the processor * - * @param array $params + * @param array|PropertyBag $params + * + * @param string $component + * + * @return array + * Result array (containing at least the key payment_status_id) * - * @return array|object - * @throws \Exception + * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function doDirectPayment(&$params) { + public function doPayment(&$params, $component = 'contribute') { + $propertyBag = \Civi\Payment\PropertyBag::cast($params); + $this->_component = $component; + $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); + + // If we have a $0 amount, skip call to processor and set payment_status to Completed. + // Conceivably a processor might override this - perhaps for setting up a token - but we don't + // have an example of that at the moment. + if ($propertyBag->getAmount() == 0) { + $result['payment_status_id'] = array_search('Completed', $statuses); + $result['payment_status'] = 'Completed'; + return $result; + } + if ($params['is_recur'] == TRUE) { throw new CRM_Core_Exception(ts('First Data - recurring payments not implemented')); } @@ -205,7 +222,7 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 36000); // ensures any Location headers are followed - if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') { + if (ini_get('open_basedir') == '') { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); } @@ -285,6 +302,8 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { //============= $params['trxn_result_code'] = $processorResponse['r_message']; $params['trxn_id'] = $processorResponse['r_ref']; + $params['payment_status_id'] = array_search('Completed', $statuses); + $params['payment_status'] = 'Completed'; CRM_Core_Error::debug_log_message("r_authresponse " . $processorResponse['r_authresponse']); CRM_Core_Error::debug_log_message("r_code " . $processorResponse['r_code']); CRM_Core_Error::debug_log_message("r_tdate " . $processorResponse['r_tdate']);