<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Validate Credit card number in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68520#M41707</link>
    <description>&lt;P&gt;There have been cards issued that are only 12 characters. Most cards are 16 digits. The standard way of validating is to use the&amp;nbsp;Luhn&lt;SPAN&gt;&amp;nbsp;algorithm. There's a lot of free sample code out there with it that you can incorporate.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2019 21:39:56 GMT</pubDate>
    <dc:creator>mmcguire</dc:creator>
    <dc:date>2019-07-22T21:39:56Z</dc:date>
    <item>
      <title>Validate Credit card number</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68511#M41698</link>
      <description>&lt;P&gt;Hi, I am using the C# integration to do the payment, i want to know the minimum lenght of all credit card types to validate in my BLL method.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 10:38:10 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68511#M41698</guid>
      <dc:creator>Praveens</dc:creator>
      <dc:date>2019-07-22T10:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Credit card number</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68520#M41707</link>
      <description>&lt;P&gt;There have been cards issued that are only 12 characters. Most cards are 16 digits. The standard way of validating is to use the&amp;nbsp;Luhn&lt;SPAN&gt;&amp;nbsp;algorithm. There's a lot of free sample code out there with it that you can incorporate.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 21:39:56 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68520#M41707</guid>
      <dc:creator>mmcguire</dc:creator>
      <dc:date>2019-07-22T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Credit card number</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68522#M41709</link>
      <description>&lt;P&gt;Typically, credit card numbers are all numeric and the length of the credit card number is between 12 digits to 19 digits.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;14, 15, 16 digits – Diners Club&lt;/LI&gt;&lt;LI&gt;15 digits – American Express&lt;/LI&gt;&lt;LI&gt;13, 16 digits – Visa&lt;/LI&gt;&lt;LI&gt;16 digits - MasterCard&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For C#, the following validates a credit card number using the Luhn&amp;nbsp;&lt;SPAN&gt;(Mod 10 algorithm):&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="code-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="code-keyword"&gt;static&lt;/SPAN&gt; &lt;SPAN class="code-keyword"&gt;bool&lt;/SPAN&gt; Mod10Check(&lt;SPAN class="code-keyword"&gt;string&lt;/SPAN&gt; creditCardNumber)
{
    &lt;SPAN class="code-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="code-keyword"&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(creditCardNumber))
    {
        &lt;SPAN class="code-keyword"&gt;return&lt;/SPAN&gt; &lt;SPAN class="code-keyword"&gt;false&lt;/SPAN&gt;;
    }

    &lt;SPAN class="code-keyword"&gt;int&lt;/SPAN&gt; sumOfDigits = creditCardNumber.Where((e) =&lt;SPAN class="code-keyword"&gt;&amp;gt;&lt;/SPAN&gt; e &lt;SPAN class="code-keyword"&gt;&amp;gt;&lt;/SPAN&gt;= &lt;SPAN class="code-string"&gt;'&lt;/SPAN&gt;&lt;SPAN class="code-string"&gt;0'&lt;/SPAN&gt; &amp;amp;&amp;amp; e &lt;SPAN class="code-keyword"&gt;&amp;lt;&lt;/SPAN&gt;= &lt;SPAN class="code-string"&gt;'&lt;/SPAN&gt;&lt;SPAN class="code-string"&gt;9'&lt;/SPAN&gt;)
                    .Reverse()
                    .Select((e, i) =&lt;SPAN class="code-keyword"&gt;&amp;gt;&lt;/SPAN&gt; ((&lt;SPAN class="code-keyword"&gt;int&lt;/SPAN&gt;)e - &lt;SPAN class="code-digit"&gt;48&lt;/SPAN&gt;) * (i % &lt;SPAN class="code-digit"&gt;2&lt;/SPAN&gt; == &lt;SPAN class="code-digit"&gt;0&lt;/SPAN&gt; ? &lt;SPAN class="code-digit"&gt;1&lt;/SPAN&gt; : &lt;SPAN class="code-digit"&gt;2&lt;/SPAN&gt;))
                    .Sum((e) =&lt;SPAN class="code-keyword"&gt;&amp;gt;&lt;/SPAN&gt; e / &lt;SPAN class="code-digit"&gt;10&lt;/SPAN&gt; + e % &lt;SPAN class="code-digit"&gt;10&lt;/SPAN&gt;);


 
    &lt;SPAN class="code-keyword"&gt;return&lt;/SPAN&gt; sumOfDigits % &lt;SPAN class="code-digit"&gt;10&lt;/SPAN&gt; == &lt;SPAN class="code-digit"&gt;0&lt;/SPAN&gt;;            
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 22:08:11 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Validate-Credit-card-number/m-p/68522#M41709</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2019-07-22T22:08:11Z</dc:date>
    </item>
  </channel>
</rss>

