[freeside-commits] branch master updated. ee27cd8eea7b135db2ba8a6b1a6ac8933171d9d0

Christopher Burger burgerc at 420.am
Mon Oct 9 11:36:42 PDT 2017


The branch, master has been updated
       via  ee27cd8eea7b135db2ba8a6b1a6ac8933171d9d0 (commit)
      from  b9c2b7cc73ad6455613268ae9e884ca0d34a127d (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 ee27cd8eea7b135db2ba8a6b1a6ac8933171d9d0
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Oct 9 14:36:07 2017 -0400

    RT# 77193 - fixed error when inserting new ach payby thru selfservice on V4.  Now works

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 30ab96b..e28aa18 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1675,14 +1675,15 @@ sub insert_payby {
 
   #XXX payinfo1 + payinfo2 for CHEK?
   #or take the opportunity to use separate, more well- named fields?
-  # my $payinfo;
-  # $p->{'payinfo1'} =~ /^([\dx]+)$/
-  #   or return { 'error' => "illegal account number ". $p->{'payinfo1'} };
-  # my $payinfo1 = $1;
-  #  $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ?
-  #   or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} };
-  # my $payinfo2 = $1;
-  # $payinfo = $payinfo1. '@'. $payinfo2;
+   if ($p->{'payby'} eq 'CHEK') {
+     $p->{'payinfo1'} =~ /^([\dx]+)$/
+       or return { 'error' => "illegal account number ". $p->{'payinfo1'} };
+     my $payinfo1 = $1;
+      $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ?
+       or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} };
+     my $payinfo2 = $1;
+     $p->{'payinfo'} = $payinfo1. '@'. $payinfo2;
+   }
 
   my $cust_payby = new FS::cust_payby {
     'custnum' => $custnum,
diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm
index fd90597..704741f 100644
--- a/FS/FS/cust_payby.pm
+++ b/FS/FS/cust_payby.pm
@@ -159,8 +159,9 @@ sub insert {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  my $error =  $self->check_payinfo_cardtype
-            || $self->SUPER::insert;
+  my $error =  $self->check_payinfo_cardtype if $self->payby =~/^(CARD|DCRD)$/;
+  $self->SUPER::insert unless $error;
+
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index f194746..6cf264c 100755
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -337,6 +337,32 @@ sub _process_change_payby {
   }
 }
 
+sub _process_insert_payby {
+  my ($erroraction, @fields) = @_;
+
+  my $results = '';
+
+  $results ||= insert_payby (
+    'session_id' => $session_id,
+    map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields,
+  );
+
+  ## check error
+
+
+  if ( $results->{'error'} ) {
+    no strict 'refs';
+    $action = $erroraction;
+    return {
+      $cgi->Vars,
+      %{&$action()},
+      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+    };
+  } else {
+    return $results;
+  }
+}
+
 sub process_change_bill {
         _process_change_info( 'change_bill', 
           qw( first last company address1 address2 city state
@@ -389,20 +415,20 @@ sub process_change_creditcard_pay {
               address1 address2 city county state zip country auto paytype
               paystate ss stateid stateid_state invoicing_list
             );
-
-        _process_change_payby( 'change_creditcard_pay', @list );
+        if ($cgi->param( 'custpaybynum' )) { _process_change_payby( 'change_creditcard_pay', @list ); }
+        else { _process_insert_payby( 'change_creditcard_pay', @list ); }
 }
 
 sub process_change_check_pay {
         my $payby  = $cgi->param( 'payby' );
-        $cgi->param('paydate', $cgi->param('year') . '-' . $cgi->param('month') . '-01');
+        #$cgi->param('paydate', '2039-12-01');
         my @list =
           qw( payby payinfo payinfo1 payinfo2 paydate payname custpaybynum 
               address1 address2 city county state zip country auto paytype
               paystate ss stateid stateid_state invoicing_list
             );
-
-        _process_change_payby( 'change_check_pay', @list );
+        if ($cgi->param( 'custpaybynum' )) { _process_change_payby( 'change_check_pay', @list ); }
+        else { _process_insert_payby( 'change_check_pay', @list ); }
 }
 
 sub view_invoice {

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                      |   17 +++++-----
 FS/FS/cust_payby.pm                               |    5 +--
 fs_selfservice/FS-SelfService/cgi/selfservice.cgi |   36 ++++++++++++++++++---
 3 files changed, 43 insertions(+), 15 deletions(-)




More information about the freeside-commits mailing list