From 760278d3c8e8a94ddeaae9659e18a7d2f27b2d79 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 29 Jul 2015 14:48:58 +1200 Subject: [PATCH] CRM-16926 backoffice version of respecting payment_status_id Conflicts: CRM/Contribute/Form/Contribution.php --- CRM/Contribute/Form/Contribution.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index c86eb49f04..9962143750 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1242,11 +1242,21 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * = error or success, unless it is a recurring contribution in which case it is pending. */ if ($result['payment_status_id'] == array_search('Completed', $statuses)) { - civicrm_api3('contribution', 'completetransaction', array( - 'id' => $contribution->id, - 'trxn_id' => $result['trxn_id'], - 'payment_processor_id' => $this->_paymentProcessor['id'], - )); + try { + civicrm_api3('contribution', 'completetransaction', array( + 'id' => $contribution->id, + 'trxn_id' => $result['trxn_id'], + 'payment_processor_id' => $this->_paymentProcessor['id'], + 'is_transactional' => FALSE, + )); + // This has now been set to 1 in the DB - declare it here also + $contribution->contribution_status_id = 1; + } + catch (CiviCRM_API3_Exception $e) { + if ($e->getErrorCode() != 'contribution_completed') { + throw new CRM_Core_Exception('Failed to update contribution in database'); + } + } } else { // Save the trxn_id. -- 2.25.1