For approximately how long is a Stripe card token (aquired through Stripe.js) valid? According to the docs:
The token is single-use only and has a short life. Use it in an API call immediately.
I understand I shouldn't store the token for use later, but how short is "short" in this case? Should I expect it to expire within seconds or minutes?
(Although not relevant to the question itself, the reason I'm asking is that I would like to take the token exchange step out of the transaction that the user is waiting for, and let a background job handle the actual Stripe integration. Obviously, that's not a good idea if the token has a very short lifetime.)
Yes, tokenization do have expiry date and that is something so configured or set up by issuer. Additionally, tokens are replenished under token life cycle management and again that is managed/configured by issuer.
Creates a single-use token that represents a credit card's details. This token can be used in place of a credit card with any API method. These tokens can be used only once: by creating a new Charge object, or by attaching them to a Customer object.
You would retrieve the customer object (stripe.com/docs/api#customer_object) on your server and you could look at the sources hash associated with it and get the last4 and expiration date for the card there.
The card token is valid for a few minutes (usually up to 10). What Stripe recommends in that case is to use the token now to create a customer via the API first to save its card and then let your background job handle the charge part after the fact.
This also ensures that the card is valid as Stripe runs a $0/$1 authorization on the card first. You can then give feedback to the customer immediately in case of an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With