if ($paid) { $refund = \Stripe\Refund::create(array("charge" => $stripe_charge_id)); $_SESSION["refund"] = $refund["amount"] / 100; } // delete the user's event registration $unregister = unregisterUser($event["event_id"], $user['user_id']); $_SESSION["cancel"] = true; } if ($_POST["action"] == "cc-on-file" || $_POST["action"] == "new-card" || $_POST["action"] == "modify") { // determine the new price of the event $price_in_cents = intval($actual_price * 100); // if this is a new card, either create a new customer or update existing customer if ($_POST["action"] == "new-card") { if (empty($user["stripe_cust_id"])) { // create a new customer $stripe_cust_id = createStripeCustomer($token, $user); $user["stripe_cust_id"] = $stripe_cust_id; } else { // update a customer's source $cu = \Stripe\Customer::retrieve($user["stripe_cust_id"]); $cu->source = $token; $cu->save(); } $_SESSION["new-card"] = true; } if ($_POST["action"] == "modify") { $registrants = $_POST["registrants"]; $price_in_cents = $unit_price * $registrants * 100; $modify = registerUser($event["event_id"], $user["user_id"], $registrants, $stripe_charge_id, true); $_SESSION["modified"] = $registrants; }
$user = getUser($_SESSION["user_id"]); if ($_SESSION["member_level"] > 0) { $actual_price = $event["member_price"]; } } if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($event["nonmember_price"] > 0) { // user has just signed up for a paid event $registrants = $_POST["registrants"]; $actual_price = $actual_price * $registrants; $price_in_cents = intval($actual_price * 100); // create a customer (if required) and charge the user if (isset($_POST["type"])) { if ($_POST["type"] == "new") { $token = $_POST['stripeToken']; $user["stripe_cust_id"] = createStripeCustomer($token, $user); } } $stripe_charge_id = createEventCharge($user, $event, $price_in_cents, $registrants); $_SESSION["payment"] = $actual_price; } $register = registerUser($_GET["id"], $_SESSION["user_id"], $registrants, $stripe_charge_id); $_SESSION["registered"] = true; header("Location:/events/" . $event["event_id"] . "/"); } else { ?> <html> <?php include ROOT_PATH . "inc/head.php"; ?> <body>