improve echeck validation for canada, deprecate echeck-nonus and cust_main-require...
[freeside.git] / httemplate / misc / payment.cgi
index 447cfa3..093494a 100644 (file)
@@ -14,6 +14,7 @@
     <TD COLSPAN=7>
       <TABLE><TR><TD BGCOLOR="#ffffff">
         <% $money_char %><INPUT NAME     = "amount"
+                                ID       = "amount"
                                 TYPE     = "text"
                                 VALUE    = "<% $amount %>"
                                 SIZE     = 8
@@ -67,7 +68,7 @@
 
 <& /elements/tr-select-discount_term.html,
              'custnum' => $custnum,
-             'cgi'     => $cgi
+             'amount_id' => 'amount',
 &>
 
 % if ( $payby eq 'CARD' ) {
 
 % } elsif ( $payby eq 'CHEK' ) {
 %
-%   my( $payinfo1, $payinfo2, $payname, $ss, $paytype, $paystate,
+%   my( $account, $aba, $branch, $payname, $ss, $paytype, $paystate,
 %       $stateid, $stateid_state )
-%     = ( '', '', '', '', '', '', '', '' );
+%     = ( '', '', '', '', '', '', '', '', '' );
 %   if ( $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
-%     $cust_main->paymask =~ /^([\dx]+)\@([\dx]*)$/i
+%     $cust_main->paymask =~ /^([\dx]+)\@([\d\.x]*)$/i
 %       or die "unparsable payinfo ". $cust_main->payinfo;
-%     ($payinfo1, $payinfo2) = ($1, $2);
+%     ($account, $aba) = ($1, $2);
+%     ($branch,$aba) = split('\.',$aba)
+%       if $conf->config('echeck-country') eq 'CA';
 %     $payname = $cust_main->payname;
 %     $ss = $cust_main->ss;
 %     $paytype = $cust_main->getfield('paytype');
 %     $stateid = $cust_main->getfield('stateid');
 %     $stateid_state = $cust_main->getfield('stateid_state');
 %   }
+%
+%  #false laziness w/{edit,view}/cust_main/billing.html
+%  my $routing_label = $conf->config('echeck-country') eq 'US'
+%                        ? 'ABA/Routing number'
+%                        : 'Routing number';
+%  my $routing_size      = $conf->config('echeck-country') eq 'CA' ? 4 : 10;
+%  my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9;
 
     <INPUT TYPE="hidden" NAME="month" VALUE="12">
     <INPUT TYPE="hidden" NAME="year" VALUE="2037">
     <TR>
       <TD ALIGN="right"><% mt('Account number') |h %></TD>
-      <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$payinfo1%>"></TD>
+      <TD><INPUT TYPE="text" SIZE=10 NAME="payinfo1" VALUE="<%$account%>"></TD>
       <TD ALIGN="right"><% mt('Type') |h %></TD>
       <TD><SELECT NAME="paytype"><% join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes) %></SELECT></TD>
     </TR>
-%   if ( $conf->exists('echeck-no_routing') ) {
-      <INPUT TYPE="text" NAME="payinfo2" VALUE="<%$payinfo2%>">
-%   } else {
+    <TR>
+      <TD ALIGN="right"><% mt($routing_label) |h %></TD>
+      <TD>
+        <INPUT TYPE="text" SIZE="<% $routing_size %>" MAXLENGTH="<% $routing_maxlength %>" NAME="payinfo2" VALUE="<%$aba%>">
+        (<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>)
+      </TD>
+    </TR>
+%   if ( $conf->config('echeck-country') eq 'CA' ) {
       <TR>
-        <TD ALIGN="right"><% mt('ABA/Routing number') |h %></TD>
+        <TD ALIGN="right"><% mt('Branch number') |h %></TD>
         <TD>
-          <INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="<%$payinfo2%>">
-          (<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>)
+          <INPUT TYPE="text" NAME="payinfo3" VALUE="<%$branch%>" SIZE=6 MAXLENGTH=5>
         </TD>
       </TR>
 %   }