条纹:我怎么知道卡是否安全,以及如何充电

时间:2017-05-19 08:43:07

标签: java paypal stripe-payments

我是Stripe Pay的新手。我找到了一种方法来收取添加到客户卡的卡(任何卡)。但我无法区分3D安全卡。以下是我正在尝试的代码:

创建卡片令牌:

     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);

向客户添加令牌:

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

如果此卡支持3 d安全付款,我现在如何继续收费。

我正在尝试关联卡片并收费如下:

 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());

提前感谢..

3 个答案:

答案 0 :(得分:3)

可以在此处找到使用条带创建3D安全付款的文档:https://stripe.com/docs/sources/three-d-secure。它包括Java样本。

请注意,这会使用新的sources API,因此您根本不会使用令牌。相反,您将创建(可重复使用)card sources,然后使用这些卡片来源创建(单次使用)3D Secure sources

答案 1 :(得分:2)

您可以使用卡片sourcecard.three_d_secure属性检查3D安全验证支持。

Stripe API文档→«使用来源进行3D安全卡付款»→«Step 2: Determine if the card supports or requires 3D Secure»:

  

3D Secure的行为和支持可能因卡网络和类型而异。对于不受支持的卡,请改为执行regular card payment

     

但是,某些发卡机构需要使用3D Secure来降低欺诈风险,拒绝所有不使用此流程的费用。因此,您可以最好地处理这些不同的情况,在继续3D安全流程之前,请检查卡片来源的card.three_d_secure属性值。

     
      
  • required:需要3D Secure。必须完成该过程才能使收费成功。
  •   
  • optional:3D Secure是可选的。该过程不是必需的,但可以执行以帮助减少欺诈的可能性。
  •   
  • not_supported:此卡不支持3D Secure。继续使用普通卡付款。
  •   

我的Stripe integration with Magento 2中的3D安全支持检测代码(PHP): https://github.com/mage2pro/stripe/blob/2.4.6/Init/Action.php#L70-L151

答案 2 :(得分:0)

我找到了一种无证的方法来确定卡是否为three_d_secure而不使用条带元素javascript。

当您根据文档创建卡片源,并将属性“type”设置为“card”时,请检查“type_”散列中的“three_d_secure”键,该键返回与条带元素卡相同的信息。

这适用于java客户端版本5.38.0。不确定其他版本。

相关问题