1 <% include( '/elements/header.html', "Process $type{$payby} payment" ) %>
2 <% include( '/elements/small_custview.html', $cust_main, '', '', popurl(2) . "view/cust_main.cgi" ) %>
3 <FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true">
4 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
5 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
6 <INPUT TYPE="hidden" NAME="payunique" VALUE="<% $payunique %>">
7 <INPUT TYPE="hidden" NAME="balance" VALUE="<% $balance %>">
9 <% include('/elements/init_overlib.html') %>
11 % #include( '/elements/table.html', '#cccccc' )
13 % my $amount = $balance > 0 ? sprintf("%.2f", $balance) : '';
15 <% ntable('#cccccc') %>
17 <TH ALIGN="right">Payment amount</TH>
19 <TABLE><TR><TD BGCOLOR="#ffffff">
20 <% $money_char %><INPUT NAME = "amount"
22 VALUE = "<% $amount %>"
24 STYLE = "text-align:right;"
26 onChange = "amount_changed(this)"
27 onKeyDown = "amount_changed(this)"
28 onKeyUp = "amount_changed(this)"
29 onKeyPress = "amount_changed(this)"
32 </TD><TD BGCOLOR="#cccccc">
34 <INPUT TYPE="hidden" NAME="fee_pkgpart" VALUE="<% $fee_pkg->pkgpart %>">
35 <INPUT TYPE="hidden" NAME="fee" VALUE="<% $fee %>">
36 <B><FONT SIZE='+1'>+</FONT>
37 <% $money_char . $fee %>
39 <% $fee_pkg->pkg |h %>
40 <B><FONT SIZE='+1'>=</FONT></B>
41 </TD><TD ID="ajax_total_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue">
42 <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', $amount + $fee ) : '' %> TOTAL</FONT>
51 <SCRIPT TYPE="text/javascript">
53 function amount_changed(what) {
57 if ( what.value.length ) {
58 total = parseFloat(what.value) + <% $fee %>;
59 /* total = Math.round(total*100)/100; */
60 total = '<% $money_char %>' + total.toFixed(2);
63 var total_cell = document.getElementById('ajax_total_cell');
64 total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' TOTAL</FONT>';
73 % if ( $payby eq 'CARD' ) {
75 % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
76 % my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
77 % if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
78 % $payinfo = $cust_main->paymask;
79 % $paycvv = $cust_main->paycvv;
80 % ( $month, $year ) = $cust_main->paydate_monthyear;
81 % $payname = $cust_main->payname if $cust_main->payname;
85 <TH ALIGN="right">Card number</TH>
90 <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
94 % for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
96 <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
104 % my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
106 <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
116 <TH ALIGN="right">CVV2</TH>
117 <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
118 (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)
122 <TH ALIGN="right">Exact name on card</TH>
123 <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
126 <% include( '/elements/location.html',
127 'object' => $cust_main, #XXX errors???
129 'address1_label' => 'Card billing address',
133 % } elsif ( $payby eq 'CHEK' ) {
135 % my( $payinfo1, $payinfo2, $payname, $ss, $paytype, $paystate,
136 % $stateid, $stateid_state )
137 % = ( '', '', '', '', '', '', '', '' );
138 % if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
139 % $cust_main->paymask =~ /^([\dx]+)\@([\dx]+)$/i
140 % or die "unparsable payinfo ". $cust_main->payinfo;
141 % ($payinfo1, $payinfo2) = ($1, $2);
142 % $payname = $cust_main->payname;
143 % $ss = $cust_main->ss;
144 % $paytype = $cust_main->getfield('paytype');
145 % $paystate = $cust_main->getfield('paystate');
146 % $stateid = $cust_main->getfield('stateid');
147 % $stateid_state = $cust_main->getfield('stateid_state');
150 <INPUT TYPE="hidden" NAME="month" VALUE="12">
151 <INPUT TYPE="hidden" NAME="year" VALUE="2037">
153 <TD ALIGN="right">Account number</TD>
154 <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$payinfo1%>"></TD>
155 <TD ALIGN="right">Type</TD>
156 <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes) %></SELECT></TD>
159 <TD ALIGN="right">ABA/Routing number</TD>
161 <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%$payinfo2%>">
162 (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)
166 <TD ALIGN="right">Bank name</TD>
167 <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
170 % if ( $conf->exists('show_bankstate') ) {
172 <TD ALIGN="right">Bank state</TD>
173 <TD><% include('/elements/select-state.html',
174 'disable_empty' => 0,
175 'empty_label' => '(choose)',
176 'state' => $paystate,
177 'country' => $cust_main->country,
184 <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
187 % if ( $conf->exists('show_ss') ) {
190 Account holder<BR>
191 Social security or tax ID #
193 <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
196 <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
199 % if ( $conf->exists('show_stateid') ) {
202 Account holder<BR>
203 Driver’s license or state ID #
205 <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
206 <TD ALIGN="right">State</TD>
207 <TD><% include('/elements/select-state.html',
208 'disable_empty' => 0,
209 'empty_label' => '(choose)',
210 'state' => $stateid_state,
211 'country' => $cust_main->country,
212 'prefix' => 'stateid_',
218 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
219 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
222 % } #end CARD/CHEK-specific section
227 <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
228 Remember this information
232 % if ( $conf->exists("batch-enable")
233 % || grep $payby eq $_, $conf->config('batch-enable_payby')
236 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
238 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
244 <INPUT TYPE="checkbox" NAME="batch" VALUE="1">
254 <INPUT TYPE="checkbox"<% ( ( $payby eq 'CARD' && $cust_main->payby ne 'DCRD' ) || ( $payby eq 'CHEK' && $cust_main->payby eq 'CHEK' ) ) ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
255 Charge future payments to this <% $type{$payby} %> automatically
262 <INPUT TYPE="submit" NAME="process" VALUE="Process payment">
265 <% include('/elements/footer.html') %>
269 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
271 my %type = ( 'CARD' => 'credit card',
272 'CHEK' => 'electronic check (ACH)',
275 $cgi->param('payby') =~ /^(CARD|CHEK)$/
276 or die "unknown payby ". $cgi->param('payby');
279 $cgi->param('custnum') =~ /^(\d+)$/
280 or die "illegal custnum ". $cgi->param('custnum');
283 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
284 die "unknown custnum $custnum" unless $cust_main;
286 my $balance = $cust_main->balance;
290 my $conf = new FS::Conf;
292 my $money_char = $conf->config('money_char') || '$';
294 #false laziness w/selfservice make_payment.html shortcut for one-country
295 my %states = map { $_->state => 1 }
296 qsearch('cust_main_county', {
297 'country' => $conf->config('countrydefault') || 'US'
299 my @states = sort { $a cmp $b } keys %states;
303 if ( $conf->config('manual_process-pkgpart') ) {
305 qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } );
307 #well ->unit_setup or ->calc_setup both call for a $cust_pkg
308 # (though ->unit_setup doesn't use it...)
309 $fee = $fee_pkg->option('setup_fee')
310 if $fee_pkg; #in case.. better than dying with a perl traceback
313 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;