Loads of changes

This commit is contained in:
2014-02-24 23:53:12 +11:00
parent 66d4c89679
commit b710954bdd
10 changed files with 357 additions and 251 deletions

View File

@@ -89,6 +89,7 @@ function booking_paypal_ipn() {
function _booking_process_payment($data) {
global $event;
$balance_payment = false;
$amount_owing = 0;
//TODO: verify $data['receiver_email'] matches variable_get('booking_paypal_account', '')
@@ -118,7 +119,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;
return;
}
watchdog('booking', 'Adding payment for user with node id: !id; event id: !eid', array('!id' => $nid, '!eid' => $eid));
@@ -155,6 +156,7 @@ function _booking_process_payment($data) {
->execute()
->fetchObject();
//check if we found a person matching this payment
if ($payment)
{
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
@@ -198,12 +200,11 @@ function _booking_process_payment($data) {
))
->condition('nid', $nid)
->execute();
//send a notification email
//If there is no outstanding balance, send a payment complete email
$amount_owing = _booking_amount_owing($nid);
//if ($total >= $payment->booking_total_pay_reqd)
if (_booking_amount_owing($nid) == 0)
if ($amount_owing == 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);
@@ -237,16 +238,23 @@ function _booking_process_payment($data) {
->condition('nid', $payment->booking_partner_id)
->execute();
//send an email
_booking_registration_email($payment->booking_partner_id, $balance_payment);
//send an email to the spouse
_booking_registration_email($payment->booking_partner_id, TRUE);
}
elseif (variable_get('booking_enable_combined_pricing', 0) == 1)
{
watchdog('booking', 'Combined pricing is enabled, but this person has a partner id of !id.', array('!id' => $payment->booking_partner_id));
} //end spouse check
}
//if this was an initial payment we need to send a notification
elseif ($balance_payment == FALSE)
{
_booking_registration_email($nid, FALSE);
}
else //this person still has an outstanding balance so just send a confirmation email
{
watchdog('booking', 'This balance payment of !payment was insufficient for !id to completely pay the total outstanding of !outstanding.',
array('!id' => $nid, '!payment' => $data['mc_gross'], '!outstanding' => $amount_owing));
//TODO: create an email specifically for partial-balance payments
//_booking_registration_email($nid, $balance_payment);
}