RT# 75817 - removed change password link as it is not needed anymore
[freeside.git] / bin / xmlrpc-update_payby
1 #!/usr/bin/perl
2
3 use strict;
4 use Frontier::Client;
5 use Data::Dumper;
6
7 use Getopt::Long;
8
9 my( $email, $password, $custpaybynum ) = @ARGV;
10 die "Usage: xmlrpc-update_payby email password custpaybynum
11        [-w weight -b payby -i payinfo -c paycvv -d paydate -n payname -s paystate -t paytype -p payip]\n"
12   unless $email && length($password) && $custpaybynum;
13
14 my %opts;
15 GetOptions(
16   "by=s"     => \$opts{'payby'},
17   "cvv=s"    => \$opts{'paycvv'},
18   "date=s"   => \$opts{'paydate'},
19   "info=s"   => \$opts{'payinfo'},
20   "name=s"   => \$opts{'payname'},
21   "payip=s"  => \$opts{'payip'},
22   "state=s"  => \$opts{'paystate'},
23   "type=s"   => \$opts{'paytype'},
24   "weight=i" => \$opts{'weight'},
25 );
26
27 foreach my $key (keys %opts) {
28   delete($opts{$key}) unless defined($opts{$key});
29 }
30
31 my $uri = new URI 'http://localhost:8080/';
32
33 my $server = new Frontier::Client ( 'url' => $uri );
34
35 my $login_result = $server->call(
36   'FS.ClientAPI_XMLRPC.login',
37     'email'    => $email,
38     'password' => $password,
39 );
40 die $login_result->{'error'}."\n" if $login_result->{'error'};
41
42 my $call_result = $server->call(
43   'FS.ClientAPI_XMLRPC.update_payby',
44     'session_id'   => $login_result->{'session_id'},
45     'custpaybynum' => $custpaybynum,
46     %opts,
47 );
48 die $call_result->{'error'}."\n" if $call_result->{'error'};
49
50 print Dumper($call_result);
51 print "Successfully updated\n";
52
53 1;