<?php session_start(); if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SESSION["steamid"]) && isset($_POST["stripeToken"]) && isset($_POST["stripeEmail"]) && isset($_POST["amount"])) { $amount = $_POST["amount"]; if ($amount >= 100 && $amount <= 500000) { require_once 'vendor/autoload.php'; $token = $_POST['stripeToken']; try { // Set your secret key \Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY); $charge = \Stripe\Charge::create(array('amount' => $amount, 'currency' => 'usd', 'source' => $token, 'description' => 'Donation')); //If the charge fails, we won't reach this point. $db = sql_start(); $steamid = $_SESSION["steamid"]; $info = sql_get_info($steamid, $db); $donationpoints = calculate_donation_increment($steamid, $db, $amount); //Log charge $db->query("INSERT INTO charges (id64, email, amount, points_before, points_after)\n\t\t\t \t\t\tVALUES (" . $db->quote($steamid) . ", " . $db->quote($_POST['stripeEmail']) . ", " . $db->quote($amount) . ", " . $db->quote($info["points"]) . ", " . $db->quote($info["points"] + $donationpoints) . ")"); //Credit user $info["points"] += $donationpoints; $info["donation_total"] += $amount; $info["donation_credited"] += $donationpoints; sql_set_info($steamid, $db, $info); ?> <h2>Donation complete - Thank you!</h2> <?php $pdata = sql_get_info($steamid, $db); $current_points = $pdata["points"]; $past_donations = $pdata["donation_total"]; $infostring = $current_points . " Points"; if ($past_donations > 0) {
<a href="index.php"><< Go Back</a> <?php } else { ?> <div class="finalinfo" style="width:250px;margin-left:200px;"> You are about to donate:<br> You will recieve:<br> To your account: </div> <div class="finalinfo" style="width:400px;"> <strong><?php echo dollars($amount); ?> </strong><br> <strong><?php echo number_format(calculate_donation_increment($steamid, $db, $amount)); ?> </strong> Points<br> <strong> <?php $players = fetch_steam_info($steamid); echo htmlspecialchars(steam_name($steamid, $players)); ?> </strong> (<?php echo steamid64ToSteamid((string) $steamid); ?> ) </div> <div style="clear:both;"> <br>