CRM-21771: error when viewing event registration with linked contribution
authorJitendra Purohit <jitendra@fuzion.co.nz>
Thu, 22 Feb 2018 08:43:57 +0000 (14:13 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Thu, 22 Feb 2018 08:48:45 +0000 (14:18 +0530)
CRM/Contribute/BAO/Contribution.php
tests/phpunit/api/v3/ParticipantPaymentTest.php

index a4788a9bb571bf0b53a0287b43d3b87365ae327c..9b6e26c18a00b854fd899c326e6561bba744eea0 100644 (file)
@@ -4108,7 +4108,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'];
index 25da033ad0eed3f4a771bfdd35027471cc30465f..e5fe10b82c7c5e5944a20da5fc8b55b9be4da72b 100644 (file)
@@ -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