1 <& /elements/header.html, mt("Process [_1] payment",$type{$payby}) &>
2 <& /elements/small_custview.html, $cust_main, '', '', popurl(2) . "view/cust_main.cgi" &>
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-amount_fee.html,
18 scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
19 'process-display' => scalar($conf->config('manual_process-display')),
20 'process-skip_first' => $conf->exists('manual_process-skip_first'),
21 'num_payments' => scalar($cust_main->cust_pay),
22 'surcharge_percentage' =>
24 ? scalar($conf->config('credit-card-surcharge-percentage'))
29 % if ( $conf->exists('part_pkg-term_discounts') ) {
30 <& /elements/tr-select-discount_term.html,
31 'custnum' => $custnum,
32 'amount_id' => 'amount',
37 % if ( $payby eq 'CARD' ) {
39 % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
40 % my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
41 % my $location = $cust_main->bill_location;
43 % #auto-fill with the highest weighted match
44 % my ($cust_payby) = $cust_main->cust_payby('CARD','DCRD');
46 % $payinfo = $cust_payby->paymask;
47 % $paycvv = $cust_payby->paycvv;
48 % ( $month, $year ) = $cust_payby->paydate_monthyear;
49 % $payname = $cust_payby->payname if $cust_payby->payname;
50 % $location = $cust_payby->cust_location || $location;
51 % $auto = 1 if $cust_payby->payby eq 'CARD';
55 <TH ALIGN="right"><% mt('Card number') |h %></TH>
60 <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
61 <TH><% mt('Exp.') |h %></TH>
64 % for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
66 <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
74 % my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
76 <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
86 <TH ALIGN="right"><% mt('CVV2') |h %></TH>
87 <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
88 (<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>)
92 <TH ALIGN="right"><% mt('Exact name on card') |h %></TH>
93 <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
96 <& /elements/location.html,
97 'object' => $location,
99 'address1_label' => emt('Card billing address'),
102 % } elsif ( $payby eq 'CHEK' ) {
104 % my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
105 % $stateid, $stateid_state )
106 % = ( '', '', '', '', '', '', '', '', '' );
107 % my ($cust_payby) = $cust_main->cust_payby('CHEK','DCHK');
109 % $cust_payby->paymask =~ /^([\dx]+)\@([\d\.x]*)$/i
110 % or die "unparsable paymask ". $cust_payby->paymask;
111 % ($account, $aba) = ($1, $2);
112 % ($branch,$aba) = split('\.',$aba)
113 % if $conf->config('echeck-country') eq 'CA';
114 % $payname = $cust_payby->payname;
115 % $paytype = $cust_payby->getfield('paytype');
116 % $paystate = $cust_payby->getfield('paystate');
117 % $auto = 1 if $cust_payby->payby eq 'CHEK';
118 % # these values aren't in cust_payby, but maybe should be...
119 % $ss = $cust_main->ss;
120 % $stateid = $cust_main->getfield('stateid');
121 % $stateid_state = $cust_main->getfield('stateid_state');
124 % #false laziness w/{edit,view}/cust_main/billing.html
125 % my $routing_label = $conf->config('echeck-country') eq 'US'
126 % ? 'ABA/Routing number'
127 % : 'Routing number';
128 % my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
129 % my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
131 <INPUT TYPE="hidden" NAME="month" VALUE="12">
132 <INPUT TYPE="hidden" NAME="year" VALUE="2037">
134 <TD ALIGN="right"><% mt('Account number') |h %></TD>
135 <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
136 <TD ALIGN="right"><% mt('Type') |h %></TD>
137 <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } FS::cust_payby->paytypes) %></SELECT></TD>
140 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
142 <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>">
143 (<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>)
146 % if ( $conf->config('echeck-country') eq 'CA' ) {
148 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
150 <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5>
155 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
156 <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
159 % if ( $conf->exists('show_bankstate') ) {
161 <TD ALIGN="right"><% mt('Bank state') |h %></TD>
162 <TD><& /elements/select-state.html,
163 'disable_empty' => 0,
164 'empty_label' => emt('(choose)'),
165 'state' => $paystate,
166 'country' => $cust_main->country,
172 <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
175 % if ( $conf->exists('show_ss') ) {
178 <% mt('Account holder') |h %><BR>
179 <% mt('Social security or tax ID #') |h %>
181 <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
184 <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
187 % if ( $conf->exists('show_stateid') ) {
190 <% mt('Account holder') |h %><BR>
191 <% mt("Driver's license or state ID #") |h %>
193 <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
194 <TD ALIGN="right"><% mt('State') |h %></TD>
195 <TD><& /elements/select-state.html,
196 'disable_empty' => 0,
197 'empty_label' => emt('(choose)'),
198 'state' => $stateid_state,
199 'country' => $cust_main->country,
200 'prefix' => 'stateid_',
205 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
206 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
209 % } #end CARD/CHEK-specific section
214 <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
215 <% mt('Remember this information') |h %>
219 % if ( $conf->exists("batch-enable")
220 % || grep $payby eq $_, $conf->config('batch-enable_payby')
223 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
225 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
231 <INPUT TYPE="checkbox" NAME="batch" VALUE="1">
232 <% mt('Add to current batch') |h %>
241 <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
242 <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %>
249 <INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>">
252 <& /elements/footer.html &>
256 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
258 my %type = ( 'CARD' => 'credit card',
259 'CHEK' => 'electronic check (ACH)',
262 $cgi->param('payby') =~ /^(CARD|CHEK)$/
263 or die "unknown payby ". $cgi->param('payby');
266 $cgi->param('custnum') =~ /^(\d+)$/
267 or die "illegal custnum ". $cgi->param('custnum');
270 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
271 die "unknown custnum $custnum" unless $cust_main;
273 my $balance = $cust_main->balance;
277 my $conf = new FS::Conf;
279 #false laziness w/selfservice make_payment.html shortcut for one-country
280 my %states = map { $_->state => 1 }
281 qsearch('cust_main_county', {
282 'country' => $conf->config('countrydefault') || 'US'
284 my @states = sort { $a cmp $b } keys %states;
287 if ( $balance > 0 ) {
288 # when configured to do so, amount will only auto-fill with balance
289 # if balance represents a single invoice
291 unless $conf->exists('manual_process-single_invoice_amount')
292 && ($cust_main->open_cust_bill != 1);
295 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;