and store the refund correctly
[freeside.git] / FS / FS / cust_main.pm
index deb14ae..be81f33 100644 (file)
@@ -2159,31 +2159,29 @@ sub realtime_refund_bop {
     $payname =  "$payfirst $paylast";
   }
 
-  if ( $method eq 'CC' ) { 
-
-    $content{card_number} = $self->payinfo;
-    $self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
-    $content{expiration} = "$2/$1";
+  my $payinfo = '';
+  if ( $method eq 'CC' ) {
 
-    #$content{cvv2} = $self->paycvv
-    #  if defined $self->dbdef_table->column('paycvv')
-    #     && length($self->paycvv);
-
-    #$content{recurring_billing} = 'YES'
-    #  if qsearch('cust_pay', { 'custnum' => $self->custnum,
-    #                           'payby'   => 'CARD',
-    #                           'payinfo' => $self->payinfo, } );
+    if ( $cust_pay ) {
+      $content{card_number} = $payinfo = $cust_pay->payinfo;
+      #$self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
+      #$content{expiration} = "$2/$1";
+    } else {
+      $content{card_number} = $payinfo = $self->payinfo;
+      $self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
+      $content{expiration} = "$2/$1";
+    }
 
   } elsif ( $method eq 'ECHECK' ) {
     ( $content{account_number}, $content{routing_code} ) =
-      split('@', $self->payinfo);
+      split('@', $payinfo = $self->payinfo);
     $content{bank_name} = $self->payname;
     $content{account_type} = 'CHECKING';
     $content{account_name} = $payname;
     $content{customer_org} = $self->company ? 'B' : 'I';
     $content{customer_ssn} = $self->ss;
   } elsif ( $method eq 'LEC' ) {
-    $content{phone} = $self->payinfo;
+    $content{phone} = $payinfo = $self->payinfo;
   }
 
   #then try refund
@@ -2232,7 +2230,7 @@ sub realtime_refund_bop {
     'refund'   => $amount,
     '_date'    => '',
     'payby'    => $method2payby{$method},
-    'payinfo'  => $self->payinfo,
+    'payinfo'  => $payinfo,
     'paybatch' => $paybatch,
     'reason'   => $options{'reason'} || 'card or ACH refund',
   } );