[ic] Changing as subroutine

Howard Lowndes interchange-users@icdevgroup.org
Tue Feb 25 16:51:01 2003


On Tue, 25 Feb 2003, ACforSale Inc Sales Team wrote:

>  On Behalf Of Howard Lowndes
> I need to change the subroutine guess_cc_type in the Vend::Order module
> to 
> include another selector for Australian Bankcard.
> 
> Is it just a case of copying the (modified) subroutine into 
> interchange.cfg as a GlobalSub or into catalog.cfg as a Sub (and 
> restarting Interchange of course), or is there more to setting up 
> GlobalSub and Sub; IOW do I have to do other things to the subroutine?
> 
> I find the doco at 4.1 in the template guide is a bit esoteric.

I didn't get any success in setting up a replacement subroutine so I had 
to settle for mod'ng the Vend::Order module to suit Australian Bankcard.  
Here are the changes for what they are worth:

sub guess_cc_type {
        my ($ccnum) = @_;
        $ccnum =~ s/\D+//g;

        # based on logic by Karl Moore from http://www.vb-world.net/tips/tip509.html
        # Australian Bankcard added by Howard Lowndes http://lannet.com.au
        if ($ccnum eq '')                                       { '' }
        elsif ($ccnum =~ /^4(?:\d{12}|\d{15})$/)                { 'visa' }
        elsif ($ccnum =~ /^56\d{14}$/)                          { 'bankcard' }
        elsif ($ccnum =~ /^5[1-5]\d{14}$/)                      { 'mc' }
        elsif ($ccnum =~ /^6011\d{12}$/)                        { 'discover' }
        elsif ($ccnum =~ /^3[47]\d{13}$/)                       { 'amex' }
        elsif ($ccnum =~ /^3(?:6\d{12}|0[0-5]\d{11})$/)         { 'dinersclub' }
        elsif ($ccnum =~ /^38\d{12}$/)                          { 'carteblanche' }
        elsif ($ccnum =~ /^2(?:014|149)\d{11}$/)                { 'enroute' }
        elsif ($ccnum =~ /^(?:3\d{15}|2131\d{11}|1800\d{11})$/) { 'jcb' }
        else                                                    { 'other' }
}


-- 
Howard.
LANNet Computing Associates - Your Linux people <http://www.lannetlinux.com>
------------------------------------------
Flatter government, not fatter government - Get rid of the Australian states.
------------------------------------------
There are 10 types of people in the world, those who understand binary, 
and those who don't.