function completePayment($vars)
{
    $user_details = $_SESSION['userdetails'];
    $activityinfo = $_SESSION['activitydetails'];
    for ($i = 0; $i < count($_SESSION['booked_activitys']); $i++) {
        $booked_activityinfo[] = $activityinfo[$_SESSION['booked_activitys'][$i]];
    }
    $total = 0;
    for ($i = 0; $i < count($booked_activityinfo); $i++) {
        $cur_activity = $booked_activityinfo[$i];
        $total = $total + $cur_activity->cost;
    }
    if ($total . $_REQUEST['ServiceID'] == $_REQUEST['Amount'] && count($booked_activityinfo) == $_REQUEST['Quantity'] && $total . $_REQUEST['ServiceID'] == $_REQUEST['TotalPaid'] && $_REQUEST['TotalPaid'] == $_REQUEST['TotalPayable']) {
        if (isset($_SESSION['fullpayment'])) {
            $removePaymentVars = array("uid" => $user_details->id);
            clearPayments($removePaymentVars);
            unset($_SESSION['booked_activitys']);
            unset($_SESSION['fullpayment']);
            unset($_SESSION['cur_bookings']);
        } else {
            var_dump($_SESSION['booked_activitys']);
            $activities = $_SESSION['booked_activitys'];
            $removePaymentVars = array("uid" => $user_details->id, "aid" => implode(":", $activities));
            if (isset($_SESSION['booked_activitys']) && isset($_SESSION['userdetails'])) {
                removePendingPayment($removePaymentVars);
                unset($_SESSION['booked_activitys']);
                $_SESSION['message'] = 52;
                $_SESSION['parentpayreturn'] = $_REQUEST;
            } else {
                $_SESSION['message'] = 51;
                $_SESSION['messageval'] = "FATAL, Activities IDs Not Set/Marked Off!";
            }
        }
    } else {
        $_SESSION['message'] = 51;
        $_SESSION['messageval'] = "FATAL, Returned parameters do not match expected parameters!";
    }
    header("Location: checkout");
}
     deleteYear($_REQUEST['year']);
     break;
 case "addgroup":
     addGroup($_REQUEST['group']);
     break;
 case "deletegroup":
     print deleteGroup($_REQUEST['group']);
     break;
 case "deleteblockeduser":
     deleteBlockedUser($_REQUEST['user']);
     break;
 case "addblockeduser":
     addBlockedUser($_REQUEST['user']);
     break;
 case "removependingpayment":
     removePendingPayment($_REQUEST);
     break;
 case "getpendingpayments":
     getPendingPayments($_REQUEST);
     break;
 case "removependingform":
     removePendingForm($_REQUEST);
     break;
 case "getpendingpaperwork":
     getPendingPaperwork($_REQUEST);
     break;
 case "embedhtmlreport":
     embedReport($_REQUEST);
     break;
 case "loadpane":
     showAdminPane($_REQUEST);