Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe Payments: Source vs Token/Card?

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

    • tokenId card enter image description here
  • sourceId

    • sourceId source

enter image description here

  • sourceId card

enter image description here

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!

like image 472
connor Avatar asked May 11 '18 03:05

connor


People also ask

What is card token in Stripe?

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.

What is source in Stripe?

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.

How long does Stripe token last?

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.

Is Stripe a token service provider?

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.


1 Answers

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.

like image 109
kasongoyo Avatar answered Sep 24 '22 18:09

kasongoyo