/**
* 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)
*
- * @throws \CRM_Core_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;
+ $result = $this->setStatusPaymentPending([]);
+
+ // 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 = $this->setStatusPaymentCompleted($result);
+ return $result;
+ }
+
if (isset($params['is_recur']) && $params['is_recur'] == TRUE) {
throw new CRM_Core_Exception(ts('Elavon - recurring payments not implemented'));
}
// set this for debugging -look for output in apache error log
//curl_setopt ($ch,CURLOPT_VERBOSE,1 );
// 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);
}
$trxn_id = (string) CRM_Core_DAO::singleValueQuery($query);
$trxn_id = (int) str_replace('test', '', $trxn_id);
++$trxn_id;
- $params['trxn_id'] = sprintf('test%08d', $trxn_id);
- return $params;
+ $result['trxn_id'] = sprintf('test%08d', $trxn_id);
+ return $result;
}
throw new PaymentProcessorException('Error: [approval code related to test transaction but mode was ' . $this->_mode, 9099);
}
// Success !
if ($this->_mode !== 'test') {
// 'trxn_id' is varchar(255) field. returned value is length 37
- $params['trxn_id'] = $processorResponse['ssl_txn_id'];
+ $result['trxn_id'] = $processorResponse['ssl_txn_id'];
}
$params['trxn_result_code'] = $processorResponse['ssl_approval_code'] . "-Cvv2:" . $processorResponse['ssl_cvv2_response'] . "-avs:" . $processorResponse['ssl_avs_response'];
+ $result = $this->setStatusPaymentCompleted($result);
- return $params;
+ return $result;
}
}