alternate decline handline (Bug #408)
[freeside.git] / fs_signup / FS-SignupClient / cgi / signup.cgi
index 6ef5354..009a633 100755 (executable)
@@ -1,6 +1,6 @@
 #!/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
@@ -10,12 +10,16 @@ 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;
@@ -38,6 +42,9 @@ $signup_html = -e 'signup.html'
 $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)
@@ -103,6 +110,24 @@ if ( -e $success_html ) {
     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'}};
@@ -210,7 +235,9 @@ if ( defined $cgi->param('magic') ) {
 
     }
     
-    if ( $error ) {
+    if ( $error eq '_decline' ) {
+      print_decline();
+    } elsif ( $error ) {
       print_form();
     } else {
       print_okay();
@@ -262,6 +289,11 @@ sub print_form {
 
 }
 
+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};
 
@@ -425,6 +457,16 @@ Package: <%= $pkg %><BR>
 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>