[freeside-commits] branch master updated. ffb9519f06c7f6fc3d5c333d69993aed7fedea69

Ivan ivan at 420.am
Tue Jan 26 20:19:33 PST 2016


The branch, master has been updated
       via  ffb9519f06c7f6fc3d5c333d69993aed7fedea69 (commit)
      from  c4e788ef6f21b5a8582a1005512a15ba2f022945 (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 ffb9519f06c7f6fc3d5c333d69993aed7fedea69
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jan 26 20:19:29 2016 -0800

    respect card-types config in backend (new customer payment types / 3.x), RT#39861

diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 0c109ce..9e0db29 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -31,7 +31,7 @@ use Business::CreditCard 0.28;
 use FS::UID qw( dbh driver_name );
 use FS::Record qw( qsearchs qsearch dbdef regexp_sql );
 use FS::Cursor;
-use FS::Misc qw( generate_ps do_print money_pretty );
+use FS::Misc qw( generate_ps do_print money_pretty card_types );
 use FS::Msgcat qw(gettext);
 use FS::CurrentUser;
 use FS::TicketSystem;
@@ -468,7 +468,8 @@ sub insert {
   $self->auto_agent_custid()
     if $conf->config('cust_main-auto_agent_custid') && ! $self->agent_custid;
 
-  my $error = $self->SUPER::insert;
+  my $error =  $self->check_payinfo_cardtype
+            || $self->SUPER::insert;
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     #return "inserting cust_main record (transaction rolled back): $error";
@@ -1354,6 +1355,14 @@ sub replace {
          || $old->payby  =~ /^(CHEK|DCHK)$/ && $self->payby =~ /^(CHEK|DCHK)$/ )
     && ( $old->payinfo eq $self->payinfo || $old->paymask eq $self->paymask );
 
+  if (    $self->payby =~ /^(CARD|DCRD)$/
+       && $old->payinfo ne $self->payinfo
+       && $old->paymask ne $self->paymask )
+  {
+    my $error = $self->check_payinfo_cardtype;
+    return $error if $error;
+  }
+
   return "Invoicing locale is required"
     if $old->locale
     && ! $self->locale
@@ -2092,6 +2101,25 @@ sub check {
   $self->SUPER::check;
 }
 
+sub check_payinfo_cardtype {
+  my $self = shift;
+
+  return '' unless $self->payby =~ /^(CARD|CHEK)$/;
+
+  my $payinfo = $self->payinfo;
+  $payinfo =~ s/\D//g;
+
+  return '' if $payinfo =~ /^99\d{14}$/; #token
+
+  my %bop_card_types = map { $_=>1 } values %{ card_types() };
+  my $cardtype = cardtype($payinfo);
+
+  return "$cardtype not accepted" unless $bop_card_types{$cardtype};
+
+  '';
+
+}
+
 =item replace_check
 
 Additional checks for replace only.

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

Summary of changes:
 FS/FS/cust_main.pm |   32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list