summaryrefslogtreecommitdiff
path: root/bin/xmlrpc-update_payby
blob: 75a1a8da98750b734b544554cf2e974a56b08b9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;