-% if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
-% $payinfo = $cust_main->paymask;
-% $paycvv = $cust_main->paycvv;
-% ( $month, $year ) = $cust_main->paydate_monthyear;
-% $payname = $cust_main->payname if $cust_main->payname;
+% my $location = $cust_main->bill_location;
+%
+% #auto-fill with the highest weighted match
+% my ($cust_payby) = $cust_main->cust_payby('CARD','DCRD');
+% if ($cust_payby) {
+% $payinfo = $cust_payby->paymask;
+% $paycvv = $cust_payby->paycvv;
+% ( $month, $year ) = $cust_payby->paydate_monthyear;
+% $payname = $cust_payby->payname if $cust_payby->payname;
+% $location = $cust_payby->cust_location || $location;
+% $auto = 1 if $cust_payby->payby eq 'CARD';