Last active
May 31, 2016 08:26
-
-
Save samcorcos/ccdb26119a508e56f658c425f4a2ab6a to your computer and use it in GitHub Desktop.
index html part 2
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
<html> | |
<head> | |
<title>Page Title</title> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> | |
<script src="https://checkout.stripe.com/checkout.js"></script> | |
<script> | |
var amount = 1000 | |
var submit = function(token) { | |
$.ajax({ | |
type: 'POST', url: '/api/purchase', data: { | |
token: token, | |
amount: amount | |
}, | |
beforeSend: function (xhr) { | |
xhr.setRequestHeader ("Authorization", "true"); | |
}, | |
}).done(function(res) { | |
console.log(res) | |
console.log("POST request successful"); | |
}) | |
} | |
</script> | |
<script> | |
$(document).ready(function() { | |
var handler = StripeCheckout.configure({ | |
key: 'pk_test_IiTtsvsKFpu2sDWlrVJ8hDmF', | |
image: '/img/documentation/checkout/marketplace.png', | |
locale: 'auto', | |
token: function(token) { | |
submit(token, amount) | |
} | |
}); | |
$('#customButton').on('click', function(e) { | |
// Open Checkout with further options: | |
handler.open({ | |
name: 'Sightline Maps Inc.', | |
description: '2 widgets', | |
amount: amount | |
}); | |
e.preventDefault(); | |
}); | |
// Close Checkout on page navigation: | |
$(window).on('popstate', function() { | |
handler.close(); | |
}); | |
}) | |
</script> | |
</head> | |
<body> | |
Hello World! | |
<button id="customButton">Purchase</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment