1 <& /elements/header.html, mt("Process [_1] payment",$type{$payby}) &>
2 <& /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 <& /elements/init_overlib.html &>
11 <% ntable('#cccccc') %>
13 <TH ALIGN="right"><% mt('Payment amount') |h %></TH>
15 <TABLE><TR><TD BGCOLOR="#ffffff">
16 <% $money_char %><INPUT NAME = "amount"
19 VALUE = "<% $amount %>"
21 STYLE = "text-align:right;"
23 onChange = "amount_changed(this)"
24 onKeyDown = "amount_changed(this)"
25 onKeyUp = "amount_changed(this)"
26 onKeyPress = "amount_changed(this)"
29 </TD><TD BGCOLOR="#cccccc">
31 <INPUT TYPE="hidden" NAME="fee_pkgpart" VALUE="<% $fee_pkg->pkgpart %>">
32 <INPUT TYPE="hidden" NAME="fee" VALUE="<% $fee_display eq 'add' ? $fee : '' %>">
33 <B><FONT SIZE='+1'><% $fee_op %></FONT>
34 <% $money_char . $fee %>
36 <% $fee_pkg->pkg |h %>
37 <B><FONT SIZE='+1'>=</FONT></B>
38 </TD><TD ID="ajax_total_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue">
39 <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT>
48 <SCRIPT TYPE="text/javascript">
50 function amount_changed(what) {
54 if ( what.value.length ) {
55 total = parseFloat(what.value) <% $fee_op %> <% $fee %>;
56 /* total = Math.round(total*100)/100; */
57 total = '<% $money_char %>' + total.toFixed(2);
60 var total_cell = document.getElementById('ajax_total_cell');
61 total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %></FONT>';
69 <& /elements/tr-select-discount_term.html,
70 'custnum' => $custnum,
71 'amount_id' => 'amount',
74 % if ( $payby eq 'CARD' ) {
76 % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
77 % my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
78 % if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
79 % $payinfo = $cust_main->paymask;
80 % $paycvv = $cust_main->paycvv;
81 % ( $month, $year ) = $cust_main->paydate_monthyear;
82 % $payname = $cust_main->payname if $cust_main->payname;
86 <TH ALIGN="right"><% mt('Card number') |h %></TH>
91 <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
92 <TH><% mt('Exp.') |h %></TH>
95 % for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
97 <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
105 % my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
107 <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
117 <TH ALIGN="right"><% mt('CVV2') |h %></TH>
118 <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
119 (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/cvv2.html', 480, 352, 'cvv2_popup' ), CAPTION, 'CVV2 Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>)
123 <TH ALIGN="right"><% mt('Exact name on card') |h %></TH>
124 <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
127 <& /elements/location.html,
128 'object' => $cust_main, #XXX errors???
130 'address1_label' => emt('Card billing address'),
133 % } elsif ( $payby eq 'CHEK' ) {
135 % my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
136 % $stateid, $stateid_state )
137 % = ( '', '', '', '', '', '', '', '', '' );
138 % if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
139 % $cust_main->paymask =~ /^([\dx]+)\@([\d\.x]*)$/i
140 % or die "unparsable payinfo ". $cust_main->payinfo;
141 % ($account, $aba) = ($1, $2);
142 % ($branch,$aba) = split('\.',$aba)
143 % if $conf->exists('cust_main-require-bank-branch');
144 % $payname = $cust_main->payname;
145 % $ss = $cust_main->ss;
146 % $paytype = $cust_main->getfield('paytype');
147 % $paystate = $cust_main->getfield('paystate');
148 % $stateid = $cust_main->getfield('stateid');
149 % $stateid_state = $cust_main->getfield('stateid_state');
152 <INPUT TYPE="hidden" NAME="month" VALUE="12">
153 <INPUT TYPE="hidden" NAME="year" VALUE="2037">
155 <TD ALIGN="right"><% mt('Account number') |h %></TD>
156 <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
157 <TD ALIGN="right"><% mt('Type') |h %></TD>
158 <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes) %></SELECT></TD>
161 <TD ALIGN="right"><% mt('ABA/Routing number') |h %></TD>
163 <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%$aba%>">
164 (<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;"><% mt('help') |h %></A>)
167 % if ( $conf->exists('cust_main-require-bank-branch') ) {
169 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
171 <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>">
176 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
177 <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
180 % if ( $conf->exists('show_bankstate') ) {
182 <TD ALIGN="right"><% mt('Bank state') |h %></TD>
183 <TD><& /elements/select-state.html,
184 'disable_empty' => 0,
185 'empty_label' => emt('(choose)'),
186 'state' => $paystate,
187 'country' => $cust_main->country,
193 <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
196 % if ( $conf->exists('show_ss') ) {
199 <% mt('Account holder') |h %><BR>
200 <% mt('Social security or tax ID #') |h %>
202 <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
205 <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
208 % if ( $conf->exists('show_stateid') ) {
211 <% mt('Account holder') |h %><BR>
212 <% mt("Driver's license or state ID #") |h %>
214 <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
215 <TD ALIGN="right"><% mt('State') |h %></TD>
216 <TD><& /elements/select-state.html,
217 'disable_empty' => 0,
218 'empty_label' => emt('(choose)'),
219 'state' => $stateid_state,
220 'country' => $cust_main->country,
221 'prefix' => 'stateid_',
226 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
227 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
230 % } #end CARD/CHEK-specific section
235 <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
236 <% mt('Remember this information') |h %>
240 % if ( $conf->exists("batch-enable")
241 % || grep $payby eq $_, $conf->config('batch-enable_payby')
244 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
246 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
252 <INPUT TYPE="checkbox" NAME="batch" VALUE="1">
253 <% mt('Add to current batch') |h %>
262 <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; }">
263 <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %>
270 <INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>">
273 <& /elements/footer.html &>
277 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
279 my %type = ( 'CARD' => 'credit card',
280 'CHEK' => 'electronic check (ACH)',
283 $cgi->param('payby') =~ /^(CARD|CHEK)$/
284 or die "unknown payby ". $cgi->param('payby');
287 $cgi->param('custnum') =~ /^(\d+)$/
288 or die "illegal custnum ". $cgi->param('custnum');
291 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
292 die "unknown custnum $custnum" unless $cust_main;
294 my $balance = $cust_main->balance;
298 my $conf = new FS::Conf;
300 my $money_char = $conf->config('money_char') || '$';
302 #false laziness w/selfservice make_payment.html shortcut for one-country
303 my %states = map { $_->state => 1 }
304 qsearch('cust_main_county', {
305 'country' => $conf->config('countrydefault') || 'US'
307 my @states = sort { $a cmp $b } keys %states;
311 my $fee_display = '';
313 my $num_payments = scalar($cust_main->cust_pay);
314 #handle old cust_main.pm (remove...)
315 $num_payments = scalar( @{ [ $cust_main->cust_pay ] } )
316 unless defined $num_payments;
317 if ( $conf->config('manual_process-pkgpart')
318 and ! $conf->exists('manual_process-skip_first') || $num_payments
322 $fee_display = $conf->config('manual_process-display') || 'add';
323 $fee_op = $fee_display eq 'add' ? '+' : '-';
326 qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } );
328 #well ->unit_setup or ->calc_setup both call for a $cust_pkg
329 # (though ->unit_setup doesn't use it...)
330 $fee = $fee_pkg->option('setup_fee')
331 if $fee_pkg; #in case.. better than dying with a perl traceback
336 if ( $balance > 0 ) {
339 if $fee && $fee_display eq 'subtract';
341 my $cc_surcharge_pct = $conf->config('credit-card-surcharge-percentage');
342 $amount += $amount * $cc_surcharge_pct/100 if $cc_surcharge_pct > 0;
344 $amount = sprintf("%.2f", $amount);
347 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;