Add stripe fees, fix price vars

master
Skylar Ittner 2 years ago
parent f8948179b4
commit 9854ec529d

@ -21,7 +21,7 @@ if (!empty($SETTINGS["disable_registration"]) && $SETTINGS["disable_registration
die("Online registration is now closed.");
}
$database->action(function($database) {
$database->action(function ($database) {
global $SETTINGS;
$database->insert("families", []);
@ -143,8 +143,8 @@ $database->action(function($database) {
switch ($people["type"][$pid]) {
case "camper":
$dueusd += 50.0;
echo "\nAdding $50 to the total for a camper, dueusd is $dueusd\n";
$dueusd += $SETTINGS["prices"]["camp"];
echo "\nAdding $$SETTINGS[prices][camp] to the total for a camper, dueusd is $dueusd\n";
$database->insert("campers", [
"parentname" => $people["parentname"][$pid],
"rank" => $people["rank"][$pid]
@ -152,7 +152,7 @@ $database->action(function($database) {
$camperid = $database->id();
break;
case "adult":
$discount = 10.0 * (strlen($days) / 2);
$discount = $SETTINGS["prices"]["adult_volunteer_daily_discount"] * (strlen($days) / 2);
$dueusd -= $discount;
echo "Subtracting $$discount from the total for an adult volunteer, dueusd is $dueusd\n";
// Add shirt charge if not working all days
@ -160,8 +160,8 @@ $database->action(function($database) {
// No shirt cost
} else if ($SETTINGS["prices"]["adult_tshirt"] !== false) {
if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < $SETTINGS["prices"]["adult_tshirt"]) {
echo "Adding $10 for a tshirt.\n";
$dueusd += 10.0;
echo "Adding $$SETTINGS[prices][tshirt] for a tshirt.\n";
$dueusd += $SETTINGS["prices"]["tshirt"];
}
}
if (!empty($people["child_care"][$pid])) {
@ -182,8 +182,8 @@ $database->action(function($database) {
case "youth":
if ($SETTINGS["prices"]["youth_tshirt"] !== false) {
if ($people["shirt"][$pid] != "NO" && (strlen($days) / 2) < $SETTINGS["prices"]["youth_tshirt"]) {
echo "Adding $10 for a tshirt.\n";
$dueusd += 10.0;
echo "Adding $$SETTINGS[prices][tshirt] for a tshirt.\n";
$dueusd += $SETTINGS["prices"]["tshirt"];
}
}
$database->insert("youth", [
@ -235,6 +235,12 @@ $database->action(function($database) {
$duecard = max(0, $dueusd - $campcoupons);
// Add Stripe fees
// https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
if ($SETTINGS["prices"]["add_stripe_fees"]) {
$duecard = ($duecard + 0.30) / (1 - 0.029);
}
echo "\nCost $dueusd total: $duecard to Stripe, $campcoupons as coupons\n";
if ($dueusd != $_POST['totalcharge']) {

@ -73,6 +73,10 @@ $("#youth_list").on("change", "select[data-name=shirt]", function () {
updateTotal();
});
$("input[name=campcoupons]").on("input paste change blur", function () {
updateTotal();
});
$(".list-group").on("click", ".rmpersonbtn", function () {
$(this).parent().remove();
updateTotal();
@ -114,7 +118,13 @@ function updateTotal() {
return false;
}).length * prices.tshirt;
totalcharge = Math.max(totalcharge, 0);
var couponcharge = ($("input[name=campcoupons]").val() * 1.0);
var cardcharge = Math.max(totalcharge - couponcharge, 0);
if (prices.add_stripe_fees) {
cardcharge = (cardcharge + 0.3) / (1 - 0.029);
}
totalcharge = Math.max(cardcharge + couponcharge, 0);
// The server will refuse to finish the registration if this doesn't match
// the backend-calculated amount, don't bother being a haxxor

@ -38,6 +38,7 @@ $SETTINGS = [
"camp" => 50.0,
"tshirt" => 10.0,
"adult_volunteer_daily_discount" => 10.0,
"add_stripe_fees" => true,
// Set to false to make shirts always free, set to a number to make them
// free for people who work at least that many days
"youth_tshirt" => false,

Loading…
Cancel
Save