From 5d3a2b9faed88588cd5dd902edb221cf4c416c34 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 20 Apr 2017 16:03:38 +1200 Subject: [PATCH] CRM-20264 handling for storing card_type_id --- CRM/Contribute/BAO/Contribution.php | 2 ++ CRM/Contribute/Form/AbstractEditPayment.php | 7 +++++++ CRM/Event/Form/Participant.php | 5 ++--- CRM/Event/Form/Registration/Confirm.php | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index e527ad5d95..fe49c31bca 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3385,6 +3385,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac // also make it available as return value self::recordAlwaysAccountsReceivable($trxnParams, $params); $trxnParams['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); + $trxnParams['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); $return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); $params['entity_id'] = $financialTxn->id; if (empty($params['partial_payment_total']) && empty($params['partial_amount_pay'])) { @@ -3808,6 +3809,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $params['partial_amount_pay'] = $trxnsData['total_amount']; $trxnsData['net_amount'] = !empty($trxnsData['net_amount']) ? $trxnsData['net_amount'] : $trxnsData['total_amount']; $params['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $trxnsData); + $params['card_type_id'] = CRM_Utils_Array::value('card_type_id', $trxnsData); // record the entry $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData); diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index ffab96701a..4e0801e91d 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -573,6 +573,13 @@ WHERE contribution_id = {$id} $this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $this->_params)); } $this->_params['ip_address'] = CRM_Utils_System::ipAddress(); + if (in_array('credit_card_type', array_keys($this->_params))) { + $this->_params['card_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->_params['credit_card_type']); + } + if (!empty($this->_params['credit_card_number']) && empty($this->_params['pan_truncation'])) { + $this->_params['pan_truncation'] = substr($this->_params['credit_card_number'], -4); + } + } diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 07160eed32..49b1c13bef 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1050,6 +1050,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } $this->_params = $params; + parent::beginPostProcess(); $amountOwed = NULL; if (isset($params['amount'])) { $amountOwed = $params['amount']; @@ -1181,9 +1182,6 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]); $this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]); - $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params); - $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params); - $this->_params['ip_address'] = CRM_Utils_System::ipAddress(); $this->_params['amount'] = $params['fee_amount']; $this->_params['amount_level'] = $params['amount_level']; $this->_params['currencyID'] = $config->defaultCurrency; @@ -1354,6 +1352,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 'check_number', 'campaign_id', 'pan_truncation', + 'card_type_id', ); foreach ($recordContribution as $f) { diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 155f8e6c13..d0385232b3 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -972,6 +972,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 'source' => !empty($params['participant_source']) ? $params['participant_source'] : $params['description'], 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params), + 'card_type_id' => CRM_Utils_Array::value('card_type_id', $params), + 'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $params), ); if ($paymentProcessor) { -- 2.25.1