コード例 #1
0
            //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) {
                $infostring .= ", " . dollars($past_donations) . " Donated";
            }
            //Workaround so we don't have to use the STEAM API again...
            output_steam_info($steamid, array(0 => array("steamid" => $steamid, "personaname" => $_POST["steam_personaname"], "personastate" => $_POST["steam_personastate"], "gameid" => $_POST["steam_gameid"], "avatarfull" => $_POST["steam_avatarfull"])), $infostring);
            ?>
			    <p>Please rejoin the game for your points to update on the server.</p>
			    <?php 
        } catch (\Stripe\Error\ApiConnection $e) {
            output_error("Networking error ApiConnection");
        } catch (\Stripe\Error\InvalidRequest $e) {
            output_error("Error: Form was resubmitted");
コード例 #2
0
ファイル: sql.php プロジェクト: jackson-c/PointShop-Donation
function calculate_donation_increment($id, $db, $amount)
{
    $info = sql_get_info($id, $db);
    return max(0, calculate_donation($amount + $info["donation_total"]) - $info["donation_credited"]);
}