2017-09-26 217 views
0

我正在一个项目中有一个整合到BigCommerce,但我有一个问题,试图处理付款方式,我需要知道什么是在付款方式中使用的卡类型,如果接受使用卡。 这是我提出付款方式清单请求时的响应Xml。 GET/API/V2 /支付/方法付款方式BigCommerce

<?xml version="1.0" encoding="UTF-8"?> 
<payment_methods> 
    <payment_method> 
     <code>braintree</code> 
     <name>PayPal powered by Braintree</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>braintreepaypal</code> 
     <name>PayPal powered by Braintree</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>testgateway</code> 
     <name>Test Payment Gateway</name> 
     <test_mode>true</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>cod</code> 
     <name>Cash on Delivery</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>cheque</code> 
     <name>Check</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>moneyorder</code> 
     <name>Money Order</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>instore</code> 
     <name>Pay in Store</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
    <payment_method> 
     <code>bankdeposit</code> 
     <name>Bank Deposit</name> 
     <test_mode>false</test_mode> 
    </payment_method> 
</payment_methods> 

如果让我选择测试支付平台作为付款方式,您必须插入存储卡。我需要知道卡的类型(VI,MC,AMEX ....)

+0

取决于卡发生器。 http://www.getcreditcardnumbers.com/,第一个数字表示卡的类型。 4 =签证等 – GeekNinja

+0

好的,但如何获得卡类型= 4您需要在回复中提供 – abelh2200

+0

您使用货到付款过帐了样本,因此没有信用卡。发布信用卡付款的样本,以便我们可以给出很好的答案。 – jdweng

回答

-1

使用xml linq。我将文件读入字符串,就像您从响应中获得的输入一样。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Xml; 
using System.Xml.Linq; 
using System.IO; 

namespace ConsoleApplication1 
{ 
    class Program 
    { 
     const string FILENAME = @"c:\temp\test.xml"; 
     static void Main(string[] args) 
     { 
      //read file into string 

      string xml = File.ReadAllText(FILENAME); 

      XDocument doc = XDocument.Parse(xml); 

      var payment_methods = doc.Descendants("payment_method").Select(x => new { 
       code = (string)x.Element("code"), 
       name = (string)x.Element("name"), 
       test_mode = (Boolean)x.Element("test_mode") 
      }).ToList(); 
     } 
    } 
} 
+1

据我所知,但没有像卡类型或cc_type这样的属性,这就是我所需要的,例如(MasterCard,Visa等) – abelh2200

+0

此更新 – abelh2200

+0

第6或8支付卡号码(信用卡,借记卡等)的数字被称为发行人识别号码(IIN),以前称为银行识别号码(BIN)。网上应该有一个表格,您可以查看该公司。 xml不包含这些信息。请参阅:https://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number – jdweng

-1

考虑使用的Bigcommerce的交易API - 只要你知道订单ID为顺序,你可以使用这个API等来访问的订单上的付款方式的细节。此处的文档:https://developer.bigcommerce.com/api/v3/orders.html#gettransactions

请注意,这是一个“V3”API,因此您需要通过OAuth访问它,并且仅限JSON。

+0

所以你告诉我,如果我使用V3 API,我只能访问那些信息,这是没有意义的,我的应用程序使用XML,它必须是另一种方式 – abelh2200

+0

我只是向你展示了更新的API BC提供的有你需要的信息。他们的V2订单API已经有很多年了,这个Transaction API对于你的用例来说还不到一年的时间,这就是为什么它只使用现代JSON。 V2订单API可以通过JSON以及某些标题获得。 –