fixes gratuitous "Illegal payname" errors reported by noment
[freeside.git] / FS / FS / cust_bill.pm
index 68ef094..449ab74 100644 (file)
@@ -458,7 +458,7 @@ sub realtime_card {
   my($payname, $payfirst, $paylast);
   if ( $cust_main->payname ) {
     $payname = $cust_main->payname;
-    $payname =~ /^\s*([\w \,\.\-\']*)?\s+([\w\,\.\-\']+)$/
+    $payname =~ /^\s*([\w \,\.\-\']*)?\s+([\w\,\.\-\']+)\s*$/
       or do {
               #$dbh->rollback if $oldAutoCommit;
               return "Illegal payname $payname";
@@ -466,7 +466,7 @@ sub realtime_card {
     ($payfirst, $paylast) = ($1, $2);
   } else {
     $payfirst = $cust_main->getfield('first');
-    $paylast = $cust_main->getfield('first');
+    $paylast = $cust_main->getfield('last');
     $payname =  "$payfirst $paylast";
   }
 
@@ -483,7 +483,10 @@ sub realtime_card {
   if ( $conf->exists('business-onlinepayment-description') ) {
     my $dtempl = $conf->config('business-onlinepayment-description');
 
-    my $agent = $cust_main->agent->agent;
+    my $agent_obj = $cust_main->agent
+      or die "can't retreive agent for $cust_main (agentnum ".
+             $cust_main->agentnum. ")";
+    my $agent = $agent_obj->agent;
     my $pkgs = join(', ',
       map { $_->cust_pkg->part_pkg->pkg }
         grep { $_->pkgnum } $self->cust_bill_pkg
@@ -515,6 +518,7 @@ sub realtime_card {
     'expiration'     => $exp,
     'referer'        => 'http://cleanwhisker.420.am/',
     'email'          => $email,
+    'phone'          => $cust_main->daytime || $cust_main->night,
   );
   $transaction->submit();
 
@@ -944,7 +948,7 @@ sub print_text {
 
 =head1 VERSION
 
-$Id: cust_bill.pm,v 1.30 2002-04-16 22:38:04 ivan Exp $
+$Id: cust_bill.pm,v 1.34 2002-05-06 13:36:02 ivan Exp $
 
 =head1 BUGS