Reputation: 2516
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..
Upvotes: 4
Views: 5638
Reputation: 1
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.
Upvotes: 0
Reputation: 17503
The documentation for creating 3D Secure payments with Stripe can be found here: https://stripe.com/docs/sources/three-d-secure. It includes Java samples.
Note that this uses the new sources API, so you won't be using tokens at all. Rather, you'll create (reusable) card sources, then create (single use) 3D Secure sources using those card sources.
Upvotes: 3