Move post-payment triggers to a separate function, and improve paypal verification attempts
This commit is contained in:
@@ -58,15 +58,31 @@ function booking_paypal_ipn() {
|
||||
|
||||
//verify the notification with paypal
|
||||
if(!_booking_paypal_ipn_verify($ipn)) {
|
||||
watchdog('booking_paypal', 'Payment verification did not succeed. Retrying.');
|
||||
if(!_booking_paypal_ipn_verify($ipn)) {
|
||||
return;
|
||||
} else {
|
||||
watchdog('booking_paypal', 'Payment verification succeeded on second attempt.');
|
||||
watchdog('booking_paypal', 'Payment verification did not succeed. Retrying...');
|
||||
|
||||
//retry the attempt to verify the payment 5 times, sleeping in between each attempt
|
||||
$continue = TRUE;
|
||||
$i = 0;
|
||||
while ($continue && $i < 5)
|
||||
{
|
||||
if(!_booking_paypal_ipn_verify($ipn)) {
|
||||
watchdog('booking_paypal', 'Payment verification did not succeed on attempt $i.');
|
||||
$i++;
|
||||
sleep(3);
|
||||
} else {
|
||||
$continue = FALSE;
|
||||
watchdog('booking_paypal', 'Payment verification succeeded on attempt $i.');
|
||||
}
|
||||
}
|
||||
|
||||
//exited the loop above with an unsuccessful verification, so return from the function now
|
||||
if ($continue)
|
||||
{
|
||||
watchdog('booking_paypal', 'Payment verification was unsuccessful.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if we're still exectuing then the verification was successful
|
||||
//verification was successful if we reach this point
|
||||
|
||||
/*
|
||||
if ($ipn['payment_status'] != 'Pending' && variable_get('booking_paypal_sandbox', 0) == 1) {
|
||||
@@ -147,14 +163,6 @@ function _booking_process_payment($data) {
|
||||
->execute();
|
||||
|
||||
//Get the person's info
|
||||
/*
|
||||
$payment = db_select('booking_person', 'p')
|
||||
->condition('p.nid', $nid, '=')
|
||||
->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd', 'booking_partner_id'))
|
||||
->execute()
|
||||
->fetchObject();
|
||||
*/
|
||||
|
||||
$person = node_load($nid);
|
||||
|
||||
//check if we found a person matching this payment
|
||||
@@ -201,7 +209,11 @@ function _booking_process_payment($data) {
|
||||
))
|
||||
->condition('nid', $nid)
|
||||
->execute();
|
||||
|
||||
|
||||
//replace the code below with a call to the helper function
|
||||
_booking_postpayment_trigger($nid, $person, $balance_payment);
|
||||
|
||||
/*
|
||||
//If there is no outstanding balance, send a payment complete email
|
||||
$amount_owing = _booking_amount_owing($person);
|
||||
//if ($total >= $person->booking_total_pay_reqd)
|
||||
@@ -251,12 +263,6 @@ function _booking_process_payment($data) {
|
||||
//send an email to the spouse
|
||||
_booking_registration_email($person->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' => $person->booking_partner_id));
|
||||
} //end spouse check
|
||||
*/
|
||||
}
|
||||
//if this was an initial payment we might need to send a notification
|
||||
elseif ($balance_payment == FALSE)
|
||||
@@ -275,7 +281,9 @@ function _booking_process_payment($data) {
|
||||
_booking_partialbalance_payment_email($nid);
|
||||
//TODO: create an email specifically for partial-balance payments
|
||||
//_booking_registration_email($nid, $balance_payment);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
else //couldn't find a matching nid for this invoice
|
||||
{
|
||||
|
Reference in New Issue
Block a user