1 package FS::SelfService;
4 use vars qw($VERSION @ISA @EXPORT_OK $socket %autoload );
10 use Storable qw(nstore_fd fd_retrieve);
14 @ISA = qw( Exporter );
16 $socket = "/usr/local/freeside/selfservice_socket";
19 'passwd' => 'passwd/passwd',
20 'chfn' => 'passwd/passwd',
21 'chsh' => 'passwd/passwd',
22 'login' => 'MyAccount/login',
23 'customer_info' => 'MyAccount/customer_info',
24 'invoice' => 'MyAccount/invoice',
25 'start' => 'MyAccount/start',
26 'update' => 'MyAccount/update',
27 'collect' => 'MyAccount/collect',
28 'cancel' => 'MyAccount/cancel',
29 'uncancel' => 'MyAccount/uncancel',
30 'getinfo' => 'MyAccount/getinfo',
31 'charge' => 'MyAccount/charge',
32 'new_customer' => 'MyAccount/new_customer',
35 @EXPORT_OK = keys %autoload;
37 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
38 $ENV{'SHELL'} = '/bin/sh';
39 $ENV{'IFS'} = " \t\n";
42 $ENV{'BASH_ENV'} = '';
44 my $freeside_uid = scalar(getpwnam('freeside'));
45 die "not running as the freeside user\n" if $> != $freeside_uid;
49 FS::SelfService - Freeside self-service API
55 Use this API to implement your own client "self-service" module.
57 If you just want to customize the look of the existing "self-service" module,
66 Returns the empty value on success, or an error message on errors.
70 foreach my $autoload ( keys %autoload ) {
81 $param->{_packet} = \''. $autoload{$autoload}. '\';
83 simple_packet($param);
93 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
94 connect(SOCK, sockaddr_un($socket)) or die "connect: $!";
95 nstore_fd($packet, \*SOCK) or die "can't send packet: $!";
98 #shoudl trap: Magic number checking on storable file failed at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/fd_retrieve.al) line 337, at /usr/local/share/perl/5.6.1/FS/SelfService.pm line 71
100 #block until there is a message on socket
101 # my $w = new IO::Select;
103 # my @wait = $w->can_read;
104 my $return = fd_retrieve(\*SOCK) or die "error reading result: $!";
105 die $return->{'_error'} if defined $return->{_error} && $return->{_error};
116 L<freeside-selfservice-clientd>, L<freeside-selfservice-server>