From 6e751b1410e7d57e38e423eddce7614760a64af7 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Thu, 22 Feb 2018 14:13:57 +0530 Subject: [PATCH] CRM-21771: error when viewing event registration with linked contribution --- CRM/Contribute/BAO/Contribution.php | 2 +- .../phpunit/api/v3/ParticipantPaymentTest.php | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index e3fe4ca57c..936f4ed968 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4106,7 +4106,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) } $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total); - $contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $id, 'return' => array('is_pay_later', 'contribution_status_id', 'financial_type_id'))); + $contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $contributionId, 'return' => array('is_pay_later', 'contribution_status_id', 'financial_type_id'))); $info['payLater'] = $contribution['is_pay_later']; $info['contribution_status'] = $contribution['contribution_status']; diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index 25da033ad0..e5fe10b82c 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -123,6 +123,27 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->contributionDelete($contributionID); } + /** + * Test getPaymentInfo() returns correct + * information of the participant payment + */ + public function testPaymentInfoForEvent() { + //Create Contribution & get contribution ID + $contributionID = $this->contributionCreate(array('contact_id' => $this->_contactID)); + + //Create Participant Payment record With Values + $params = array( + 'participant_id' => $this->_participantID4, + 'contribution_id' => $contributionID, + ); + $this->callAPISuccess('participant_payment', 'create', $params); + + //Check if participant payment is correctly retrieved. + $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_participantID4, 'event'); + $this->assertEquals('Completed', $paymentInfo['contribution_status']); + $this->assertEquals('100.00', $paymentInfo['total']); + } + ///////////////// civicrm_participant_payment_create methods -- 2.25.1