#johnpitchko-token
1 messages · Page 1 of 1 (latest)
How are you loading STripe.js?
Script tag in my application layout HTML file
Are you possibly loading v1 instead of v3?
Is there a reason you're just testing this out in the console? Looks like that undefined is expected (see https://stackoverflow.com/questions/14633968/chrome-firefox-console-log-always-appends-a-line-saying-undefined)
Oh
No reason other than to confirm that the code is working in the app
Ok when I run in the app now, seems to be working. I get another error but the stripe variable seems to initialize now. Thanks!
Thanks for the unrelated help!
I don't do much front end
no problem!
Oh unrelated question. Can you use Stripe tokens for adding a credit card to a customer?
I've inherited a really old app that used Stripe tokens on the client side to capture a user's credit card. The token value would then be passed to the app server which created/updated the customer's credit card.
Ahh think I found it: https://stripe.com/docs/api/tokens/create_card
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yup! Tokens are one-time use, so you'd trade it in for a card/source and attach that to the customer. Of course, the recommendation nowadays is to use Payment Methods, but if you're working with an older app it's not surprising it's using legacy things
karbi Sorry to bother again ( cannot post in our other thread) but I'm struggling to find the docs on how to generate a client-side card token.
I found this but server-side only. Then I found this which seems WAAYYY more complicated than the v1 version implemented in the app
Hey @pastel cave , karbi had to step away for a bit. I can help, just need to catch up on this thread and your latest question
Thank you, just looking for documentation on generating client-side tokens for cards. The app I inherited uses v1 of the Stripe.js, which uses a pretty elementary method for generating card tokens. Karbi pointed me to v3 of the Stripe.js which I don't believe offers the same method (at least according to the API docs I'm looking at).
What is the method that v3 doesn't seem to have?
Stripe.createToken({...});
And to clarify, is the goal here is just to take client side info and create a card with it on a customer? Does it need to use tokens?
To be fair, I haven't tested it. Just didn't clearly see it in the docs.
Yeah just adding a card to an existing customer. Legacy app does it via client-side tokens, so I am replicating that.
Within the same app, just another endpoint/page.
And the current call is incompatible with what you are doing because it uses Stripe Elements?
Oh no current call works great, but its using v1 of the API. I figured it might be a good time to upgrade to the latest version of the API.
Just couldn't find any documentation about it, which we've run into before because this app is very old. So trying to be considerate of future devs by not propagating legacy stuff.
Gotcha, so this is the currently recommended flow for collecting payment method details client side and saving them to a customer https://stripe.com/docs/payments/save-and-reuse