}
+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;
'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',
--- /dev/null
+#!/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;
--- /dev/null
+#!/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;
'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',
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,