Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Last active November 13, 2018 22:47
Show Gist options
  • Save staycreativedesign/621f17a4c22d93455ef61add8f69d579 to your computer and use it in GitHub Desktop.
Save staycreativedesign/621f17a4c22d93455ef61add8f69d579 to your computer and use it in GitHub Desktop.
Uncaught SyntaxError: Unexpected token - Line 5
%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