summaryrefslogtreecommitdiffstats
path: root/donate
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2019-05-31 20:24:45 -0400
committerLukas Fleischer <lfleischer@calcurse.org>2019-05-31 20:24:45 -0400
commit4e6abad2bba7f30be098bd9eb1078c029e991faa (patch)
treee308b6602a3d7d201e715287fb3ad8ed960ba4cb /donate
parent1d105aaa86105c91274d5fe7433d0a43b291affc (diff)
downloadcalcurse.org-4e6abad2bba7f30be098bd9eb1078c029e991faa.tar.gz
calcurse.org-4e6abad2bba7f30be098bd9eb1078c029e991faa.zip
Add reCAPTCHA to out donations script
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'donate')
-rw-r--r--donate/index.html44
1 files changed, 28 insertions, 16 deletions
diff --git a/donate/index.html b/donate/index.html
index 801ad22..71f77c7 100644
--- a/donate/index.html
+++ b/donate/index.html
@@ -10,6 +10,7 @@
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/lightbox.js"></script>
<script type="text/javascript" src="https://checkout.stripe.com/checkout.js"></script>
+ <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=6LdGJp4UAAAAAOSO_ptuZSe-ZBRDZ0UUl47IulUu"></script>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/css/style.css" media="all" />
@@ -71,22 +72,33 @@ var handler = StripeCheckout.configure({
key: (location.search == '?test') ? 'pk_test_zNePe3wvpZ65O3nEeFq4QL2j' : 'pk_live_g0aFHViGhTkfSSCFmDCr5UI8',
locale: 'auto',
token: function(token) {
- $.ajax({
- type: "POST",
- url: "/stripe",
- data: { "token": token.id, "email": token.email, "amount": amount, "currency": token.currency, "test": (location.search == '?test') },
- success: function(data) {
- if (data.success) {
- $("#donate-status").html('<h2>Thank you for your donation!</h2>');
- } else {
- $("#donate-status").html('<h2>Whoops, something went wrong!</h2><p class="error">There has been an error, and you have not been charged. Please try again or send an email to <tt>&lt;donations at calcurse dot org&gt;</tt>.');
- $("#donate-status h2").text(data.message);
- }
- },
- error: function(jqXHR, msg, err) {
- $("#donate-status").html('<h2>Whoops, something went wrong!</h2><p class="error">There has been an error, and you have not been charged. Please try again or send an email to <tt>&lt;donations at calcurse dot org&gt;</tt>.');
- $("#donate-status h2").text(msg + ", " + err);
- }
+ grecaptcha.ready(function() {
+ grecaptcha.execute('6LdGJp4UAAAAAOSO_ptuZSe-ZBRDZ0UUl47IulUu', {"action": "process_payment"}).then(function(recaptcha) {
+ $.ajax({
+ type: "POST",
+ url: "/stripe",
+ data: {
+ "token": token.id,
+ "email": token.email,
+ "amount": amount,
+ "currency": token.currency,
+ "recaptcha": recaptcha,
+ "test": (location.search == '?test'),
+ },
+ success: function(data) {
+ if (data.success) {
+ $("#donate-status").html('<h2>Thank you for your donation!</h2>');
+ } else {
+ $("#donate-status").html('<h2>Whoops, something went wrong!</h2><p class="error">There has been an error, and you have not been charged. Please try again or send an email to <tt>&lt;donations at calcurse dot org&gt;</tt>.');
+ $("#donate-status h2").text(data.message);
+ }
+ },
+ error: function(jqXHR, msg, err) {
+ $("#donate-status").html('<h2>Whoops, something went wrong!</h2><p class="error">There has been an error, and you have not been charged. Please try again or send an email to <tt>&lt;donations at calcurse dot org&gt;</tt>.');
+ $("#donate-status h2").text(msg + ", " + err);
+ }
+ });
+ });
});
}
});