From 68e61ad6b7fce36d47cfc330da6750e587738c88 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 7 Jul 2015 22:25:11 +1200 Subject: [PATCH] CRM-16737, CRM-15296 support for payment_status_id as the new official way to declare outcome of payment transaction --- CRM/Contribute/BAO/Contribution/Utils.php | 9 +++++++-- CRM/Member/BAO/Membership.php | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 1df72627a6..04b9ddffc2 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -330,8 +330,13 @@ class CRM_Contribute_BAO_Contribution_Utils { ); } $form->postProcessPremium($premiumParams, $contribution); - if (is_array($result) && !empty($result['trxn_id'])) { - $contribution->trxn_id = $result['trxn_id']; + if (is_array($result)) { + if (!empty($result['trxn_id'])) { + $contribution->trxn_id = $result['trxn_id']; + } + if (!empty($result['payment_status_id'])) { + $contribution->contribution_status_id = $result['payment_status_id']; + } } $membershipResult[1] = $contribution; } diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 13c2ca8c83..bc51d8effb 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1452,7 +1452,8 @@ 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)) { + if (!empty($membershipContribution->trxn_id) && !isset($membershipContribution->payment_status_id) + || (!empty($membershipContribution->payment_status_id) && $membershipContribution->payment_status_id == 1)) { try { civicrm_api3('contribution', 'completetransaction', array( 'id' => $membershipContribution->id, -- 2.25.1