Skip to content

Instantly share code, notes, and snippets.

@andrewpthorp
Forked from anonymous/gist:8100390
Last active January 1, 2016 05:48
Show Gist options
  • Save andrewpthorp/8100571 to your computer and use it in GitHub Desktop.
Save andrewpthorp/8100571 to your computer and use it in GitHub Desktop.
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton">Purchase</button>
<label><input type="radio" name="amount" value="2000" data-description="DESCRIBE $20 PRODUCT HERE">$20</label>
<label><input type="radio" name="amount" value="5000" data-description="DESCRIBE $50 PRODUCT HERE">$50</label>
<label><input type="radio" name="amount" value="10000" data-description="DESCRIBE $100 PRODUCT HERE">$100</label>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_ahu1YHgH8D5BMaKmm3IX3aav',
image: 'YOUR_LOGO_HERE.JPG',
token: function(token, args) {
// Use the token to create the charge with a server-side script.
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// cache the selected radio button here
var $selected = $('input[name=amount]:checked')
// Open Checkout with further options
handler.open({
name: 'YOUR STORE NAME HERE',
description: $selected.data('description'),
amount: $selected.val()
});
e.preventDefault();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment