Skip to content

Commit

Permalink
fixup! Add stripe donate form
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Apr 2, 2024
1 parent 8c38dad commit 5229a86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
16 changes: 2 additions & 14 deletions www/includes/easyparliament/helper-donate.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ function giftaid_decision()
}
}

function contact_decision()
{
return isset($_POST["contact_permission"])
? $_POST["contact_permission"]
: "No";
}

# Stripe

function stripe_post($path, $data)
Expand All @@ -78,7 +71,7 @@ function stripe_session_ajax($successPage, $cancelPage)
$utm_medium = $_POST["utm_medium"];
$utm_campaign = $_POST["utm_campaign"];
$full_name = $_POST["full_name"];
$contact_permission = contact_decision();
$contact_permission = $_POST["contact_permission"] ?? "No";

# backward compatibility
if ($howoften == "recurring") {
Expand Down Expand Up @@ -228,9 +221,4 @@ function get_checked($value, $checked_value, $echo = true)
function wp_esc_attr($text)
{
return htmlspecialchars($text, ENT_QUOTES, "UTF-8");
}

function get_or_default($name, $default_value = "")
{
return isset($_GET[$name]) ? $_GET[$name] : $default_value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
$default_type = 'annually';

# use the how-often parameter if set, if not default to option at end of line (options are 'monthly', 'annually', or 'one-off')
$initial_payment_type = isset($_GET['how-often']) ? $_GET['how-often'] : $default_type;
$initial_payment_type = $_GET['how-often'] ?? $default_type;

# use the how-much parameter if set, if not default to default amount for initial payment type
$how_much = isset($_GET['how-much']) ? $_GET['how-much'] : $default_amounts[$initial_payment_type];
$how_much = $_GET['how-much'] ?? $default_amounts[$initial_payment_type];

# if how-much is not in the allowed values for the current payment type, set to 'other', and set $other_how_much to the value of how-much
if (!array_key_exists($how_much, $payment_amounts[$initial_payment_type])) {
Expand Down Expand Up @@ -139,10 +139,10 @@ class="donate-<?=$payment_type?>-amount inline-radio-label"
<p><small>Payment methods available: Card, PayPal, Apple Pay, Google Pay, Direct Debit</small></p>
</div>

<input type="hidden" name="utm_source" value="<?=htmlspecialchars(get_or_default('utm_source', 'theyworkforyou.com')) ?>">
<input type="hidden" name="utm_content" value="<?=htmlspecialchars(get_or_default('utm_content')) ?>">
<input type="hidden" name="utm_medium" value="<?=htmlspecialchars(get_or_default('utm_medium')) ?>">
<input type="hidden" name="utm_campaign" value="<?=htmlspecialchars(get_or_default('utm_campaign', 'twfy_donate_page')) ?>">
<input type="hidden" name="utm_source" value="<?=htmlspecialchars($_GET['utm_source'] ?? 'theyworkforyou.com') ?>">
<input type="hidden" name="utm_content" value="<?=htmlspecialchars($_GET['utm_content'] ?? '') ?>">
<input type="hidden" name="utm_medium" value="<?=htmlspecialchars($_GET['utm_medium'] ?? '') ?>">
<input type="hidden" name="utm_campaign" value="<?=htmlspecialchars($_GET['utm_campaign'] ?? 'twfy_donate_page') ?>">

</form>

Expand Down

0 comments on commit 5229a86

Please sign in to comment.