0

I'm working in a project which have an integration to BigCommerce, but I have a problem trying to process the payment method, I need to know what is the card type used in a payment method if this accept using card. This is the Xml of the response when I made the request for payment method list. GET /api/v2/payments/methods

<?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>

If I choose Test Payment Gateway as payment method, You must insert a card. I need to know the type of the card(VI,MC, AMEX ....)

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
abelh2200
  • 37
  • 8
  • Depends on the card generator. http://www.getcreditcardnumbers.com/, the first number would denote the card type. 4 = visa, etc. – GeekNinja Sep 26 '17 at 21:34
  • Ok , but how you get card type = 4 y need that coming in the response – abelh2200 Sep 26 '17 at 21:36
  • You posted a sample of a payment using Cash on Delivery so there is no credit card. Post a sample of a credit card payment so we can give good answers. – jdweng Sep 27 '17 at 06:35
  • No, I use Test Payment Gateway which need a card that is what I post this question – abelh2200 Sep 27 '17 at 12:56
  • Is anyone can come with any suggestion? Maybe this is a question directly for BigCommerce support team – abelh2200 Sep 27 '17 at 16:29

2 Answers2

-1

Use xml linq. I read file into string like the input you are getting from response.

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();
        }
    }
}
jdweng
  • 33,250
  • 2
  • 15
  • 20
  • 1
    I understand but there is not attribute like card type or cc_type and that is what I need, E.g( MasterCard, Visa etc..) – abelh2200 Sep 26 '17 at 21:39
  • The first 6 or 8 digits of a payment card number (credit cards, debit cards, etc.) are known as the Issuer Identification Numbers (IIN), previously known as Bank Identification Number (BIN). There should be a table on the web that you can look up the company. The xml doesn't contain this information. See : https://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number – jdweng Sep 27 '17 at 04:02
  • That is not my question, if you work with integration with magento you will see that they return in the request the cc_type used in the payment method, if you use Visa they return "VI" , that is what I need here, but bigcommerce limit the response to only the payment method and his code and name – abelh2200 Sep 27 '17 at 13:04
  • This is a question for BigCommerce. I went to their website but could not find how do get bank id. I understand they do not want to give out credit card number, but should have a method to supply . I try a search here : https://forum.bigcommerce.com/s/search/All – jdweng Sep 27 '17 at 14:53
  • But not need the credit card number, only cc_type, I understand that we can get cc_type from cc_number but othe ecommerce sites give to you a cc_type without show the cc_number it seems that bigcommerce don't give access to that info – abelh2200 Sep 27 '17 at 15:02
  • It seems like the user isn't asking how to parse xml, and yet here once again is your standard answer to almost all questions. – David Heffernan Sep 27 '17 at 19:12
-1

Consider using BigCommerce's Transactions API - as long as you know the Order ID for the order, you can use this other API to access details of the payment methods on the order. Documentation here: https://developer.bigcommerce.com/api/v3/orders.html#gettransactions

Note that this is a "V3" API, so you need to access it via OAuth, and it's JSON only.

Nathan Booker
  • 684
  • 4
  • 6
  • So you tell me that I only can access to that info if I use V3 API , that makes no sense, my app use XML, it has to be another way – abelh2200 Sep 27 '17 at 13:01
  • I'm simply showing you the newer API BC has made available that has the information you need. Their V2 Orders API is many years old, this Transaction API which is perfect for your use case is less than a year old, which is why it uses modern JSON only. The V2 Orders API is available via JSON as well with certain headers. – Nathan Booker Sep 28 '17 at 14:39