+ } # foreach my $field
+ # finished importing columns
+
+ $bill_location{'country'} ||= $conf->config('countrydefault') || 'US';
+ $cust_main{'bill_location'} = FS::cust_location->new(\%bill_location);
+ if ( grep $_, values(%ship_location) ) {
+ $ship_location{'country'} ||= $conf->config('countrydefault') || 'US';
+ $cust_main{'ship_location'} = FS::cust_location->new(\%ship_location);
+ } else {
+ $cust_main{'ship_location'} = $cust_main{'bill_location'};
+ }
+
+ if ( defined $cust_main{'payinfo'} && length $cust_main{'payinfo'} ) {
+
+ if ( $cust_main{'payinfo'} =~ /^\s*(\d+\@[\d\.]+)\s*$/ ) {
+
+ delete $cust_main{'payinfo'};
+
+ $cust_payby = new FS::cust_payby {
+ 'payby' => 'CHEK',
+ 'payinfo' => $1,
+ };
+
+ } elsif ($cust_main{'payinfo'} =~ /^\s*([AD]?)(.*)\s*$/) {
+
+ delete $cust_main{'payinfo'};
+
+ ## validate credit card if requested
+ if ($validate_cc) {
+ validate($2)
+ or return "Invalid card($2) for customer ".$cust_main{'first'}." ".$cust_main{'last'};
+ return "Unknown card type for customer ".$cust_main{'first'}." ".$cust_main{'last'}
+ if cardtype($2) eq "Unknown";
+ }
+
+ $cust_payby = new FS::cust_payby {
+ 'payby' => ($1 eq 'D') ? 'DCRD' : 'CARD',
+ 'payinfo' => $2,
+ 'paycvv' => delete $cust_main{'paycvv'},
+ 'paydate' => delete $cust_main{'paydate'},
+ 'payname' => $cust_main{'first'}. ' '. $cust_main{'last'},
+ };
+
+ }
+