diff --git a/booking.paypal.inc b/booking.paypal.inc index 36f229e..8a3ebec 100644 --- a/booking.paypal.inc +++ b/booking.paypal.inc @@ -74,6 +74,12 @@ function booking_paypal_ipn() { if (empty($ipn['payment_status']) || ($ipn['payment_status'] != 'Completed' && variable_get('booking_paypal_sandbox', 0) == 0)) return; + //if (strcasecmp($ipn['receiver_email'], variable_get('booking_paypal_account', '') <> 0)) + if ($ipn['receiver_email'] !== variable_get('booking_paypal_account', '')) + { + watchdog('booking_paypal', 'Receiving address "!receiver" for paypal payment doesnt match configured address "!configured". Full POST: !id', + array('!id' => var_export($ipn, TRUE), '!receiver' => $ipn['receiver_email'], '!configured' => variable_get('booking_paypal_account', '')), WATCHDOG_ERROR); + } //Insert record into database and remove temporary booking id field from user _booking_process_payment($ipn); @@ -84,6 +90,8 @@ function _booking_process_payment($data) { global $event; $balance_payment = false; + //TODO: verify $data['receiver_email'] matches variable_get('booking_paypal_account', '') + //extract the person node id from the invoice $pos = strpos($data['invoice'], "_"); if (($pos === false) || ($pos == 0)) @@ -110,6 +118,7 @@ function _booking_process_payment($data) { if ($duplicate_check) { watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR); + //return; } watchdog('booking', 'Adding payment for user with node id: !id; event id: !eid', array('!id' => $nid, '!eid' => $eid)); @@ -141,7 +150,7 @@ function _booking_process_payment($data) { // ->fetchObject(); $payment = db_select('booking_person', 'p') - ->condition('p.nid', $nid,'=') + ->condition('p.nid', $nid, '=') ->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd', 'booking_partner_id')) ->execute() ->fetchObject(); @@ -193,7 +202,8 @@ function _booking_process_payment($data) { //send a notification email //If there is no outstanding balance, send a payment complete email - if ($total >= $payment->booking_total_pay_reqd) + //if ($total >= $payment->booking_total_pay_reqd) + if (_booking_amount_owing($nid) == 0) { //this should always be a balance payment type email, since that tells the user that their payment is completed _booking_registration_email($nid, TRUE); @@ -209,7 +219,7 @@ function _booking_process_payment($data) { ->fetchObject(); //update the spouse's status from "not paid" if required - $spouse_status = $spouse->booking_status == 0 ? 1 : $spouse_booking_status; + $spouse_status = $spouse->booking_status == 0 ? 1 : $spouse->booking_status; watchdog('booking', 'Setting status for spouse id !id to !new from !status', array('!id' => $payment->booking_partner_id, '!new' => $spouse_status, '!status' => $spouse->booking_status));