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");
}
    case "deletebooking":
        deleteBooking($_REQUEST['uid']);
        break;
    case "generateuserlist":
        showUserList($_REQUEST);
        break;
    case "generategrouplist":
        showGroupList($_REQUEST);
        break;
    case "editbooking":
        editBooking($_REQUEST['userid']);
        break;
    case "getpaperwork":
        getPaperworkByID($_REQUEST['papid']);
        break;
    case "deletepaperwork":
        deletePaperwork($_REQUEST['papid']);
        break;
    case "loadyearrecopts":
        display_year_recognition();
        break;
    case "updateuseryearrec":
        updateUserYearRecognition($_REQUEST);
        break;
    case "deductpayment":
        deductPayment($_REQUEST);
        break;
    case "clearpayments":
        clearPayments($_REQUEST);
        break;
}