Hello all. I'm not sure if this is the right place for this question or not, but here goes.
I'm new to stripe and I've been trying to work out how to implement a checkout form where the description and amount variables alternate between purchases. I've tried numerous different methods but I can't seem to get it to send the token information to the server. In its most basic appearance, my code looks like this:
<p><input id="buy-submit-button" class="button" type="submit" value="チェックアウト"></input></p>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_g6do5S237ekq10r65BnxO6S0',
locale: 'auto',
token: function(token) {
//don't know what needs to go here
}
});
document.getElementById("buy-submit-button").addEventListener('click', function(e) {
setTimeout(function(){
var totalCost = 0;
var totalCartLoad = "";
totalCost = localStorage.getItem('totalCartPrice');
totalCartLoad = localStorage.getItem('whatsInCart');
totalCartLoad = totalCartLoad.replace('undefined','');
// Open Checkout with further options:
handler.open({
name: "チェックアウト",
description: totalCartLoad,
shippingAddress: true,
billingAddress: true,
zipCode: true,
allowRememberMe: true,
currency: 'JPY',
amount: totalCost
});
e.preventDefault();
}, 500);
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
});
</script>
I currently don't have form tags surrounding this.