1 package FS::SignupClient;
4 use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket);
12 @ISA = qw( Exporter );
13 @EXPORT_OK = qw( signup_info new_customer );
15 $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket";
17 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
18 $ENV{'SHELL'} = '/bin/sh';
19 $ENV{'IFS'} = " \t\n";
22 $ENV{'BASH_ENV'} = '';
24 my $freeside_uid = scalar(getpwnam('freeside'));
25 die "not running as the freeside user\n" if $> != $freeside_uid;
29 FS::SignupClient - Freeside signup client API
33 use FS::SignupClient qw( signup_info new_customer );
35 ( $locales, $packages, $pops ) = signup_info;
37 $error = new_customer ( {
41 'comapny' => $company,
42 'address1' => $address1,
43 'address2' => $address2,
48 'country' => $country,
49 'daytime' => $daytime,
53 'payinfo' => $payinfo,
54 'paydate' => $paydate,
55 'payname' => $payname,
56 'invoicing_list' => $invoicing_list,
57 'referral_custnum' => $referral_custnum,
58 'pkgpart' => $pkgpart,
59 'username' => $username,
60 '_password' => $password,
66 This module provides an API for a remote signup server.
68 It needs to be run as the freeside user. Because of this, the program which
69 calls these subroutines should be written very carefully.
77 Returns three array references of hash references.
79 The first set of hash references is of allowable locales. Each hash reference
80 has the following keys:
86 The second set of hash references is of allowable packages. Each hash
87 reference has the following keys:
91 The third set of hash references is of allowable POPs (Points Of Presence).
92 Each hash reference has the following keys:
102 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
103 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
104 print SOCK "signup_info\n";
107 chop ( my $n_cust_main_county = <SOCK> );
108 my @cust_main_county = map {
109 chop ( my $taxnum = <SOCK> );
110 chop ( my $state = <SOCK> );
111 chop ( my $county = <SOCK> );
112 chop ( my $country = <SOCK> );
117 'country' => $country,
119 } 1 .. $n_cust_main_county;
121 chop ( my $n_part_pkg = <SOCK> );
123 chop ( my $pkgpart = <SOCK> );
124 chop ( my $pkg = <SOCK> );
126 'pkgpart' => $pkgpart,
131 chop ( my $n_svc_acct_pop = <SOCK> );
132 my @svc_acct_pop = map {
133 chop ( my $popnum = <SOCK> );
134 chop ( my $city = <SOCK> );
135 chop ( my $state = <SOCK> );
136 chop ( my $ac = <SOCK> );
137 chop ( my $exch = <SOCK> );
138 chop ( my $loc = <SOCK> );
147 } 1 .. $n_svc_acct_pop;
151 \@cust_main_county, \@part_pkg, \@svc_acct_pop;
154 =item new_customer HASHREF
156 Adds a customer to the remote Freeside system. Requires a hash reference as
157 a paramater with the following keys:
183 Returns a scalar error message, or the empty string for success.
190 #things that aren't necessary in base class, but are for signup server
191 return "Empty password" unless $hashref->{'_password'};
192 return "No POP selected" unless $hashref->{'popnum'};
194 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
195 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
196 print SOCK "new_customer\n";
198 print SOCK join("\n", map { $hashref->{$_} } qw(
199 first last ss company address1 address2 city county state zip country
200 daytime night fax payby payinfo paydate payname invoicing_list
201 referral_custnum pkgpart username _password popnum
205 chop( my $error = <SOCK> );
215 L<fs_signupd>, L<FS::SignupServer>, L<FS::cust_main>