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 <& /elements/tr-amount_fee.html,
16 scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
17 'process-display' => scalar($conf->config('manual_process-display')),
18 'process-skip_first' => $conf->exists('manual_process-skip_first'),
19 'num_payments' => scalar($cust_main->cust_pay),
20 'surcharge_percentage' => scalar($conf->config('credit-card-surcharge-percentage')),
23 <& /elements/tr-select-discount_term.html,
24 'custnum' => $custnum,
25 'amount_id' => 'amount',
28 % if ( $payby eq 'CARD' ) {
30 % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' );
31 % my $payname = $cust_main->first. ' '. $cust_main->getfield('last');
32 % if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
33 % $payinfo = $cust_main->paymask;
34 % $paycvv = $cust_main->paycvv;
35 % ( $month, $year ) = $cust_main->paydate_monthyear;
36 % $payname = $cust_main->payname if $cust_main->payname;
40 <TH ALIGN="right"><% mt('Card number') |h %></TH>
45 <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<%$payinfo%>"> </TD>
46 <TH><% mt('Exp.') |h %></TH>
49 % for ( ( map "0$_", 1 .. 9 ), 10 .. 12 ) {
51 <OPTION<% $_ == $month ? ' SELECTED' : '' %>><% $_ %>
59 % my @a = localtime; for ( $a[5]+1900 .. $a[5]+1915 ) {
61 <OPTION<% $_ == $year ? ' SELECTED' : '' %>><% $_ %>
71 <TH ALIGN="right"><% mt('CVV2') |h %></TH>
72 <TD><INPUT TYPE="text" NAME="paycvv" VALUE="<% $paycvv %>" SIZE=4 MAXLENGTH=4>
73 (<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>)
77 <TH ALIGN="right"><% mt('Exact name on card') |h %></TH>
78 <TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<%$payname%>"></TD>
81 <& /elements/location.html,
82 'object' => $cust_main->bill_location,
84 'address1_label' => emt('Card billing address'),
87 % } elsif ( $payby eq 'CHEK' ) {
89 % my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
90 % $stateid, $stateid_state )
91 % = ( '', '', '', '', '', '', '', '', '' );
92 % if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
93 % $cust_main->paymask =~ /^([\dx]+)\@([\d\.x]*)$/i
94 % or die "unparsable payinfo ". $cust_main->payinfo;
95 % ($account, $aba) = ($1, $2);
96 % ($branch,$aba) = split('\.',$aba)
97 % if $conf->config('echeck-country') eq 'CA';
98 % $payname = $cust_main->payname;
99 % $ss = $cust_main->ss;
100 % $paytype = $cust_main->getfield('paytype');
101 % $paystate = $cust_main->getfield('paystate');
102 % $stateid = $cust_main->getfield('stateid');
103 % $stateid_state = $cust_main->getfield('stateid_state');
106 % #false laziness w/{edit,view}/cust_main/billing.html
107 % my $routing_label = $conf->config('echeck-country') eq 'US'
108 % ? 'ABA/Routing number'
109 % : 'Routing number';
110 % my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
111 % my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
113 <INPUT TYPE="hidden" NAME="month" VALUE="12">
114 <INPUT TYPE="hidden" NAME="year" VALUE="2037">
116 <TD ALIGN="right"><% mt('Account number') |h %></TD>
117 <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
118 <TD ALIGN="right"><% mt('Type') |h %></TD>
119 <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes) %></SELECT></TD>
122 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
124 <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>">
125 (<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>)
128 % if ( $conf->config('echeck-country') eq 'CA' ) {
130 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
132 <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5>
137 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
138 <TD><INPUT TYPE="text" NAME="payname" VALUE="<%$payname%>"></TD>
141 % if ( $conf->exists('show_bankstate') ) {
143 <TD ALIGN="right"><% mt('Bank state') |h %></TD>
144 <TD><& /elements/select-state.html,
145 'disable_empty' => 0,
146 'empty_label' => emt('(choose)'),
147 'state' => $paystate,
148 'country' => $cust_main->country,
154 <INPUT TYPE="hidden" NAME="paystate" VALUE="<% $paystate %>">
157 % if ( $conf->exists('show_ss') ) {
160 <% mt('Account holder') |h %><BR>
161 <% mt('Social security or tax ID #') |h %>
163 <TD><INPUT TYPE="text" NAME="ss" VALUE="<% $ss %>"></TD>
166 <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>"></TD>
169 % if ( $conf->exists('show_stateid') ) {
172 <% mt('Account holder') |h %><BR>
173 <% mt("Driver's license or state ID #") |h %>
175 <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>"></TD>
176 <TD ALIGN="right"><% mt('State') |h %></TD>
177 <TD><& /elements/select-state.html,
178 'disable_empty' => 0,
179 'empty_label' => emt('(choose)'),
180 'state' => $stateid_state,
181 'country' => $cust_main->country,
182 'prefix' => 'stateid_',
187 <INPUT TYPE="hidden" NAME="stateid" VALUE="<% $stateid %>">
188 <INPUT TYPE="hidden" NAME="stateid_state" VALUE="<% $stateid_state %>">
191 % } #end CARD/CHEK-specific section
196 <INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
197 <% mt('Remember this information') |h %>
201 % if ( $conf->exists("batch-enable")
202 % || grep $payby eq $_, $conf->config('batch-enable_payby')
205 % if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
207 <INPUT TYPE="hidden" NAME="batch" VALUE="1">
213 <INPUT TYPE="checkbox" NAME="batch" VALUE="1">
214 <% mt('Add to current batch') |h %>
223 <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; }">
224 <% mt("Charge future payments to this [_1] automatically",$type{$payby}) |h %>
231 <INPUT TYPE="submit" NAME="process" VALUE="<% mt('Process payment') |h %>">
234 <& /elements/footer.html &>
238 unless $FS::CurrentUser::CurrentUser->access_right('Process payment');
240 my %type = ( 'CARD' => 'credit card',
241 'CHEK' => 'electronic check (ACH)',
244 $cgi->param('payby') =~ /^(CARD|CHEK)$/
245 or die "unknown payby ". $cgi->param('payby');
248 $cgi->param('custnum') =~ /^(\d+)$/
249 or die "illegal custnum ". $cgi->param('custnum');
252 my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
253 die "unknown custnum $custnum" unless $cust_main;
255 my $location = $cust_main->bill_location;
256 # no proper error handling on this anyway, but when we have it,
257 # remember to repopulate fields in $location
259 my $balance = $cust_main->balance;
263 my $conf = new FS::Conf;
265 #false laziness w/selfservice make_payment.html shortcut for one-country
266 my %states = map { $_->state => 1 }
267 qsearch('cust_main_county', {
268 'country' => $conf->config('countrydefault') || 'US'
270 my @states = sort { $a cmp $b } keys %states;
273 if ( $balance > 0 ) {
277 my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;