[ic] guess_cc_type(), does the 'test way' need to be changed ?
Mike Heins
mike at perusion.com
Wed Sep 14 09:18:52 EDT 2005
Quoting Mike Heins (mike at perusion.com):
> Quoting ns (linux at post10.tele.dk):
> > Hi, this is mostly for brainstorming...
> >
> > I did observe that Mike have changed the guess_cc_type() function to
> > cover more cards.
> >
> > Because we (here in DK) can charge different fees for different CC card,
> > like :
> >
> > - danish issued CC ( fee 1.95 + 0.1 %)
> > - danish issued visa electron (1.95 + 1.25)
> > - international issued CC's (1.95 + 5.5%)
[snip]
> > So, I was thinking of a new way to make this CC tests, like a lookup in
> > a table, but due to the use of prefixes like 405833 is also 'coveret' by
> > the rule /^4(?:\d{12}|\d{15})$/ , I can not se a 'easy' way to make
> > another way to make the test, else than expanging the existing routine..
>
> If I were to pick a way to change the source to do this, I would put at
> the top of the routine:
>
> if(my $subname = $Vend::Cfg->{SpecialSub}{guess_cc}) {
> my $sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
> my $guess;
> if( $sub and $guess = $sub->($ccnum) ) {
> return $guess;
> }
> }
>
> That would allow you to put your own routine before the existing one
> and
I guess I didn't finish that. I will now:
The above, in combination with this in catalog.cfg
## Map a subroutine to guess custom credit card types
SpecialSub guess_cc_type special_cc
Sub special_cc <<EOS
sub {
my $num = shift;
return 'foobar' if $num =~ /^41/;
return undef;
}
EOS
makes it possible to do this.
This is in CVS.
`
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
Light travels faster than sound. This is why some people appear bright
until you hear them speak. -- unknown
More information about the interchange-users
mailing list