Skip to content

Commit

Permalink
Merge pull request #11907 from mattwire/contribution_financialtype_fix
Browse files Browse the repository at this point in the history
dev/core#88 Make sure financial_type_id is set when contribution is created
  • Loading branch information
monishdeb authored Jun 14, 2018
2 parents b782c36 + 248a226 commit 07f3638
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CRM/Contribute/BAO/Contribution/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public static function processConfirm(

// add some financial type details to the params list
// if folks need to use it
//CRM-15297 deprecate contributionTypeID
$paymentParams['financial_type_id'] = $paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $financialType->id;
//CRM-15297 - contributionType is obsolete - pass financial type as well so people can deprecate it
$paymentParams['financialType_name'] = $paymentParams['contributionType_name'] = $form->_params['contributionType_name'] = $financialType->name;
//CRM-11456
Expand Down Expand Up @@ -154,8 +156,6 @@ public static function processConfirm(
}

$paymentParams['contributionID'] = $contribution->id;
//CRM-15297 deprecate contributionTypeID
$paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
if (isset($paymentParams['contribution_source'])) {
$paymentParams['source'] = $paymentParams['contribution_source'];
Expand Down
13 changes: 5 additions & 8 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,21 +740,18 @@ public function postProcess() {
*
* Comments from previous refactor indicate doubt as to what was going on.
*
* @param int $contributionTypeId
* @param int $financialTypeID
*
* @return null|string
*/
public function wrangleFinancialTypeID($contributionTypeId) {
if (isset($paymentParams['financial_type'])) {
$contributionTypeId = $paymentParams['financial_type'];
}
elseif (!empty($this->_values['pledge_id'])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge',
public function wrangleFinancialTypeID($financialTypeID) {
if (empty($financialTypeID) && !empty($this->_values['pledge_id'])) {
$financialTypeID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge',
$this->_values['pledge_id'],
'financial_type_id'
);
}
return $contributionTypeId;
return $financialTypeID;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,20 @@ public function testPaynowPayment() {
'skipLineItem' => 0,
);

$result = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form,
$processConfirmResult = CRM_Contribute_BAO_Contribution_Utils::processConfirm($form,
$form->_params,
$contactID,
$form->_values['financial_type_id'],
0, FALSE
);

// Make sure that certain parameters are set on return from processConfirm
$this->assertEquals($form->_values['financial_type_id'], $processConfirmResult['financial_type_id']);

// Based on the processed contribution, complete transaction which update the contribution status based on payment result.
if (!empty($result['contribution'])) {
if (!empty($processConfirmResult['contribution'])) {
$this->callAPISuccess('contribution', 'completetransaction', array(
'id' => $result['contribution']->id,
'id' => $processConfirmResult['contribution']->id,
'trxn_date' => date('Y-m-d'),
'payment_processor_id' => $paymentProcessorID,
));
Expand Down

0 comments on commit 07f3638

Please sign in to comment.