From: Eileen McNaughton Date: Tue, 30 Sep 2014 07:37:29 +0000 (+1300) Subject: CRM-15296 - fix to confirm payments for recurring transactions that are processed... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a7a336512d1a418b249426afeebfa17131773e1a;p=civicrm-core.git CRM-15296 - fix to confirm payments for recurring transactions that are processed immediately (in a gentle way --- diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index fdb830594a..8bdb0795d7 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -330,7 +330,9 @@ class CRM_Contribute_BAO_Contribution_Utils { ); } $form->postProcessPremium($premiumParams, $contribution); - + if (is_array($result) && !empty($result['trxn_id'])) { + $contribution->trxn_id = $result['trxn_id']; + } $membershipResult[1] = $contribution; } diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 8289a514b9..1f67baf9e5 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -129,6 +129,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $contributionParams['payment_instrument_id'] = 1; } } + if ($paymentProcessorOutcome) { + $contributionParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $paymentProcessorOutcome); + } if (!$pending && $paymentProcessorOutcome) { $contributionParams += array( 'fee_amount' => CRM_Utils_Array::value('fee_amount', $paymentProcessorOutcome), @@ -137,7 +140,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 'receipt_date' => $receiptDate, // also add financial_trxn details as part of fix for CRM-4724 'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $paymentProcessorOutcome), - 'payment_processor' => CRM_Utils_Array::value('payment_processor', $paymentProcessorOutcome), ); } diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 5b5a38108c..5b513ef567 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1384,6 +1384,16 @@ AND civicrm_membership.is_test = %2"; // Do not send an email if Recurring transaction is done via Direct Mode // Email will we sent when the IPN is received. if (!empty($form->_params['is_recur']) && $form->_contributeMode == 'direct') { + if (!empty($membershipContribution->trxn_id)) { + try { + civicrm_api3('contribution', 'completetransaction', array('id' => $membershipContribution->id, 'trxn_id' => $membershipContribution->trxn_id)); + } + catch (CiviCRM_API3_Exception $e) { + // if for any reason it is already completed this will fail - e.g extensions hacking around core not completing transactions prior to CRM-15296 + // so let's be gentle here + CRM_Core_Error::debug_log_message('contribution ' . $membershipContribution->id . ' not completed with trxn_id ' . $membershipContribution->trxn_id . ' and message ' . $e->getMessage()); + } + } return; }