Creating stripe payment token after validating other fields
By : kvk
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , To keep this simple I have only included one of the forms I am validating. Everything validates right, but I can't figure out why a token does not get generated. The form never submits. I had the form working right without validating not sure what the problem is. , Figured it out. Needed to not have the submit function as a method.
// validate fields
oeValidate.errors = false;
// send the card details to Stripe
// disable the submit button to prevent repeated clicks
// prevent the form from submitting the default action
Creating Stripe customer from Stripe Token using .Net client library & Stripe.js
may help you . Instead of using the element type 'card' I needed to separate the elements, In the documentation example they only use 'card' so when they create a token they just pass the card object to the create token parameter. , From the Elements reference.
var elements = stripe.elements();
var cardNumber = elements.create('cardNumber');
var cardExpiry = elements.create('cardExpiry');
var cardCvc = elements.create('cardCvc');
// creating a postal code element is deprecated
// var cardPostalCode = elements.create('postalCode');
This might help you You can not create a new token for an existing card as this would not make sense. The card is already saved on the customer and you can charge it. The easiest solution here is likely to do the reverse and save the card on a customer when you get a token tok_XXXX. This way, you always charge a card by passing the customer parameter as the customer id cus_XXXX and the source parameter as the card id card_XXXX.