1 <& /elements/header-cust_main.html, view=>'payment_history', cust_main=>$cust_main &>
3 <h2><% emt("Process [_1] payment",$type{$payby}) %></h2>
5 <FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true">
6 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
7 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
8 <INPUT TYPE="hidden" NAME="payunique" VALUE="<% $payunique %>">
9 <INPUT TYPE="hidden" NAME="balance" VALUE="<% $balance %>">
11 <& /elements/init_overlib.html &>
13 <TABLE class="fsinnerbox">
15 <& /elements/tr-select-payment_options.html,
16 'custnum' => $cust_main->custnum,
19 scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
20 'process-display' => scalar($conf->config('manual_process-display')),
21 'process-skip_first' => $conf->exists('manual_process-skip_first'),
22 'num_payments' => scalar($cust_main->cust_pay),
23 'surcharge_percentage' =>
25 ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
28 'surcharge_flatfee' =>
30 ? scalar($conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum))
35 % if ( $conf->exists('part_pkg-term_discounts') ) {
36 <& /elements/tr-select-discount_term.html,
37 'custnum' => $custnum,
38 'amount_id' => 'amount',
42 % my $disallow_no_auto_apply = 0;
43 % if ( $conf->exists("batch-enable")
44 % || grep $payby eq $_, $conf->config('batch-enable_payby')
47 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
48 % $disallow_no_auto_apply = 1;
50 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
55 <TH ALIGN="right"> <% mt('Add to current batch') |h %></TH>
57 <INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch_checkbox" ONCHANGE="change_batch_checkbox()">
64 % unless ($disallow_no_auto_apply) {
65 % # false laziness with edit/cust_pay.cgi
67 <TR ID="apply_box_row">
68 <TH ALIGN="right"><% mt('Auto-apply to invoices') |h %></TH>
70 <SELECT NAME="apply" ID="apply_box">
71 <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION>
72 <OPTION VALUE=""><% mt('not now') |h %></OPTION>
73 <OPTION VALUE="never"><% mt('never') |h %></OPTION>
78 % # this can go away if no_auto_apply handling gets added to batch payment processing
80 function change_batch_checkbox () {
81 if (document.getElementById('batch_checkbox').checked) {
82 document.getElementById('apply_box').disabled = true;
83 document.getElementById('apply_box_row').style.display = 'none';
85 document.getElementById('apply_box').disabled = false;
86 document.getElementById('apply_box_row').style.display = '';
93 <SCRIPT TYPE="text/javascript">
94 function cust_payby_changed (what) {
95 var custpaybynum = what.options[what.selectedIndex].value
96 if ( custpaybynum == '' || custpaybynum == '0' ) {
97 //what.form.payinfo.disabled = false;
98 $('#cust_payby').slideDown();
100 //what.form.payinfo.value = '';
101 //what.form.payinfo.disabled = true;
102 $('#cust_payby').slideUp();
107 % #can't quite handle CARD/CHEK on the same page yet, but very close
108 % #does it make sense from a UI/usability perspective?
110 % my @cust_payby = ();
111 % if ( $payby eq 'CARD' ) {
112 % @cust_payby = $cust_main->cust_payby('CARD','DCRD');
113 % } elsif ( $payby eq 'CHEK' ) {
114 % @cust_payby = $cust_main->cust_payby('CHEK','DCHK');
116 % die "unknown payby $payby";
119 % my $custpaybynum = length(scalar($cgi->param('custpaybynum')))
120 % ? scalar($cgi->param('custpaybynum'))
121 % : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
123 <& /elements/tr-select-cust_payby.html,
124 'cust_payby' => \@cust_payby,
125 'curr_value' => $custpaybynum,
126 'onchange' => 'cust_payby_changed(this)',
132 <% $custpaybynum ? 'STYLE="display:none"'
136 <TABLE class="fsinnerbox">
139 % if ( $payby eq 'CARD' ) {
141 % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
142 % my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
143 % my $location = $cust_main->bill_location;
146 <TH ALIGN="right"><% mt('Card number') |h %></TH>
151 <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
152 <TH><% mt('Exp.') |h %></TH>
154 <SELECT NAME="month">
155 % for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
157 <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
165 % my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
167 <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
177 <TH ALIGN="right"><% mt('CVV2') |h %></TH>
178 <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
179 (<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>)
183 <TH ALIGN="right"><% mt('Exact name on card') |h %></TH>
184 <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
187 <& /elements/location.html,
188 'object' => $location,
190 'address1_label' => emt('Card billing address'),
193 % } elsif ( $payby eq 'CHEK' ) {
195 % my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
196 % $stateid, $stateid_state )
197 % = ( '', '', '', '', '', '', '', '', '' );
199 % #false laziness w/{edit,view}/cust_main/billing.html
200 % my $routing_label = $conf->config('echeck-country') eq 'US'
201 % ? 'ABA/Routing number'
202 % : 'Routing number';
203 % my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
204 % my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
206 <INPUT TYPE="hidden" NAME="month" VALUE="12">
207 <INPUT TYPE="hidden" NAME="year" VALUE="2037">
209 <TD ALIGN="right"><% mt('Account number') |h %></TD>
210 <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
211 <TD ALIGN="right"><% mt('Type') |h %></TD>
212 <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } FS::cust_payby->paytypes) %></SELECT></TD>
215 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
217 <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>">
218 (<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>)
221 % if ( $conf->config('echeck-country') eq 'CA' ) {
223 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
225 <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5>
230 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
231 <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
234 % if ( $conf->exists('show_bankstate') ) {
236 <TD ALIGN="right"><% mt('Bank state') |h %></TD>
237 <TD><& /elements/select-state.html,
238 'disable_empty' => 0,
239 'empty_label' => emt('(choose)'),
240 'state' => $paystate,
241 'country' => $cust_main->country,
247 <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
250 % if ( $conf->exists('show_ss') ) {
253 <% mt('Account holder') |h %><BR>
254 <% mt('Social security or tax ID #') |h %>
256 <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
259 <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
262 % if ( $conf->exists('show_stateid') ) {
265 <% mt('Account holder') |h %><BR>
266 <% mt("Driver's license or state ID #") |h %>
268 <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
269 <TD ALIGN="right"><% mt('State') |h %></TD>
270 <TD><& /elements/select-state.html,
271 'disable_empty' => 0,
272 'empty_label' => emt('(choose)'),
273 'state' => $stateid_state,
274 'country' => $cust_main->country,
275 'prefix' => 'stateid_',
280 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
281 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
284 % } #end CARD/CHEK-specific section
289 <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
290 <% mt('Remember this information') |h %>
296 <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
297 <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %>
298 % if ( @cust_payby ) {
300 <SELECT NAME="weight">
301 % for ( 1 .. 1+scalar(grep { $_->payby =~ /^(CARD|CHEK)$/ } @cust_payby) ) {
302 <OPTION VALUE="<%$_%>"><% mt( $weight{$_} ) |h %>
306 <INPUT TYPE="hidden" NAME="weight" VALUE="1">
315 <INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>">
318 <& /elements/footer-cust_main.html &>
335 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
337 my %type = ( 'CARD' => 'credit card',
338 'CHEK' => 'electronic check (ACH)',
341 $cgi->param('payby') =~ /^(CARD|CHEK)$/
342 or die "unknown payby ". $cgi->param('payby');
345 $cgi->param('custnum') =~ /^(\d+)$/
346 or die "illegal custnum ". $cgi->param('custnum');
349 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
350 die "unknown custnum $custnum" unless $cust_main;
352 my $balance = $cust_main->balance;
356 my $conf = new FS::Conf;
358 #false laziness w/selfservice make_payment.html shortcut for one-country
359 my %states = map { $_->state => 1 }
360 qsearch('cust_main_county', {
361 'country' => $conf->config('countrydefault') || 'US'
363 my @states = sort { $a cmp $b } keys %states;
365 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;