From: Seamus Lee Date: Thu, 30 Mar 2023 22:07:23 +0000 (+1100) Subject: dev/core#4029 Ensure that Pan Truncation and card type id is recorded when processing... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3e1c5ce3831e5b9b01fb1054918d448978f41a5e;p=civicrm-core.git dev/core#4029 Ensure that Pan Truncation and card type id is recorded when processing front end contributions --- diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 9de15eb9a2..e93b6ae706 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1728,8 +1728,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 'is_transactional' => FALSE, 'fee_amount' => $result['result']['fee_amount'] ?? NULL, 'receive_date' => $result['result']['receive_date'] ?? NULL, - 'card_type_id' => $result['result']['card_type_id'] ?? NULL, - 'pan_truncation' => $result['result']['pan_truncation'] ?? NULL, + 'card_type_id' => $paymentParams['card_type_id'] ?? NULL, + 'pan_truncation' => $paymentParams['pan_truncation'] ?? NULL, ]); } catch (CRM_Core_Exception $e) { @@ -2407,8 +2407,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 'is_transactional' => FALSE, 'fee_amount' => $result['fee_amount'] ?? NULL, 'receive_date' => $result['receive_date'] ?? NULL, - 'card_type_id' => $result['card_type_id'] ?? NULL, - 'pan_truncation' => $result['pan_truncation'] ?? NULL, + 'card_type_id' => $paymentParams['card_type_id'] ?? NULL, + 'pan_truncation' => $paymentParams['pan_truncation'] ?? NULL, ]); } catch (CRM_Core_Exception $e) { diff --git a/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php b/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php index 487e142e4a..e52ef44d9f 100644 --- a/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php @@ -227,6 +227,12 @@ class CRM_Contribute_Form_Contribution_ConfirmTest extends CiviUnitTestCase { $form->preProcess(); $form->buildQuickForm(); $form->postProcess(); + $financialTrxnId = $this->callAPISuccess('EntityFinancialTrxn', 'get', ['entity_id' => $form->_contributionID, 'entity_table' => 'civicrm_contribution', 'sequential' => 1])['values'][0]['financial_trxn_id']; + $financialTrxn = $this->callAPISuccess('FinancialTrxn', 'get', [ + 'id' => $financialTrxnId, + ])['values'][$financialTrxnId]; + $this->assertEquals('1111', $financialTrxn['pan_truncation']); + $this->assertEquals(1, $financialTrxn['card_type_id']); $assignedVariables = $form->get_template_vars(); $this->assertTrue($assignedVariables['is_separate_payment']); }