alternate decline handline (Bug #408)
authorivan <ivan>
Thu, 25 Apr 2002 12:03:15 +0000 (12:03 +0000)
committerivan <ivan>
Thu, 25 Apr 2002 12:03:15 +0000 (12:03 +0000)
fs_signup/FS-SignupClient/cgi/decline.html [new file with mode: 0644]
fs_signup/FS-SignupClient/cgi/signup.cgi
fs_signup/fs_signup_server

diff --git a/fs_signup/FS-SignupClient/cgi/decline.html b/fs_signup/FS-SignupClient/cgi/decline.html
new file mode 100644 (file)
index 0000000..a37ba3a
--- /dev/null
@@ -0,0 +1,5 @@
+<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>
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>
index b636b69..e7b372a 100755 (executable)
@@ -169,12 +169,7 @@ while (1) {
     %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;
 
@@ -191,10 +186,18 @@ while (1) {
 
       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;