X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=479b19a4acc278e1e3fefcec4f2acf2fb5342e44;hb=c62991706722410987b249893f1323b4ba0e7a5f;hp=e5748ec3f8a9c0e75ef4976c44ca5f4ad4f8dc25;hpb=b5fbaadb1cb2893660e460a1d4a3cabe02774de7;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index e5748ec3f..479b19a4a 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2122,6 +2122,7 @@ sub realtime_refund_bop { #first try void if applicable if ( $cust_pay && $cust_pay->paid == $amount ) { #and check dates? + warn "FS::cust_main::realtime_bop: attempting void\n" if $DEBUG; my $void = new Business::OnlinePayment( $processor, @bop_options ); $void->content( 'action' => 'void', %content ); $void->submit(); @@ -2134,10 +2135,14 @@ sub realtime_refund_bop { warn $e; return $e; } + warn "FS::cust_main::realtime_bop: void successful\n" if $DEBUG; return ''; } } + warn "FS::cust_main::realtime_bop: void unsuccessful, trying refund\n" + if $DEBUG; + #massage data my $address = $self->address1; $address .= ", ". $self->address2 if $self->address2; @@ -2154,20 +2159,17 @@ 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"; - - #$content{cvv2} = $self->paycvv - # if defined $self->dbdef_table->column('paycvv') - # && length($self->paycvv); + if ( $method eq 'CC' ) { - #$content{recurring_billing} = 'YES' - # if qsearch('cust_pay', { 'custnum' => $self->custnum, - # 'payby' => 'CARD', - # 'payinfo' => $self->payinfo, } ); + if ( $cust_pay ) { + $content{card_number} = $cust_pay->payinfo; + #$self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; + #$content{expiration} = "$2/$1"; + } else { + $content{card_number} = $self->payinfo; + $self->paydate =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; + $content{expiration} = "$2/$1"; + } } elsif ( $method eq 'ECHECK' ) { ( $content{account_number}, $content{routing_code} ) = @@ -2183,7 +2185,7 @@ sub realtime_refund_bop { #then try refund my $refund = new Business::OnlinePayment( $processor, @bop_options ); - $refund->content( + my %sub_content = $refund->content( 'action' => 'credit', 'customer_id' => $self->custnum, 'last_name' => $paylast, @@ -2196,6 +2198,8 @@ sub realtime_refund_bop { 'country' => $self->country, %content, #after ); + warn join('', map { " $_ => $sub_content{$_}\n" } keys %sub_content ) + if $DEBUG > 1; $refund->submit(); return "$processor error: ". $refund->error_message