[freeside-commits] branch master updated. ed87c04490375c6663843f8065e69a7690939b18

Mitch Jackson mitch at freeside.biz
Mon Jun 11 16:38:05 PDT 2018


The branch, master has been updated
       via  ed87c04490375c6663843f8065e69a7690939b18 (commit)
      from  8b8d621a1bb4e9abaa1f0edab5190d302e6a6e99 (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 ed87c04490375c6663843f8065e69a7690939b18
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 f82787482..60a70fddc 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1727,9 +1727,6 @@ sub update_payby {
      $p->{'payinfo'} = $payinfo1. '@'. $payinfo2;
    }
 
-  # Perform update within a transaction
-  local $FS::UID::AutoCommit = 0;
-
   my $cust_payby = qsearchs('cust_payby', {
                               'custnum'      => $custnum,
                               'custpaybynum' => $p->{'custpaybynum'},
@@ -1746,26 +1743,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 {

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

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




More information about the freeside-commits mailing list