Stripe: How do i know whether card is 3d secure and how to charge it

Viewed 5176

i am new to Stripe Pay. I am finding a way to charge a card (any card) which is added to customer cards. But i am unable to differentiate a 3d secure card. Below is the code that i am trying:

Creating a card token:

     Map<String, Object> customerParams = new HashMap<String, Object>();
        Map<String, Object> tokenParams = new HashMap<String, Object>();
        Map<String, Object> cardParams = new HashMap<String, Object>();
        cardParams.put("number", "4000000000003063");
        cardParams.put("exp_month", 5);
        cardParams.put("exp_year", 2018);
        cardParams.put("cvc", "314");
        tokenParams.put("card", cardParams);
Token token=Token.create(tokenParams);

Adding token To customer:

Customer customer=Customer.retrieve("cus_Token");
      customerParams.put("source", token.getId());
      Card card=(Card)customer.getSources().create(customerParams);

Now how do i proceed to charge , if this card supports 3 d secure payment.

I am trying to relate card and making a charge as below:

 Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 1000);
    params.put("currency", "usd");
    params.put("description", "Testing payments");
  params.put("source","src_token");
  params.put("customer", "cus_Token");
  Charge charge = Charge.create(params);
  System.out.println(charge.getId());

thanks in advance..

2 Answers

I found an undocumented way to determine whether a card is three_d_secure without using stripe elements javascript.

when you create a card source as per the documentation, with property "type" set to "card", check the "typeData" hash for the "three_d_secure" key which returns the same information as the stripe elements card.

this works for the java client version 5.38.0. not sure about other versions.

Related