[freeside-commits] branch FREESIDE_4_BRANCH updated. b4236044e83406ccfe7cf19d7689da1ebe4e6d7d

Jonathan Prykop jonathan at 420.am
Fri Jul 29 17:13:36 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  b4236044e83406ccfe7cf19d7689da1ebe4e6d7d (commit)
      from  4f5e4641c64227e3b2c5ef369abc405a64b7bed7 (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 b4236044e83406ccfe7cf19d7689da1ebe4e6d7d
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jul 26 23:46:01 2016 -0500

    RT#38881: BILL illegal payby in 4.x [update_payby]

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index d767e91..685821b 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1627,6 +1627,34 @@ sub insert_payby {
   
 }
 
+sub update_payby {
+  my $p = shift;
+
+  my($context, $session, $custnum) = _custoragent_session_custnum($p);
+  return { 'error' => $session } if $context eq 'error';
+
+  my $cust_payby = qsearchs('cust_payby', {
+                              'custnum'      => $custnum,
+                              'custpaybynum' => $p->{'custpaybynum'},
+                           })
+    or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} };
+
+  foreach my $field (
+    qw( weight payby payinfo paycvv paydate payname paystate paytype payip )
+  ) {
+    next unless exists($p->{$field});
+    $cust_payby->set($field,$p->{$field});
+  }
+
+  my $error = $cust_payby->replace;
+  if ( $error ) {
+    return { 'error' => $error };
+  } else {
+    return { 'custpaybynum' => $cust_payby->custpaybynum };
+  }
+  
+}
+
 sub verify_payby {
   my $p = shift;
 
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 2dea801..3ffb378 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -129,6 +129,7 @@ sub ss2clientapi {
   'list_invoices'             => 'MyAccount/list_invoices', #?
   'list_payby'                => 'MyAccount/list_payby',
   'insert_payby'              => 'MyAccount/insert_payby',
+  'update_payby'              => 'MyAccount/update_payby',
   'delete_payby'              => 'MyAccount/delete_payby',
   'cancel'                    => 'MyAccount/cancel',        #add to ss cgi!
   'payment_info'              => 'MyAccount/payment_info',
diff --git a/bin/xmlrpc-insert_payby b/bin/xmlrpc-insert_payby
new file mode 100755
index 0000000..9815d05
--- /dev/null
+++ b/bin/xmlrpc-insert_payby
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+use Getopt::Long;
+
+my( $email, $password ) = @ARGV;
+die "Usage: xmlrpc-insert_payby email password
+       [-w weight -b payby -i payinfo -c paycvv -d paydate -n payname -s paystate -t paytype -p payip]\n"
+  unless $email && length($password);
+
+my %opts;
+GetOptions(
+  "by=s"     => \$opts{'payby'},
+  "cvv=s"    => \$opts{'paycvv'},
+  "date=s"   => \$opts{'paydate'},
+  "info=s"   => \$opts{'payinfo'},
+  "name=s"   => \$opts{'payname'},
+  "payip=s"  => \$opts{'payip'},
+  "state=s"  => \$opts{'paystate'},
+  "type=s"   => \$opts{'paytype'},
+  "weight=i" => \$opts{'weight'},
+);
+
+foreach my $key (keys %opts) {
+  delete($opts{$key}) unless defined($opts{$key});
+}
+
+my $uri = new URI 'http://localhost:8080/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $login_result = $server->call(
+  'FS.ClientAPI_XMLRPC.login',
+    'email'    => $email,
+    'password' => $password,
+);
+die $login_result->{'error'}."\n" if $login_result->{'error'};
+
+my $call_result = $server->call(
+  'FS.ClientAPI_XMLRPC.insert_payby',
+    'session_id'   => $login_result->{'session_id'},
+    %opts,
+);
+die $call_result->{'error'}."\n" if $call_result->{'error'};
+
+print Dumper($call_result);
+print "Successfully inserted\n";
+
+1;
diff --git a/bin/xmlrpc-update_payby b/bin/xmlrpc-update_payby
new file mode 100755
index 0000000..75a1a8d
--- /dev/null
+++ b/bin/xmlrpc-update_payby
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+use Getopt::Long;
+
+my( $email, $password, $custpaybynum ) = @ARGV;
+die "Usage: xmlrpc-update_payby email password custpaybynum
+       [-w weight -b payby -i payinfo -c paycvv -d paydate -n payname -s paystate -t paytype -p payip]\n"
+  unless $email && length($password) && $custpaybynum;
+
+my %opts;
+GetOptions(
+  "by=s"     => \$opts{'payby'},
+  "cvv=s"    => \$opts{'paycvv'},
+  "date=s"   => \$opts{'paydate'},
+  "info=s"   => \$opts{'payinfo'},
+  "name=s"   => \$opts{'payname'},
+  "payip=s"  => \$opts{'payip'},
+  "state=s"  => \$opts{'paystate'},
+  "type=s"   => \$opts{'paytype'},
+  "weight=i" => \$opts{'weight'},
+);
+
+foreach my $key (keys %opts) {
+  delete($opts{$key}) unless defined($opts{$key});
+}
+
+my $uri = new URI 'http://localhost:8080/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $login_result = $server->call(
+  'FS.ClientAPI_XMLRPC.login',
+    'email'    => $email,
+    'password' => $password,
+);
+die $login_result->{'error'}."\n" if $login_result->{'error'};
+
+my $call_result = $server->call(
+  'FS.ClientAPI_XMLRPC.update_payby',
+    'session_id'   => $login_result->{'session_id'},
+    'custpaybynum' => $custpaybynum,
+    %opts,
+);
+die $call_result->{'error'}."\n" if $call_result->{'error'};
+
+print Dumper($call_result);
+print "Successfully updated\n";
+
+1;
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 30c1b43..b068c3b 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -50,6 +50,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'list_invoices'             => 'MyAccount/list_invoices', #?
   'list_payby'                => 'MyAccount/list_payby',
   'insert_payby'              => 'MyAccount/insert_payby',
+  'update_payby'              => 'MyAccount/update_payby',
   'delete_payby'              => 'MyAccount/delete_payby', 
   'cancel'                    => 'MyAccount/cancel',        #add to ss cgi!
   'payment_info'              => 'MyAccount/payment_info',
@@ -681,6 +682,16 @@ Optional IP address from which payment was submitted
 If there is an error, returns a hash reference with a single key, B<error>,
 otherwise returns a hash reference with a single key, B<custpaybynum>.
 
+=item update_payby HASHREF
+
+Updates stored payment information.  Takes a hash reference with the same
+keys as insert_payby, as well as B<custpaybynum> to specify which record
+to update.  All keys except B<session_id> and B<custpaybynum> are optional;
+if omitted, the previous values in the record will be preserved.
+
+If there is an error, returns a hash reference with a single key, B<error>,
+otherwise returns a hash reference with a single key, B<custpaybynum>.
+
 =item delete_payby HASHREF
 
 Removes stored payment information.  Takes a hash reference with two keys,

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                 |   28 ++++++++++++++
 FS/FS/ClientAPI_XMLRPC.pm                    |    1 +
 bin/xmlrpc-insert_payby                      |   52 +++++++++++++++++++++++++
 bin/xmlrpc-update_payby                      |   53 ++++++++++++++++++++++++++
 fs_selfservice/FS-SelfService/SelfService.pm |   11 ++++++
 5 files changed, 145 insertions(+)
 create mode 100755 bin/xmlrpc-insert_payby
 create mode 100755 bin/xmlrpc-update_payby




More information about the freeside-commits mailing list