-
-
Save andrewpthorp/8100571 to your computer and use it in GitHub Desktop.
This file contains 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="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