1 package FS::SignupClient;
4 use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket);
9 use Storable qw(nstore_fd fd_retrieve);
13 @ISA = qw( Exporter );
14 @EXPORT_OK = qw( signup_info new_customer );
16 $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket";
18 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
19 $ENV{'SHELL'} = '/bin/sh';
20 $ENV{'IFS'} = " \t\n";
23 $ENV{'BASH_ENV'} = '';
25 my $freeside_uid = scalar(getpwnam('freeside'));
26 die "not running as the freeside user\n" if $> != $freeside_uid;
30 FS::SignupClient - Freeside signup client API
34 use FS::SignupClient qw( signup_info new_customer );
36 ( $locales, $packages, $pops ) = signup_info;
38 $error = new_customer ( {
42 'comapny' => $company,
43 'address1' => $address1,
44 'address2' => $address2,
49 'country' => $country,
50 'daytime' => $daytime,
54 'payinfo' => $payinfo,
55 'paydate' => $paydate,
56 'payname' => $payname,
57 'invoicing_list' => $invoicing_list,
58 'referral_custnum' => $referral_custnum,
59 'pkgpart' => $pkgpart,
60 'username' => $username,
61 '_password' => $password,
62 'sec_phrase' => $sec_phrase,
68 This module provides an API for a remote signup server.
70 It needs to be run as the freeside user. Because of this, the program which
71 calls these subroutines should be written very carefully.
79 Returns three array references of hash references.
81 The first set of hash references is of allowable locales. Each hash reference
82 has the following keys:
88 The second set of hash references is of allowable packages. Each hash
89 reference has the following keys:
93 The third set of hash references is of allowable POPs (Points Of Presence).
94 Each hash reference has the following keys:
104 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
105 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
106 print SOCK "signup_info\n";
109 my $init_data = fd_retrieve(\*SOCK);
112 (map { $init_data->{$_} } qw( cust_main_county part_pkg svc_acct_pop ) ),
117 =item new_customer HASHREF
119 Adds a customer to the remote Freeside system. Requires a hash reference as
120 a paramater with the following keys:
146 Returns a scalar error message, or the empty string for success.
153 #things that aren't necessary in base class, but are for signup server
154 # return "Passwords don't match"
155 # if $hashref->{'_password'} ne $hashref->{'_password2'}
156 return "Empty password" unless $hashref->{'_password'};
157 return "No POP selected" unless $hashref->{'popnum'};
159 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
160 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
161 print SOCK "new_customer\n";
163 my $signup_data = { map { $_ => $hashref->{$_} } qw(
164 first last ss company address1 address2 city county state zip country
165 daytime night fax payby payinfo paydate payname invoicing_list
166 referral_custnum pkgpart username _password popnum
170 nstore_fd($signup_data, \*SOCK) or die "can't send customer signup: $!";
173 chop( my $error = <SOCK> );
183 L<fs_signupd>, L<FS::cust_main>