Skip to content

Commit

Permalink
Merge pull request #18385 from eileenmcnaughton/pay
Browse files Browse the repository at this point in the history
[REF] simplify interaction with objects in complete order
  • Loading branch information
mattwire authored Sep 7, 2020
2 parents 09b6d19 + 62a721e commit 77ca888
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Civi\Api4\ContributionPage;
use Civi\Api4\ContributionRecur;
use Civi\Api4\Participant;
use Civi\Api4\PaymentProcessor;

/**
*
Expand Down Expand Up @@ -4409,10 +4410,8 @@ public static function completeOrder($input, $ids, $objects, $isPostPaymentCreat

$contributionParams['payment_processor'] = $paymentProcessorId;

// If paymentProcessor is not set then the payment_instrument_id would not be correct.
// not clear when or if this would occur if you encounter this please fix here & add a unit test.
if (empty($contributionParams['payment_instrument_id']) && isset($contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'])) {
$contributionParams['payment_instrument_id'] = $contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'];
$contributionParams['payment_instrument_id'] = PaymentProcessor::get()->addWhere('id', '=', $paymentProcessorId)->addSelect('payment_instrument_id')->execute()->first()['payment_instrument_id'];
}

if ($recurringContributionID) {
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/CRM/Member/BAO/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,9 @@ public function testMembershipPaymentForSingleContributionMultipleMembership() {
'original_contribution_id' => $contribution['id'],
'contribution_status_id' => 'Completed',
]);
$this->callAPISuccessGetCount('Contribution', [], 2);
$contributions = $this->callAPISuccess('Contribution', 'get', ['sequential' => 1])['values'];
$this->assertCount(2, $contributions);
$this->assertEquals('Debit Card', CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $contributions[1]['payment_instrument_id']));
// @todo this fails depending on what tests it is run with due some bad stuff in Membership.create
// It needs to be addressed but might involve the switch to ORDER. Membership BAO does bad line item stuff.
// $this->callAPISuccessGetCount('LineItem', [], 6);
Expand Down

0 comments on commit 77ca888

Please sign in to comment.