further implementation work for stripe integration

This commit is contained in:
Nathan Coad
2016-07-22 09:01:39 +10:00
parent 6172866bf4
commit c0d2e11172
6 changed files with 188 additions and 221 deletions

View File

@@ -91,7 +91,7 @@ function booking_paypal_ipn() {
}
*/
//TODO: Handle refund and payment dispute IPNs
//@todo Handle refund and payment dispute IPNs
if (empty($ipn['payment_status']) || ($ipn['payment_status'] != 'Completed' && variable_get('booking_paypal_sandbox', 0) == 0))
return;
@@ -131,8 +131,7 @@ function _booking_process_payment($data) {
//verify paypal hasn't already sent through a notification for this payment
$duplicate_check = db_query("SELECT payid, booking_person_nid FROM {booking_payment} where booking_ipn_track_id = :ipn_id ",
array(':ipn_id' => $data['ipn_track_id']))
->fetchObject();
array(':ipn_id' => $data['ipn_track_id']))->fetchObject();
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;
@@ -166,45 +165,9 @@ function _booking_process_payment($data) {
//check if we found a person matching this payment
if ($person) {
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
'!payment' => $person->booking_amount_paid));
//if successful, update their total payment amount
$total = $person->booking_amount_paid + $data['mc_gross'];
//only recalculate their booking status if this is the initial payment, not a payment of the outstanding balance
if ($balance_payment == FALSE) {
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $person->booking_status);
if ($person->booking_status == 1) {
watchdog('booking', 'This registration has been manually assigned to the booked-in list.');
$status = 1;
}
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2) {
watchdog('booking', 'This registration belongs on the waiting list.');
$status = 2;
}
else {
watchdog('booking', 'This registration made it to the booked-in list.');
$status = 1;
}
}
else {
//this is a balance payment
watchdog('booking', 'Processing a balance payment.');
//if this is a payment of outstanding balance, keep the booking_status the same
$status = $person->booking_status;
}
//update the database for this person
db_update('booking_person')
->fields(array(
'booking_amount_paid' => $total,
'booking_status' => $status,
))
->condition('nid', $nid)
->execute();
//handle workflow emails and spouse payment updates
_booking_postpayment_trigger($nid, $person, $balance_payment);
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment',
array('!id' => $nid, '!eid' => $eid, '!payment' => $person->booking_amount_paid));
_booking_process_payment($person, $data['mc_gross'], $balance_payment);
}
else {
//couldn't find a matching nid for this invoice
@@ -216,8 +179,7 @@ function _booking_process_payment($data) {
/**
* Landing page after returning from paypal
*/
function booking_payment_completed_page()
{
function booking_payment_completed_page() {
//get some configuration information
global $event;
$output = "";