From 1d98578b4d7be5868a2def108bef1a1c7c4be43c Mon Sep 17 00:00:00 2001
From: Peter <aegir@mysite.com>
Date: Tue, 30 Nov 2010 13:00:06 -0600
Subject: [PATCH] fix for 'paypal only works with primary email' and makes email non-case sensative

---
 payment/uc_paypal/uc_paypal.pages.inc |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/payment/uc_paypal/uc_paypal.pages.inc b/payment/uc_paypal/uc_paypal.pages.inc
index 07b1a66..997ace7 100644
--- a/payment/uc_paypal/uc_paypal.pages.inc
+++ b/payment/uc_paypal/uc_paypal.pages.inc
@@ -35,14 +35,17 @@ function uc_paypal_ipn($order_id = 0) {
   $payment_amount = check_plain($_POST['mc_gross']);
   $payment_currency = check_plain($_POST['mc_currency']);
   $payment_fee = check_plain($_POST['mc_fee']);
-  $receiver_email = check_plain($_POST['receiver_email']);
+  $receiver_email = check_plain($_POST['business']);
+  if ($receiver_email == '') {
+    $receiver_email = check_plain($_POST['receiver_email']);
+  }
   $txn_id = check_plain($_POST['txn_id']);
   $txn_type = check_plain($_POST['txn_type']);
   $payer_email = check_plain($_POST['payer_email']);
 
   // Express Checkout IPNs may not have the WPS email stored. But if it is, make
   // sure that the right account is being paid.
-  if (variable_get('uc_paypal_wps_email', '') && $receiver_email != variable_get('uc_paypal_wps_email', '')) {
+  if (variable_get('uc_paypal_wps_email', '') && drupal_strtolower($receiver_email) != drupal_strtolower(variable_get('uc_paypal_wps_email', ''))) {
     watchdog('uc_paypal', 'IPN for a different PayPal account attempted.', array(), WATCHDOG_ERROR);
     return;
   }
-- 
1.5.4.3

