RT# 76093 - Added ability to charge a processing fee when taking a payment on the...
[freeside.git] / httemplate / misc / process / payment.cgi
index 5f945a7..4d4e62a 100644 (file)
@@ -32,6 +32,8 @@ my $custnum = $1;
 my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
 die "unknown custnum $custnum" unless $cust_main;
 
+my $processing_fee = $cgi->param('processing_fee') ? $cgi->param('processing_fee') : '';
+
 $cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/
   or errorpage("illegal amount ". $cgi->param('amount'));
 my $amount = $1;
@@ -124,7 +126,9 @@ if ( $payby eq 'CHEK' ) {
 
   if ( defined $cust_main->dbdef_table->column('paycvv') ) {
     if ( length($cgi->param('paycvv') ) ) {
-      if ( cardtype($payinfo) eq 'American Express card' ) {
+      if ( $cgi->param('paycvv') =~ /^\*+$/ ) {
+        $paycvv = $cust_main->paycvv;
+      } elsif ( cardtype($payinfo) eq 'American Express card' ) {
         $cgi->param('paycvv') =~ /^(\d{4})$/
           or errorpage("CVV2 (CID) for American Express cards is four digits.");
         $paycvv = $1;
@@ -202,6 +206,7 @@ if ( $cgi->param('batch') ) {
                                      'payinfo'  => $payinfo,
                                      'paydate'  => "$year-$month-01",
                                      'payname'  => $payname,
+                                     'processing-fee' => $processing_fee,
                                      map { $_ => scalar($cgi->param($_)) } 
                                        @{$payby2fields{$payby}}
                                    );
@@ -223,6 +228,7 @@ if ( $cgi->param('batch') ) {
     'discount_term' => $discount_term,
     'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
     'no_invnum'     => 1,
+    'processing-fee' => $processing_fee,
     map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
   );
   errorpage($error) if $error;