scalar cgi param
[freeside.git] / httemplate / misc / process / payment.cgi
index 79b43b7..852becb 100644 (file)
@@ -86,7 +86,7 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
 
   $payinfo = $cust_payby->payinfo;
   $paymask = $cust_payby->paymask;
-  $paycvv = '';
+  $paycvv = $cust_payby->paycvv; # pass it if we got it, running a transaction will clear it
   ( $month, $year ) = $cust_payby->paydate_mon_year;
   $payname = $cust_payby->payname;
 
@@ -170,7 +170,7 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
     my %saveopt;
     if ( $payby eq 'CARD' ) {
       my $bill_location = FS::cust_location->new;
-      $bill_location->set( $_ => $cgi->param($_) )
+      $bill_location->set( $_ => scalar($cgi->param($_)) )
         foreach @{$payby2fields{$payby}};
       $saveopt{'bill_location'} = $bill_location;
       $saveopt{'paycvv'} = $paycvv; # save_cust_payby contains conf logic for when to use this
@@ -231,6 +231,8 @@ if ( $cgi->param('batch') ) {
     'paycvv'     => $paycvv,
     'paynum_ref' => \$paynum,
     'discount_term' => $discount_term,
+    'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
+    'no_invnum'     => 1,
     map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
   );
   errorpage($error) if $error;
@@ -251,7 +253,7 @@ if ( $cgi->param('batch') ) {
 
   }
 
-  $cust_main->apply_payments;
+  $cust_main->apply_payments if ($cgi->param('apply') eq 'yes');
 
 }