From 9bee639f48bb455e9c47be9b8025452d1b21f6c2 Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Mon, 5 Mar 2018 13:05:39 -0500 Subject: [PATCH] ensure correct payment_instrument_id https://lab.civicrm.org/dev/core/issues/7 Otherwise, after first recurring contribution, contributions are coded as check, not credit card. --- CRM/Core/Payment/AuthorizeNetIPN.php | 1 + tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index bdae00f94e..621ebde1ee 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -146,6 +146,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $contribution->amount_level = $objects['contribution']->amount_level; $contribution->address_id = $objects['contribution']->address_id; $contribution->campaign_id = $objects['contribution']->campaign_id; + $contribution->_relatedObjects = $objects['contribution']->_relatedObjects; $objects['contribution'] = &$contribution; } diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index da6311676d..cb73bbb3f4 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -186,6 +186,9 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { 'sequential' => 1, )); $this->assertEquals(2, $contribution['count']); + // Ensure both contributions are coded as credit card contributions. + $this->assertEquals(1, $contribution['values'][0]['payment_instrument_id']); + $this->assertEquals(1, $contribution['values'][1]['payment_instrument_id']); $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); $this->callAPISuccessGetSingle('line_item', array( -- 2.25.1