According to the documentation, Checkout supports two different integrations: simple and custom.
A simple way works for me:
**<form action="create_subscription.php" method="POST">**
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="asdsdfasd3232"
data-amount="2000"
data-name=""
data-description="2 widgets"
data-image="https://s3.amazonaws.com/stripe-uploads/acct_19EnQrGHC6pu6Qvdmerchant-icon-1485553962843-logo_stripe.png"
data-locale="auto">
</script>
</form>
However, in my own way, I do not understand how and where I should call the "create_subscription.php" script. This is the user integration code:
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton">Purchase</button>
<script>
var handler = StripeCheckout.configure({
key: 'asdsdfasd3232',
image: 'https://s3.amazonaws.com/stripe-uploads/acct_19EnQrGHC6pu6Qvdmerchant-icon-1485553962843-logo_stripe.png',
locale: 'auto',
token: function(token) {
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
handler.open({
name: '',
description: '2 widgets',
amount: 2000
});
e.preventDefault();
});
window.addEventListener('popstate', function() {
handler.close();
});
</script>
I tried this code but it does not work. Can someone point me in the right direction?
<form action="/create_subscription.php" method="POST">
<script src="https://checkout.stripe.com/checkout.js"></script>
<div id="stripe-demo" class="evo-button rounded cele">
<span>Register</span>
</div>
<script>
var handler = StripeCheckout.configure({
key: "asdsdfasd3232",
image: "img/logo.png",
name: "",
description: "Subscription for 1 month",
panelLabel: "Sign Me Up!",
amount: "2000",
allowRememberMe: false
});
document.getElementById('stripe-demo').addEventListener('click', function(e) {
handler.open();
e.preventDefault();
});
window.addEventListener('popstate', function() {
handler.close();
});
</script>
</form>
source
share