#!/usr/bin/perl -Tw
#
-# $Id: signup.cgi,v 1.26 2002-04-20 00:48:17 ivan Exp $
+# $Id: signup.cgi,v 1.27 2002-04-25 12:03:15 ivan Exp $
use strict;
use vars qw( @payby $cgi $locales $packages $pops $init_data $error
$pkgpart $username $password $password2 $sec_phrase $popnum
$agentnum
$ieak_file $ieak_template $cck_file $cck_template
- $signup_html $signup_template $success_html $success_template
+ $signup_html $signup_template
+ $success_html $success_template
+ $decline_html $decline_template
$ac $exch $loc
$email_name $pkg
$self_url
);
-use subs qw( print_form print_okay expselect signup_default success_default );
+use subs qw( print_form print_okay print_decline
+ signup_default success_default decline_default
+ expselect );
use CGI;
#use CGI::Carp qw(fatalsToBrowser);
use Text::Template;
$success_html = -e 'success.html'
? 'success.html'
: '/usr/local/freeside/success.html';
+$decline_html = -e 'decline.html'
+ ? 'decline.html'
+ : '/usr/local/freeside/decline.html';
if ( -e $ieak_file ) {
my $ieak_txt = Text::Template::_load_text($ieak_file)
or die $Text::Template::ERROR;
}
+if ( -e $decline_html ) {
+ my $decline_txt = Text::Template::_load_text($decline_html)
+ or die $Text::Template::ERROR;
+ $decline_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
+ $decline_txt = $1;
+ $decline_template = new Text::Template ( TYPE => 'STRING',
+ SOURCE => $decline_txt,
+ DELIMITERS => [ '<%=', '%>' ],
+ )
+ or die $Text::Template::ERROR;
+} else {
+ $decline_template = new Text::Template ( TYPE => 'STRING',
+ SOURCE => &decline_default,
+ DELIMITERS => [ '<%=', '%>' ],
+ )
+ or die $Text::Template::ERROR;
+}
+
( $locales, $packages, $pops, $init_data ) = signup_info();
@payby = @{$init_data->{'payby'}} if @{$init_data->{'payby'}};
}
- if ( $error ) {
+ if ( $error eq '_decline' ) {
+ print_decline();
+ } elsif ( $error ) {
print_form();
} else {
print_okay();
}
+sub print_decline {
+ print $cgi->header( '-expires' => 'now' ),
+ $decline_template->fill_in();
+}
+
sub print_okay {
my $user_agent = new HTTP::Headers::UserAgent $ENV{HTTP_USER_AGENT};
END
}
+sub decline_default { #html to use if there is a decline
+ <<'END';
+<HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
+<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
+There has been an error processing your account. Please contact customer
+support.
+</BODY></HTML>
+END
+}
+
sub signup_default { #html to use if you don't specify a template file
<<'END';
<HTML><HEAD><TITLE>ISP Signup form</TITLE></HEAD>
%hash = ( $cust_pkg => [ $svc_acct ] );
$error ||= $cust_main->insert( \%hash, \@invoicing_list ); #msgcat
- warn "[fs_signup_server] Sending results...\n" if $Debug;
- print $writer $error, "\n";
-
- next if $error;
-
- if ( $conf->exists('signup_server-realtime') ) {
+ if ( ! $error && $conf->exists('signup_server-realtime') ) {
warn "[fs_signup_server] Billing customer...\n" if $Debug;
if ( $cust_main->balance > 0 ) {
#should check list for errors...
- $cust_main->suspend;
+ #$cust_main->suspend;
+ $cust_main->cancel;
}
}
+ $error ||= '_decline';
+
+ warn "[fs_signup_server] Sending results...\n" if $Debug;
+ print $writer $error, "\n";
+
+ next if $error;
+
if ( $conf->config('signup_server-email') ) {
warn "[fs_signup_server] Sending email...\n" if $Debug;