From e0f0ee820fe39006444c6dcffd9d2a844926b264 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 3 Dec 2014 18:10:45 -0500 Subject: [PATCH] Monthly supporter can enter variable amount. This required some doing. I'm not completely sure it works, but I roughly followed the tutorial available at: https://www.paypal.com/webapps/mpp/get-started/create-recurring-donation-button with back-reference to this: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/ My main concern with this setup currently is that 'p3' must be set to '1', which would seem from the documentation to be saying the payment will recur only once. There is a subtle hint via the tutorial that setting 'src' to 1 will override 'p3' with whatever is found in 'srt', but that's not said anywhere explicitly that I can find. So, I'm going with this and I'll just test it myself with a monthly subscription to see if it's indefinite (which is the behavior we herein desire). Finally, note that "amount" is now a class rather than id, since I'm now using the associated jQuery .on('input') code for both the annual and monthly amount boxes. --- www/conservancy/static/supporter-page.js | 9 +++++---- www/conservancy/static/supporter/index.html | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/www/conservancy/static/supporter-page.js b/www/conservancy/static/supporter-page.js index d2bc8415..9a0cd866 100644 --- a/www/conservancy/static/supporter-page.js +++ b/www/conservancy/static/supporter-page.js @@ -42,15 +42,16 @@ $(document).ready(function() { $(".t-shirt-size-selector").hide(); } }); - $('#amount').addClass("valid"); - $('#amount').on('input', function() { + $('.amount').addClass("valid"); + $('.amount').on('input', function() { var input=$(this); var value = input.val(); var errorElement=$("span", input.parent()); var noCommaValue = value; noCommaValue = value.replace(/,/g, ""); var re = /^((\d{1,3}(,?\d{3})*?(\.\d{0,2})?)|\d+(\.\d{0,2})?)$/; - var isValid = ( re.test(value) && parseInt(noCommaValue) >= 120); + var isValid = ( re.test(value) && + parseInt(noCommaValue) >= parseInt(input.attr("minimum"))); if (isValid) { input.removeClass("invalid").addClass("valid"); errorElement.removeClass("form-error-show").addClass("form-error"); @@ -62,7 +63,7 @@ $(document).ready(function() { } }); $("#supporter-form-submit").click(function(event){ - var valid = $('#amount').hasClass("valid"); + var valid = $('.amount').hasClass("valid"); if (! valid) { $("#form-correction-needed").removeClass("form-error").addClass("form-error-show") .css("font-weight", "bold").css("font-size", "150%"); diff --git a/www/conservancy/static/supporter/index.html b/www/conservancy/static/supporter/index.html index 464acfa3..bbd76a0d 100644 --- a/www/conservancy/static/supporter/index.html +++ b/www/conservancy/static/supporter/index.html @@ -140,7 +140,7 @@ internal policies are published and available for scrutiny.

- + $120 is a minimum for Conservancy Supporters. Donate smaller amounts here.
@@ -194,10 +194,21 @@ internal policies are published and available for scrutiny.

monthly supporters for 12 months.

- - + - + + + + + + + + + + + + $10/month is a minimum for Conservancy + Supporters. Donate smaller amounts here.
Yes