var stripe = Stripe('pk_test_51HWMiSJoEtlrQ2NqKqYIJH13raDUjWFP9KnO5obE6slqFElfTpRw71FMLBDH8A0mUuVIhJeEjNS4n1pvBdG745MW00XrMX3Yjh'); var elements = stripe.elements(); // Custom styling can be passed to options when creating an Element. var style = { base: { // Add your base input styles here. For example: fontSize: '16px', color: '#32325d', }, }; // Create an instance of the card Element. var card = elements.create('card', {style: style}); // Add an instance of the card Element into the `card-element`
. card.mount('#card-element'); // Create a token or display an error when the form is submitted. var form = document.getElementById('payment-form'); form.addEventListener('submit', function(event) { event.preventDefault(); stripe.createToken(card).then(function(result) { if (result.error) { // Inform the customer that there was an error. var errorElement = document.getElementById('card-errors'); errorElement.textContent = result.error.message; } else { // Send the token to your server. stripeTokenHandler(result.token); } }); });