[interchange-cvs] interchange - heins modified lib/Vend/Order.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Wed Sep 14 09:18:43 EDT 2005
User: heins
Date: 2005-09-14 13:18:42 GMT
Modified: lib/Vend Order.pm
Log:
* Add SpecialSub "guess_cc_type" to allow custom credit card types on a
per catalog basis.
* Calling parameters -- is passed the digits of the credit card number
as its only parameter (no spaces or non-word chars).
* If you know what type the number is, you return it and it is used as
the result. If not, return a false value to let the normal routine do
it's thing.
* To activate, do 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 'interchange_test' if $num =~ /^4111/;
return undef;
}
EOS
That will return "interchange_test" if the number begins with 4111
* Where I should document this I don't know. If someone suggests a home
and helps me find the actual document -- this is important -- I will
try. But I don't think finding the right file out of hundreds to do
the documentation in is not a really viable alternative.
Revision Changes Path
2.72 +10 -2 interchange/lib/Vend/Order.pm
rev 2.72, prev_rev 2.71
Index: Order.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.71
retrieving revision 2.72
diff -u -r2.71 -r2.72
--- Order.pm 9 Aug 2005 21:10:37 -0000 2.71
+++ Order.pm 14 Sep 2005 13:18:42 -0000 2.72
@@ -1,6 +1,6 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.71 2005/08/09 21:10:37 mheins Exp $
+# $Id: Order.pm,v 2.72 2005/09/14 13:18:42 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -29,7 +29,7 @@
package Vend::Order;
require Exporter;
-$VERSION = substr(q$Revision: 2.71 $, 10);
+$VERSION = substr(q$Revision: 2.72 $, 10);
@ISA = qw(Exporter);
@@ -643,6 +643,14 @@
sub guess_cc_type {
my ($ccnum) = @_;
$ccnum =~ s/\D+//g;
+
+ if(my $subname = $Vend::Cfg->{SpecialSub}{guess_cc_type}) {
+ my $sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
+ my $guess;
+ if( $sub and $guess = $sub->($ccnum) ) {
+ return $guess;
+ }
+ }
# based on logic by Karl Moore from http://www.vb-world.net/tips/tip509.html
if ($ccnum eq '') { '' }
More information about the interchange-cvs
mailing list