Welcome Guest, Not a member yet? Register   Sign In
how to know credit card
#1
Information 

Hallo everyone
i just wanted to know that if user input his credit card details then how can i check it's master card, visa card or etc.
Help me..
Thanks
Nady
Reply
#2

Please stop posting the same thread in different sections of the forums; I've deleted 4 duplicates from you since yesterday.
Reply
#3

One of the easiest ways to figure that out is to use this https://github.com/stripe/jquery.payment. On the page as the card is being entered you can store the card type to a field.

If you want to do it in PHP there are many ways it can be done.  Read over this post http://stackoverflow.com/questions/72768...-on-number.

Good luck.
Reply
#4

Mastercard number starts with 5.
Visa starts with 4.
Discover starts with 6.
AMEX starts with 3.
Reply
#5

(12-12-2015, 03:45 AM)nady Wrote: Hallo everyone
i just wanted to know that if user input his credit card details then how can i check it's master card, visa card or etc.
Help me..
Thanks
Nady


PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

/**
 * ------------------------------------------------------------------------
 * Editor   : PhpStorm 10.0.2
 * Date     : 12/16/2015
 * Time     : 11:45 AM
 * Authors  : Raymond L King Sr.
 * ------------------------------------------------------------------------
 * 
 * Class        creditcard_helper
 * 
 * @project     Fx
 * @author      Raymond L King Sr.
 * @link        http://www.procoversfx.com
 * @copyright   Copyright (c) 2009 - 2015 Pro Covers FX, LLC.
 * @license     http://www.procoversfx.com/license
 * ------------------------------------------------------------------------
 */

/**
 * card_type ()
 * ------------------------------------------------------------------------
 *
 * Return  credit card type if card number is valid
 *
 * @param  $card_number string
 * @return string
 **/
if ( ! function_exists('card_type'))
{
    
/**
     * ------------------------------------------------------------------------
     * card_type ()
     * ------------------------------------------------------------------------
     *
     * @param  $card_number
     * @return string
     */
    
function card_type($card_number)
    {
        
$card_number preg_replace('/[^\d]/'''$card_number);

        if (
preg_match('/^3[47][0-9]{13}$/'$card_number))
        {
            return 
'American Express';
        }
        elseif (
preg_match('/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/'$card_number))
        {
            return 
'Diners Club';
        }
        elseif (
preg_match('/^6(?:011|5[0-9][0-9])[0-9]{12}$/'$card_number))
        {
            return 
'Discover';
        }
        elseif (
preg_match('/^(?:2131|1800|35\d{3})\d{11}$/'$card_number))
        {
            return 
'JCB';
        }
        elseif (
preg_match('/^5[1-5][0-9]{14}$/'$card_number))
        {
            return 
'MasterCard';
        }
        elseif (
preg_match('/^4[0-9]{12}(?:[0-9]{3})?$/'$card_number))
        {
            return 
'Visa';
        }
        else
        {
            return 
'Unknown';
        }
    }
}

/**
 * ------------------------------------------------------------------------
 * Filename: creditcard_helper.php
 * Location: ./application/helpers/creditcard_helper.php
 * ------------------------------------------------------------------------
 */ 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(This post was last modified: 02-25-2019, 11:58 PM by ciadmin. Edit Reason: inappropriate link )

From my point of view you can't do this as per the laws. **Link redacted**
Reply




Theme © iAndrew 2016 - Forum software by © MyBB