I want to put a second Stripe Checkout button for the mobile site of my landing page, but although I have put it the same way I put the first button (see 'SuscrÃbete' on the top of the main site), it does nothing when you click on it. The new button is located on the navigation menu that appears when you load my website in mobile view.
HTML code:
<button class="btn btn--secondary" id="checkout-button-sku_FQdLfDQeVmuBwR" role="link">SuscrÃbete</button>
I have already loaded:
<script>
var stripe = Stripe('pk_live_3ASoXZAFAaRMXuoCshu9gGSO00Jvx2IR2u');
var checkoutButton = document.getElementById('checkout-button-sku_FQdLfDQeVmuBwR');
checkoutButton.addEventListener('click', function() {
// When the customer clicks on the button, redirect
// them to Checkout.
stripe.redirectToCheckout({
items: [{
sku: 'sku_FQdLfDQeVmuBwR',
quantity: 1
}],
// Do not rely on the redirect to the successUrl for fulfilling
// purchases, customers may not always reach the success_url after
// a successful payment.
// Instead use one of the strategies described in
// https://stripe.com/docs/payments/checkout/fulfillment
successUrl: 'http://liderplay.es/success',
cancelUrl: 'http://liderplay.es/canceled',
})
.then(function(result) {
if (result.error) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer.
var displayError = document.getElementById('error-message');
displayError.textContent = result.error.message;
}
});
});
</script>
And
<script src="https://js.stripe.com/v3"></script>