5 use vars qw( $cgi $self_url $error
6 $verify_html $verify_template
7 $success_html $success_template
8 $decline_html $decline_template
11 use subs qw( print_verify print_okay print_decline
12 verify_default success_default decline_default
16 use FS::SelfService qw( capture_payment );
18 $verify_html = -e 'verify.html'
20 : '/usr/local/freeside/verify.html';
21 $success_html = -e 'verify_success.html'
23 : '/usr/local/freeside/success.html';
24 $decline_html = -e 'verify_decline.html'
26 : '/usr/local/freeside/decline.html';
29 if ( -e $verify_html ) {
30 my $verify_txt = Text::Template::_load_text($verify_html)
31 or die $Text::Template::ERROR;
32 $verify_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
34 $verify_template = new Text::Template ( TYPE => 'STRING',
35 SOURCE => $verify_txt,
36 DELIMITERS => [ '<%=', '%>' ],
38 or die $Text::Template::ERROR;
40 $verify_template = new Text::Template ( TYPE => 'STRING',
41 SOURCE => &verify_default,
42 DELIMITERS => [ '<%=', '%>' ],
44 or die $Text::Template::ERROR;
47 if ( -e $success_html ) {
48 my $success_txt = Text::Template::_load_text($success_html)
49 or die $Text::Template::ERROR;
50 $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
52 $success_template = new Text::Template ( TYPE => 'STRING',
53 SOURCE => $success_txt,
54 DELIMITERS => [ '<%=', '%>' ],
56 or die $Text::Template::ERROR;
58 $success_template = new Text::Template ( TYPE => 'STRING',
59 SOURCE => &success_default,
60 DELIMITERS => [ '<%=', '%>' ],
62 or die $Text::Template::ERROR;
65 if ( -e $decline_html ) {
66 my $decline_txt = Text::Template::_load_text($decline_html)
67 or die $Text::Template::ERROR;
68 $decline_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
70 $decline_template = new Text::Template ( TYPE => 'STRING',
71 SOURCE => $decline_txt,
72 DELIMITERS => [ '<%=', '%>' ],
74 or die $Text::Template::ERROR;
76 $decline_template = new Text::Template ( TYPE => 'STRING',
77 SOURCE => &decline_default,
78 DELIMITERS => [ '<%=', '%>' ],
80 or die $Text::Template::ERROR;
85 my $rv = capture_payment(
86 data => { 'manual' => 1,
87 map { $_ => scalar($cgi->param($_)) } $cgi->param
89 url => $cgi->self_url,
92 $error = $rv->{error};
94 if ( $error eq '_decline' ) {
105 $error = "Error: $error" if $error;
107 my $r = { $cgi->Vars, 'error' => $error };
109 $r->{self_url} = $cgi->self_url;
111 print $cgi->header( '-expires' => 'now' ),
112 $verify_template->fill_in( PACKAGE => 'FS::SelfService::_signupcgi',
118 print $cgi->header( '-expires' => 'now' ),
119 $decline_template->fill_in();
125 my @success_url = split '/', $cgi->url(-path);
128 my $success_url = join '/', @success_url;
129 if ($param{session_id}) {
130 my $session_id = lc($param{session_id});
131 $success_url .= "/selfservice.cgi?action=myaccount&session=$session_id";
133 $success_url .= '/signup.cgi?action=success';
136 print $cgi->header( '-expires' => 'now' ),
137 $success_template->fill_in( HASH => { success_url => $success_url } );
140 sub success_default { #html to use if you don't specify a success file
142 <HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
143 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
144 Thanks for signing up!
146 <SCRIPT TYPE="text/javascript">
147 window.top.location="<%= $success_url %>";
153 sub verify_default { #html to use for verification response
155 <HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
156 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
157 There has been an error processing your account. Please contact customer
163 sub decline_default { #html to use if there is a decline
165 <HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
166 <BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
167 There has been an error processing your account. Please contact customer
173 # subs for the templates...
175 package FS::SelfService::_signupcgi;