Skip to content

Commit

Permalink
Merge pull request #20325 from mattwire/firstdatadopayment
Browse files Browse the repository at this point in the history
Convert FirstData to doPayment
  • Loading branch information
seamuslee001 authored May 17, 2021
2 parents bcf5338 + d4cc1ce commit 76cb1dc
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions CRM/Core/Payment/FirstData.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,29 @@ public function mapProcessorFieldstoParams($params) {
* 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'));
}
Expand Down Expand Up @@ -285,6 +302,8 @@ public function doDirectPayment(&$params) {
//=============
$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']);
Expand Down

0 comments on commit 76cb1dc

Please sign in to comment.