[freeside-commits] branch FREESIDE_4_BRANCH updated. 889c731e26608ffca1582fe57657e35711fd18b8

Mitch Jackson mitch at freeside.biz
Sun Dec 9 13:51:49 PST 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  889c731e26608ffca1582fe57657e35711fd18b8 (commit)
       via  fbe36a956f6e39078c926b8dbbf5d1afca5ea2ea (commit)
      from  72cbcafac03e83c15adebac5974cf5322cfcb488 (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 889c731e26608ffca1582fe57657e35711fd18b8
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Mon Jun 11 18:37:13 2018 -0500

    RT# 80514 Selfservice can update ssn/stateid payment info

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 5c850301b..a3198611d 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1735,9 +1735,6 @@ sub update_payby {
     $p->{paydate} = $p->{year} . '-' . $p->{month} . '-01' unless $p->{paydate};
   }
 
-  # Perform update within a transaction
-  local $FS::UID::AutoCommit = 0;
-
   my $cust_payby = qsearchs('cust_payby', {
                               'custnum'      => $custnum,
                               'custpaybynum' => $p->{'custpaybynum'},
@@ -1754,26 +1751,23 @@ sub update_payby {
     $cust_payby->set($field,$p->{$field});
   }
 
-  my $error = $cust_payby->replace;
+  # Update column if given a value, and the given value wasn't
+  # the value generated by $cust_main->masked($column);
+  $cust_main->set( $_, $p->{$_} )
+    for grep{ $p->{$_} !~ /^x/i; }
+        grep{ exists $p->{$_} }
+        qw/ss stateid/;
 
-  if (!$error) {
-    my $is_changed = 0;
-    for my $field ( qw/ss stateid/ ) {
-      next if !exists $p->{$field} || $p->{$field} =~ /^x/i;
-      $cust_main->set( $field, $p->{$field} );
-      $is_changed = 1;
-    }
-    $error = $cust_main->replace if $is_changed;
-  }
+  # Perform updates within a transaction
+  local $FS::UID::AutoCommit = 0;
 
-  if ( $error ) {
+  if ( my $error = $cust_payby->replace || $cust_main->replace ) {
     dbh->rollback;
-    return { 'error' => $error };
-  } else {
-    dbh->commit;
-    return { 'custpaybynum' => $cust_payby->custpaybynum };
+    return { error => $error };
   }
-  
+
+  dbh->commit;
+  return { custpaybynum => $cust_payby->custpaybynum };
 }
 
 sub verify_payby {

commit fbe36a956f6e39078c926b8dbbf5d1afca5ea2ea
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Mon Jun 11 15:06:50 2018 -0500

    RT# 80514 Selfservice can update ssn/stateid payment info

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 05bc6d769..5c850301b 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1735,12 +1735,18 @@ sub update_payby {
     $p->{paydate} = $p->{year} . '-' . $p->{month} . '-01' unless $p->{paydate};
   }
 
+  # Perform update within a transaction
+  local $FS::UID::AutoCommit = 0;
+
   my $cust_payby = qsearchs('cust_payby', {
                               'custnum'      => $custnum,
                               'custpaybynum' => $p->{'custpaybynum'},
                            })
     or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} };
 
+  my $cust_main = qsearchs( 'cust_main', {custnum => $cust_payby->custnum} )
+    or return { 'error' => 'unknown custnum '.$cust_payby->custnum };
+
   foreach my $field (
     qw( weight payby payinfo paycvv paydate payname paystate paytype payip )
   ) {
@@ -1749,9 +1755,22 @@ sub update_payby {
   }
 
   my $error = $cust_payby->replace;
+
+  if (!$error) {
+    my $is_changed = 0;
+    for my $field ( qw/ss stateid/ ) {
+      next if !exists $p->{$field} || $p->{$field} =~ /^x/i;
+      $cust_main->set( $field, $p->{$field} );
+      $is_changed = 1;
+    }
+    $error = $cust_main->replace if $is_changed;
+  }
+
   if ( $error ) {
+    dbh->rollback;
     return { 'error' => $error };
   } else {
+    dbh->commit;
     return { 'custpaybynum' => $cust_payby->custpaybynum };
   }
   

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list