2017-05-19 38 views
0

我是Stripe Pay的新手。我找到一種方法來爲添加到客戶卡的卡(任何卡)充電。但我無法區分一個3D安全卡。下面是我努力的代碼:Stripe:我如何知道卡是否安全以及如何對其充電

創建卡令牌:

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

現在我該怎樣繼續充電,如果此卡支持3D安全支付。

我想涉及卡和製作費用如下:提前

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

感謝..

回答

1

您可以使用卡片的sourcecard.three_d_secure屬性檢查3D安全驗證支持。

條紋API文檔→«3D安全卡支付與資源»→«Step 2: Determine if the card supports or requires 3D Secure»:

的行爲,並支持3D安全可以在卡網絡和類型而有所不同。對於不支持的卡,請改爲執行regular card payment

但是,有些髮卡機構需要使用3D Secure來降低欺詐風險,拒絕所有不使用此流程的費用。因此,您可以最好地處理這些不同的情況,在繼續3D安全過程之前檢查卡片源的屬性值card.three_d_secure

  • required:3D安全是必需的。該過程必須完成才能成功。
  • optional:3D安全是可選的。該過程不是必需的,但可以執行以幫助減少欺詐的可能性。
  • not_supported:此卡不支持3D Secure。繼續進行常規的卡支付。

一個3D安全支持檢測從我的條紋integration with Magento 2代碼(PHP): https://github.com/mage2pro/stripe/blob/2.4.6/Init/Action.php#L70-L151

相關問題