Skip to content

Instantly share code, notes, and snippets.

@itisnot-me
Last active February 19, 2017 05:18
Show Gist options
  • Save itisnot-me/c70f2e60169a8dc248cd6b19ffbae866 to your computer and use it in GitHub Desktop.
Save itisnot-me/c70f2e60169a8dc248cd6b19ffbae866 to your computer and use it in GitHub Desktop.
var objvalues = {};//needed so you can store all items for later use
var handler = StripeCheckout.configure({
key: "pk_test_Public key",
image: "productimage.jpg",
token: function(token) {
objvalues["stripeToken"] = token.id;
objvalues["stripeEmail"] = token.email;
$.get(
"/handler.php", /* your route here */
objvalues,
function(data) {
console.log(data);
}
);
objvalues = {};//clear out var for later use
}
});
//example of button <button class="btn btn-success buynow" data-price="6799" data-desc="SEO Package" data-name="Seo" data-id="483hS" data-type="connected">Buy Now</button>
$("body").on("click", "button.buynow", function(e) {
// Open Checkout with further options
objvalues["type"]=$(this).attr("data-type");
objvalues["name"]=$(this).attr("data-name");
objvalues["description"] = $(this).attr("data-desc")+' ($'+$(this).attr("data-price")/100+')';
objvalues["amount"] = parseInt($(this).attr("data-price"));
objvalues["itemid"] = $(this).attr("data-id");//unique id generated from server that you can double check against the real price later. can help against fake charges
handler.open({
name: objvalues.name,
description: objvalues.description,
amount: objvalues.amount
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment