2017-09-26 220 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以及某些標題獲得。 –