[freeside-commits] branch FREESIDE_4_BRANCH updated. 8fbd52b17789117befa7a3a69d330ec6112d769c

Christopher Burger burgerc at freeside.biz
Thu Nov 29 13:03:16 PST 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  8fbd52b17789117befa7a3a69d330ec6112d769c (commit)
      from  bc7104ea4d6c2e9efe7a1fb4460e2ed71b5e911a (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 8fbd52b17789117befa7a3a69d330ec6112d769c
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu Nov 29 14:49:24 2018 -0500

    RT# 81557 - Added checkbox to validate cc on import, and cc validation.

diff --git a/FS/FS/cust_main/Import.pm b/FS/FS/cust_main/Import.pm
index 9624529fa..dcedc16b1 100644
--- a/FS/FS/cust_main/Import.pm
+++ b/FS/FS/cust_main/Import.pm
@@ -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,
diff --git a/httemplate/misc/cust_main-import.cgi b/httemplate/misc/cust_main-import.cgi
index 46d15363d..20b5528d8 100644
--- a/httemplate/misc/cust_main-import.cgi
+++ b/httemplate/misc/cust_main-import.cgi
@@ -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',

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

Summary of changes:
 FS/FS/cust_main/Import.pm            | 11 +++++++++++
 httemplate/misc/cust_main-import.cgi |  7 +++++++
 2 files changed, 18 insertions(+)




More information about the freeside-commits mailing list