1
votes

I want to use Stripe to charge cards recurrently every 30 days with amounts that oscilate.

From the docs I got that if there is a possibility that the card requires 3DS we should use Sources so I switched to sources ;)

From the source object stripe.js retrieves I look at three_d_secure param to decide whether to create a source object that requires 3DS or a normal card charging.

The flow:

With JS I get the source object that has three_d_secure set to either optional or required. When it's set to optional after I retrieve the source with: source = Stripe::Source.retrieve(source_id) it looks like this:

"status": "chargeable",
"type": "card",
"usage": "reusable",
"card":{"exp_month":12,"exp_year":2032,"brand":"Visa",...

I attach it to a customer and charge it. I guess usage: reusable means that I can charge the card again later...

When three_d_secure=='required' I create a new source calling this:

source = Stripe::Source.create({
    amount: amount,
    currency: currency,
    type: 'three_d_secure',
    three_d_secure: {
      card: source_id, #src_xcvxcvxcvc
    },
    redirect: {
      return_url: return_url
    },
})

I redirect the user to the URL Stripe provides, user enters his 3DS PIN and gets back to my return_url. When Stripe redirects the user back to my return_url I retrieve the source again and get something like this:

"status": "chargeable", "type": "three_d_secure", "usage": "single_use", "three_d_secure": {"card":"src_1B1JzQHopXUl9h9Iwk05JV1z","authenticated":true,"customer":null}

I would expect that after passing the 3DS the source becomes reusable and chargeable until the date of expiry or so :|

My questions are:

1 Why is the 3DS source single_use? Is this like this only in sanbox environment or with the card I am using to test?

2 Can a 3DS protected card be charged again at all?

3 What's the correct approach to attach to customer sources (3DS or normal) that can be charged again and again?

Thank you!

1

1 Answers

2
votes
  1. Because it is a source payment token, not a source card token. It expires on a due date or when is consumed. You can use reusable token to create single_use tokens. reusable one represents a card source token

  2. Yes if a 3ds is optional or not_supported, no if required. If required then every payement needs to fulfill a 3ds.

  3. Steps:

    • Create an src_card_token for a card or use saved one (reusable)

    • Create an customer object with an src from src_card_token

    • Create an src_payment_token for a customer using one of his saved cards (as token)

    • fullfil a 3ds redirect process if required.

    • create a charge