I'm working on setting up recurring payments with stripe. I'm using react-stripe-elements to collect card information and it looks like there's two ways to save a card for later:
this.props.stripe.createToken()
this.props.stripe.createSource()
Then create a customer on the backend:
stripe.customers.create({ source: tokenId })
stripe.customers.create({ source: sourceId })
The result in stripe dashboard:
tokenId
sourceId
My question is what is the difference between these two patterns? Should I be using one instead of the other? I notice in the tokenId pattern the card says cvc/zip check passed, while the card doesn't say that in the sourceId pattern. But the sourceId pattern also explicitly says the card is chargeable and reusable, does that imply that the card saved from using the tokenId pattern is not reusable? Are the logs/events in the sourceId card more useful? The return object structure for the two patterns is also different.
Any help would be much appreciated, thanks in advance!
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.
Source objects allow you to accept a variety of payment methods with a single API. A source represents a customer's payment instrument, and can be used with the Stripe API to create payments. Sources can be charged directly, or attached to customers for later reuse.
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.
Stripe works with payment networks like Visa and Mastercard to tokenize a user's repository of PANs into network tokens, and maintains them so they stay current, even if the underlying card data changes.
Token is just a string value result after tokenization of the user card details. You can use token or source for either one time or subscription payment(provided you don't use it to charge immediately before attaching it to customer).
But source gives you more option as it is the only option you have when accept other payment option such as alipay or wechat pay etc, you cannot use token api with other payment method other than card. As @Daniel Winterstein said that token was Stripe old API and stripe decided to keep it just for backward compatibility but you should use source as the standard API to capture use payment details.
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