[freeside-commits] branch master updated. 5d1f486c543c2e61cea6c050bed86c0c9815085e

Mark Wells mark at 420.am
Thu Oct 3 17:31:04 PDT 2013


The branch, master has been updated
       via  5d1f486c543c2e61cea6c050bed86c0c9815085e (commit)
      from  83a88f9294aa7db638e316df1ed0964901cdb370 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5d1f486c543c2e61cea6c050bed86c0c9815085e
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Oct 3 17:29:21 2013 -0700

    clean up some cust_payby upgrade issues, #23741

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 4d5b6bf..f0f2b46 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5520,6 +5520,13 @@ and customer address. Include units.',
     'type'        => 'text',
   },
 
+  {
+    'key'         => 'allow_invalid_cards',
+    'section'     => '',
+    'description' => 'Accept invalid credit card numbers.  Useful for testing with fictitious customers.  There is no good reason to enable this in production.',
+    'type'        => 'checkbox',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 13b0150..3403dc4 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -17,6 +17,7 @@ use vars qw( $DEBUG $me $conf
              @encrypted_fields
              $import
              $ignore_expired_card $ignore_banned_card $ignore_illegal_zip
+             $ignore_invalid_card
              $skip_fuzzyfiles
              @paytypes
            );
@@ -89,6 +90,7 @@ $me = '[FS::cust_main]';
 $import = 0;
 $ignore_expired_card = 0;
 $ignore_banned_card = 0;
+$ignore_invalid_card = 0;
 
 $skip_fuzzyfiles = 0;
 
@@ -102,6 +104,7 @@ sub nohistory_fields { ('payinfo', 'paycvv'); }
 install_callback FS::UID sub { 
   $conf = new FS::Conf;
   #yes, need it for stuff below (prolly should be cached)
+  $ignore_invalid_card = $conf->exists('allow_invalid_cards');
 };
 
 sub _cache {
@@ -1826,7 +1829,8 @@ sub check {
 
   # Need some kind of global flag to accept invalid cards, for testing
   # on scrubbed data.
-  if ( !$import && $check_payinfo && $self->payby =~ /^(CARD|DCRD)$/ ) {
+  if ( !$import && !$ignore_invalid_card && $check_payinfo && 
+    $self->payby =~ /^(CARD|DCRD)$/ ) {
 
     my $payinfo = $self->payinfo;
     $payinfo =~ s/\D//g;
@@ -1898,7 +1902,8 @@ sub check {
       $self->payissue('');
     }
 
-  } elsif ( $check_payinfo && $self->payby =~ /^(CHEK|DCHK)$/ ) {
+  } elsif ( !$ignore_invalid_card && $check_payinfo && 
+    $self->payby =~ /^(CHEK|DCHK)$/ ) {
 
     my $payinfo = $self->payinfo;
     $payinfo =~ s/[^\d\@\.]//g;
@@ -5125,13 +5130,13 @@ sub _upgrade_data { #class method
       die $error if $error;
 
       $cust_main->setfield($_, '') foreach @payfields;
-      $DEBUG = 2;
+      #$DEBUG = 2;
       $error = $cust_main->replace;
       die $error if $error;
 
     };
 
-    FS::upgrade_journal->set_done('cust_main__trimspaces');
+    FS::upgrade_journal->set_done('cust_main__cust_payby');
   }
 
   $class->_upgrade_otaker(%opts);
diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm
index 5914ab5..d78c574 100644
--- a/FS/FS/cust_payby.pm
+++ b/FS/FS/cust_payby.pm
@@ -7,9 +7,11 @@ use FS::Record qw( qsearchs ); #qsearch;
 use FS::payby;
 use FS::cust_main;
 use Business::CreditCard qw( validate cardtype );
+use FS::Msgcat qw( gettext );
 
 use vars qw( $conf @encrypted_fields
              $ignore_expired_card $ignore_banned_card
+             $ignore_invalid_card
            );
 
 @encrypted_fields = ('payinfo', 'paycvv');
@@ -17,10 +19,12 @@ sub nohistory_fields { ('payinfo', 'paycvv'); }
 
 $ignore_expired_card = 0;
 $ignore_banned_card = 0;
+$ignore_invalid_card = 0;
 
 install_callback FS::UID sub { 
   $conf = new FS::Conf;
   #yes, need it for stuff below (prolly should be cached)
+  $ignore_invalid_card = $conf->exists('allow_invalid_cards');
 };
 
 =head1 NAME
@@ -197,7 +201,8 @@ sub check {
   # Need some kind of global flag to accept invalid cards, for testing
   # on scrubbed data.
   #XXX if ( !$import && $check_payinfo && $self->payby =~ /^(CARD|DCRD)$/ ) {
-  if ( $check_payinfo && $self->payby =~ /^(CARD|DCRD)$/ ) {
+  if ( !$ignore_invalid_card && 
+    $check_payinfo && $self->payby =~ /^(CARD|DCRD)$/ ) {
 
     my $payinfo = $self->payinfo;
     $payinfo =~ s/\D//g;
@@ -269,7 +274,8 @@ sub check {
       $self->payissue('');
     }
 
-  } elsif ( $check_payinfo && $self->payby =~ /^(CHEK|DCHK)$/ ) {
+  } elsif ( !$ignore_invalid_card && 
+    $check_payinfo && $self->payby =~ /^(CHEK|DCHK)$/ ) {
 
     my $payinfo = $self->payinfo;
     $payinfo =~ s/[^\d\@\.]//g;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm       |    7 +++++++
 FS/FS/cust_main.pm  |   13 +++++++++----
 FS/FS/cust_payby.pm |   10 ++++++++--
 3 files changed, 24 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list