summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2008-07-21 22:34:35 +0000
committerivan <ivan>2008-07-21 22:34:35 +0000
commit533c1a26db76bcd486e36099da3976d7853ea46d (patch)
treed894261c443a9d8b178880d134b6665537fac9aa
parent4011d4876104367056d340f68697ff1a39ff810b (diff)
svc_phone signup
-rw-r--r--FS/FS/ClientAPI/Signup.pm20
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm23
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/signup.cgi74
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/signup.html11
-rw-r--r--fs_selfservice/FS-SelfService/cgi/success.html46
5 files changed, 136 insertions, 38 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index aeb0aaa..b8ed96a 100644
--- a/FS/FS/ClientAPI/Signup.pm
+++ b/FS/FS/ClientAPI/Signup.pm
@@ -421,7 +421,7 @@ sub new_customer {
my $svc;
if ( $svc_x eq 'svc_acct' ) {
- my $svc = new FS::svc_acct ( {
+ $svc = new FS::svc_acct ( {
'svcpart' => $svcpart,
map { $_ => $packet->{$_} }
qw( username _password sec_phrase popnum ),
@@ -444,10 +444,10 @@ sub new_customer {
} elsif ( $svc_x eq 'svc_phone' ) {
- my $svc = new FS::svc_phone ( {
+ $svc = new FS::svc_phone ( {
'svcpart' => $svcpart,
map { $_ => $packet->{$_} }
- qw( countrycode phonenum pin ),
+ qw( countrycode phonenum sip_password pin ),
} );
} else {
@@ -533,7 +533,19 @@ sub new_customer {
$error = $placeholder->delete;
return { 'error' => $error } if $error;
- return { error => '' };
+ my %return = ( 'error' => '',
+ 'signup_service' => $svc_x,
+ );
+
+ if ( $svc_x eq 'svc_acct' ) {
+ $return{$_} = $svc->$_() for qw( username _password );
+ } elsif ( $svc_x eq 'svc_phone' ) {
+ $return{$_} = $svc->$_() for qw( countrycode phonenum sip_password pin );
+ } else {
+ die "unknown signup service $svc_x";
+ }
+
+ return \%return;
}
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 6867fd8..0492b09 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -193,11 +193,16 @@ FS::SelfService - Freeside self-service API
'payname' => $payname,
'invoicing_list' => $invoicing_list,
'referral_custnum' => $referral_custnum,
+ 'agentnum' => $agentnum,
'pkgpart' => $pkgpart,
+
'username' => $username,
'_password' => $password,
'popnum' => $popnum,
- 'agentnum' => $agentnum,
+ #OR
+ 'countrycode' => 1,
+ 'phonenum' => $phonenum,
+ 'pin' => $pin,
}
);
@@ -973,6 +978,10 @@ comma-separated list of email addresses for email invoices. The special value '
referring customer number
+=item agentnum
+
+Agent number
+
=item pkgpart
pkgpart of initial package
@@ -993,9 +1002,17 @@ Security phrase
Access number (index, not the literal number)
-=item agentnum
+=item countrycode
-Agent number
+Country code (to be provisioned as a service)
+
+=item phonenum
+
+Phone number (to be provisioned as a service)
+
+=item pin
+
+Voicemail PIN
=back
diff --git a/fs_selfservice/FS-SelfService/cgi/signup.cgi b/fs_selfservice/FS-SelfService/cgi/signup.cgi
index 62a36a8..47857f0 100755
--- a/fs_selfservice/FS-SelfService/cgi/signup.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/signup.cgi
@@ -165,6 +165,7 @@ if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
$cgi->param('invoicing_list' => 'POST' );
}
+ #if ( $svc_x eq 'svc_acct' ) {
if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
$error = $init_data->{msgcat}{passwords_dont_match}; #msgcat
$cgi->param('_password', '');
@@ -188,8 +189,9 @@ if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
$error ||= $init_data->{msgcat}{illegal_or_empty_text};
}
+ my $rv = '';
unless ( $error ) {
- my $rv = new_customer( {
+ $rv = new_customer( {
( map { $_ => scalar($cgi->param($_)) }
qw( last first ss company
address1 address2 city county state zip country
@@ -202,8 +204,9 @@ if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
payby payinfo paycvv paydate payname paystate paytype
invoicing_list referral_custnum promo_code reg_code
- pkgpart username sec_phrase _password popnum refnum
- agentnum
+ pkgpart refnum agentnum
+ username sec_phrase _password popnum
+ countrycode phonenum sip_password pin
),
grep { /^snarf_/ } $cgi->param
),
@@ -223,6 +226,7 @@ if ( ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
} else {
print_okay(
'pkgpart' => scalar($cgi->param('pkgpart')),
+ %$rv,
);
}
@@ -263,12 +267,30 @@ sub print_okay {
my %param = @_;
my $user_agent = new HTTP::BrowserDetect $ENV{HTTP_USER_AGENT};
- $cgi->param('username') =~ /^(.+)$/
- or die "fatal: invalid username got past FS::SelfService::new_customer";
- my $username = $1;
- $cgi->param('_password') =~ /^(.+)$/
- or die "fatal: invalid password got past FS::SelfService::new_customer";
- my $password = $1;
+ my( $username, $password ) = ( '', '' );
+ my( $countrycode, $phonenum, $sip_password, $pin ) = ( '', '', '', '' );
+
+ my $svc_x = $param{signup_service} || 'svc_acct'; #just in case
+ if ( $svc_x eq 'svc_acct' ) {
+
+ $cgi->param('username') =~ /^(.+)$/
+ or die "fatal: invalid username got past FS::SelfService::new_customer";
+ $username = $1;
+ $cgi->param('_password') =~ /^(.+)$/
+ or die "fatal: invalid password got past FS::SelfService::new_customer";
+ $password = $1;
+
+ } elsif ( $svc_x eq 'svc_phone' ) {
+
+ $countrycode = $param{countrycode};
+ $phonenum = $param{phonenum};
+ $sip_password = $param{sip_password};
+ $pin = $param{pin};
+
+ } else {
+ die "unknown signup service $svc_x";
+ }
+
( $cgi->param('first'). ' '. $cgi->param('last') ) =~ /^(.*)$/
or die "fatal: invalid email_name got past FS::SelfService::new_customer";
my $email_name = $1; #global for template
@@ -296,23 +318,39 @@ sub print_okay {
my $pkg = $part_pkg->{'pkg'};
if ( $ieak_template && $user_agent->windows && $user_agent->ie ) {
+
#send an IEAK config
print $cgi->header('application/x-Internet-signup'),
$ieak_template->fill_in();
+
} else { #send a simple confirmation
+
print $cgi->header( '-expires' => 'now' ),
$success_template->fill_in( HASH => {
- username => $username,
- password => $password,
- _password => $password,
- email_name => $email_name,
- ac => $ac,
- exch => $exch,
- loc => $loc,
- pkg => $pkg,
- part_pkg => \$part_pkg,
+
+ email_name => $email_name,
+ pkg => $pkg,
+ part_pkg => \$part_pkg,
+
+ signup_service => $svc_x,
+
+ #for svc_acct
+ username => $username,
+ password => $password,
+ _password => $password,
+ ac => $ac, #for dialup POP
+ exch => $exch, #
+ loc => $loc, #
+
+ #for svc_phone
+ countrycode => $countrycode,
+ phonenum => $phonenum,
+ sip_password => $sip_password,
+ pin => $pin,
+
});
}
+
}
sub success_default { #html to use if you don't specify a success file
diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html
index 9dcf01f..29078e2 100755
--- a/fs_selfservice/FS-SelfService/cgi/signup.html
+++ b/fs_selfservice/FS-SelfService/cgi/signup.html
@@ -25,7 +25,7 @@
%>
<%=
- $OUT = join("\n", map { qq|<input type="hidden" name="$_" />| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum / );
+ $OUT = join("\n", map { qq|<input type="hidden" name="$_" />| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum countrycode phonenum sip_password pin / );
%>
Where did you hear about our service? <SELECT NAME="refnum">
@@ -362,10 +362,11 @@ function fixup_form() {
// Copy signup details to OneTrueForm
- var signup_elements = new Array ( 'promo_code', 'reg_code',
- 'pkgpart', 'username',
- '_password', '_password2',
- 'sec_phrase', 'popnum' );
+ var signup_elements = new Array (
+ 'promo_code', 'reg_code', 'pkgpart',
+ 'username', '_password', '_password2', 'sec_phrase', 'popnum',
+ 'countrycode', 'phonenum', 'sip_password', 'pin'
+ );
for ( ii = 0 ; ii < signup_elements.length ; ii ++ ) {
copyelement ( document.signup_form.elements[signup_elements[ii]],
diff --git a/fs_selfservice/FS-SelfService/cgi/success.html b/fs_selfservice/FS-SelfService/cgi/success.html
index 397cc6c..92185c3 100644
--- a/fs_selfservice/FS-SelfService/cgi/success.html
+++ b/fs_selfservice/FS-SelfService/cgi/success.html
@@ -1,11 +1,41 @@
-<HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
-<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
-Thanks for signing up!
+<HTML>
+
+<HEAD>
+ <TITLE>Signup successful</TITLE>
+</HEAD>
+
+<BODY BGCOLOR="#e8e8e8">
+
+<FONT SIZE=7>Signup successful</FONT><BR><BR>
+
+Thanks for signing up! Save this information for future reference.
<BR><BR>
+
Signup information for <%= $email_name %>:
<BR><BR>
-Username: <%= $username %><BR>
-Password: <%= $password %><BR>
-Access number: (<%= $ac %>) / <%= $exch %> - <%= $local %><BR>
-Package: <%= $pkg %><BR>
-</BODY></HTML>
+
+<%=
+ if ($signup_service eq 'svc_acct' || !$signup_service ) { #just in case
+ $OUT .= <<END
+ Username: $username<BR>
+ Password: $password><BR>
+ Access number: ($ac) / $exch - $local <BR>
+END
+ } elsif ( $signup_service eq 'svc_phone' ) {
+ $OUT .= <<END
+ <!-- Countrycode: $countrycode <BR>-->
+ Phone number: $phonenum<BR>
+ SIP Server: itsp.sip.server.name<BR>
+ SIP Login: $phonenum<BR>
+ SIP Password: $sip_password<BR>
+ Voicemail PIN: $pin<BR>
+END
+ } else {
+ die "unknown signup service $signup_service";
+ }
+%>
+
+ Package: <%= $pkg %><BR>
+
+</BODY>
+</HTML>