Merge branch 'FREESIDE_3_BRANCH' of ssh://git.freeside.biz/home/git/freeside into...
authorChristopher Burger <burgerc@freeside.biz>
Fri, 30 Nov 2018 14:24:49 +0000 (09:24 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Fri, 30 Nov 2018 14:24:49 +0000 (09:24 -0500)
FS/FS/cust_main/Import.pm
httemplate/misc/cust_main-import.cgi

index d7a66db..49d87f2 100644 (file)
@@ -16,6 +16,7 @@ use FS::svc_external;
 use FS::svc_phone;
 use FS::svc_hardware;
 use FS::part_referral;
+use Business::CreditCard 0.35;
 
 $DEBUG = 0;
 
@@ -98,6 +99,7 @@ sub process_batch_import {
       agentnum  => $param->{'agentnum'},
       refnum    => $param->{'refnum'},
       pkgpart   => $param->{'pkgpart'},
+      validate_cc => $param->{'validate_cc'},
       #'fields'  => [qw( cust_pkg.setup dayphone first last address1 address2
       #                 city state zip comments                          )],
       'format'  => $param->{'format'},
@@ -128,6 +130,7 @@ sub batch_import {
   my $agentnum  = $param->{agentnum};
   my $refnum    = $param->{refnum};
   my $pkgpart   = $param->{pkgpart};
+  my $validate_cc = $param->{validate_cc};
 
   my $format    = $param->{'format'};
 
@@ -431,6 +434,15 @@ sub batch_import {
         $cust_main{'payby'} = 'CARD';
 
         if ($cust_main{'payinfo'} =~ /^\s*([AD]?)(.*)\s*$/) {
+
+          ## validate credit card if requested
+          if ($validate_cc) {
+            validate($2)
+              or return "Invalid card($2) for customer ".$cust_main{'first'}." ".$cust_main{'last'};
+            return "Unknown card type for customer ".$cust_main{'first'}." ".$cust_main{'last'}
+              if cardtype($2) eq "Unknown";
+          }
+
           $cust_main{'payby'} = 'DCRD' if $1 eq 'D';
           $cust_main{'payinfo'} = $2;
         }
index 46d1536..20b5528 100644 (file)
@@ -42,6 +42,13 @@ Import a file containing customer records.
     </TD>
   </TR>
 
+  <& /elements/tr-checkbox.html,
+       'label' => 'Validate credit card',
+       'field' => 'validate_cc',
+       'id'    => 'validate_cc',
+       'value' => 'Y',
+  &>
+
   <% include( '/elements/file-upload.html',
                 'field' => 'file',
                 'label' => 'Filename',