From bc66bc9ebdfa5ba101c2c28502636b5f3d6c2dd3 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Mon, 1 Jul 2013 17:49:12 +0530 Subject: [PATCH] CRM-12972 fix --- CRM/Core/Payment/PayPalIPN.php | 12 ++++++++++-- CRM/Core/Payment/PayPalProIPN.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index ad07fd8ca2..5a468fb1ff 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -173,10 +173,18 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { } if (!$first) { - // create a contribution and then get it processed + //check if this contribution transaction is already processed + //if not create a contribution and then get it processed $contribution = new CRM_Contribute_BAO_Contribution(); + $contribution->trxn_id = $input['trxn_id']; + if ($contribution->trxn_id && $contribution->find()) { + CRM_Core_Error::debug_log_message("returning since contribution has already been handled"); + echo "Success: Contribution has already been handled

"; + return TRUE; + } + $contribution->contact_id = $ids['contact']; - $contribution->financial_type_id = $objects['contributionType']->id; + $contribution->financial_type_id = $objects['contributionType']->id; $contribution->contribution_page_id = $ids['contributionPage']; $contribution->contribution_recur_id = $ids['contributionRecur']; $contribution->receive_date = $now; diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 3f5ad9ef2f..9ec6f8c39a 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -193,10 +193,18 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { } if (!$first) { - // create a contribution and then get it processed + //check if this contribution transaction is already processed + //if not create a contribution and then get it processed $contribution = new CRM_Contribute_BAO_Contribution(); + $contribution->trxn_id = $input['trxn_id']; + if ($contribution->trxn_id && $contribution->find()) { + CRM_Core_Error::debug_log_message("returning since contribution has already been handled"); + echo "Success: Contribution has already been handled

"; + return TRUE; + } + $contribution->contact_id = $ids['contact']; - $contribution->financial_type_id = $objects['contributionType']->id; + $contribution->financial_type_id = $objects['contributionType']->id; $contribution->contribution_page_id = $ids['contributionPage']; $contribution->contribution_recur_id = $ids['contributionRecur']; $contribution->receive_date = $now; -- 2.25.1