RT# 81557 - Added checkbox to validate cc on import, and cc validation.
authorChristopher Burger <burgerc@freeside.biz>
Thu, 29 Nov 2018 19:49:24 +0000 (14:49 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Thu, 29 Nov 2018 19:49:24 +0000 (14:49 -0500)
FS/FS/cust_main/Import.pm
httemplate/misc/cust_main-import.cgi

index 9624529..dcedc16 100644 (file)
@@ -14,6 +14,7 @@ use FS::svc_external;
 use FS::svc_phone;
 use FS::svc_hardware;
 use FS::part_referral;
+use Business::CreditCard 0.35;
 
 $DEBUG = 0;
 
@@ -95,6 +96,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'},
@@ -125,6 +127,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'};
 
@@ -421,6 +424,14 @@ sub batch_import {
 
         delete $cust_main{'payinfo'};
 
+        ## 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_payby = new FS::cust_payby {
           'payby'   => ($1 eq 'D') ? 'DCRD' : 'CARD',
           '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',