Last active
November 13, 2018 22:47
-
-
Save staycreativedesign/621f17a4c22d93455ef61add8f69d579 to your computer and use it in GitHub Desktop.
Uncaught SyntaxError: Unexpected token - Line 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%script{:src => "https://checkout.stripe.com/checkout.js"} | |
:javascript | |
var handler = StripeCheckout.configure({ | |
key: '#{Rails.configuration.stripe[:publishable_key]}', | |
locale: 'auto', | |
name: 'foobar', | |
description: 'Donation', | |
token: function(token) { | |
$('input#stripeToken').val(token.id); | |
$('form').submit(); | |
} | |
}); | |
$('#donateButton').on('click', function(e) { | |
e.preventDefault(); | |
$('#error_explanation').html(''); | |
var amount = $('input#amount').val(); | |
amount = amount.replace(/\$/g, '').replace(/\,/g, '') | |
amount = parseFloat(amount); | |
if (isNaN(amount)) { | |
$('#error_explanation').html('<p>Please enter a valid amount in USD ($).</p>'); | |
} | |
else if (amount < 5.00) { | |
$('#error_explanation').html('<p>Donation amount must be at least $5.</p>'); | |
} | |
else { | |
amount = amount * 100; // Needs to be an integer! | |
handler.open({ | |
amount: Math.round(amount) | |
}) | |
} | |
}); | |
$(window).on('popstate', function() { | |
handler.close(); | |
}); | |
$(".donationAmount").click(function(e){ | |
e.preventDefault(); | |
da = $(this).data("amount") | |
$("#amount").val(da) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment