dev/core#4029 Ensure that Pan Truncation and card type id is recorded when processing...
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 30 Mar 2023 22:07:23 +0000 (09:07 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 30 Mar 2023 22:20:28 +0000 (09:20 +1100)
CRM/Contribute/Form/Contribution/Confirm.php
tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php

index 9de15eb9a23eb0b582ab8a6f308cdc3cb9353206..e93b6ae706bbc0eb5b88e356031065084f3a962a 100644 (file)
@@ -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) {
index 487e142e4a781e02ef8130872620fafcf8b21427..e52ef44d9f4a37c96aee0db4b381d06371e21bd5 100644 (file)
@@ -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']);
   }