Unsure how to create a token
See original GitHub issueHello!
I’m migrating over from tipsi-stripe so I think I’m mostly integrated with Stripe already but I cannot for the life of me figure out how to create a token in the way I was doing it before. I would appreciate anyone pointing me in the right direction. I scoured the docs, examples, and issues for the last two days but got very lost/confused and think I might’ve ended up on the wrong site? I tried running the example project to investigate further too but couldn’t get it to work.
In the app I’m working on, we allow users to add cards to use later (it’s a food delivery app so they shouldn’t have to add their card every time, only once). Before, I gathered the card info like this:
const params = {
number: cardNumber,
expMonth: Number(month),
expYear: Number(year),
cvc: security,
};
and created a token (type object) like this:
const token = await stripe.createTokenWithCard(params);
I then sent the token to the backend where it talked to stripe which stored the card. The stripe-react-native function that seems to be analogous is createToken
, which takes in an object where type
is the only required field, and returns a token object and an error. Then what happens? How does createToken
create a token that refers to a specific card with only the type (hypothetically) and not the number, cvc, etc? Is there another function that would let me take in my params and return an object with an id, or is this a much more complex problem?
I’m not using expo if that is important. I truly appreciate anyone’s help. I’m still learning so some things aren’t intuitive to me yet.
Issue Analytics
- State:
- Created a year ago
- Comments:6
@charliecruzan-stripe I truly thank you for your time!
This means CardField isn’t completely filled out. You should disable your
Checkout
button until theonCardChange
callback fires withcardDetails.complete === true