X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling_Realtime.pm;h=48651e69ca2163275cacb45f0d98f039e7cba62c;hb=0e7c29b192fff137d3b9167b29633a94f94b995f;hp=fd192416d132682d68d03436c8c1d99155806e4a;hpb=b8d1f6382bd483b4c5718a7930ea2493a1686d50;p=freeside.git diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index fd192416d..48651e69c 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -4,7 +4,6 @@ use strict; use vars qw( $conf $DEBUG $me ); use vars qw( $realtime_bop_decline_quiet ); #ugh use Data::Dumper; -use Digest::MD5 qw(md5_base64); use Business::CreditCard 0.28; use FS::UID qw( dbh ); use FS::Record qw( qsearch qsearchs ); @@ -13,6 +12,7 @@ use FS::payby; use FS::cust_pay; use FS::cust_pay_pending; use FS::cust_refund; +use FS::banned_pay; $realtime_bop_decline_quiet = 0; @@ -401,11 +401,11 @@ sub realtime_bop { # check for banned credit card/ACH ### - my $ban = qsearchs('banned_pay', { + my $ban = FS::banned_pay->ban_search( 'payby' => $bop_method2payby{$options{method}}, - 'payinfo' => md5_base64($options{payinfo}), - } ); - return "Banned credit card" if $ban; + 'payinfo' => $options{payinfo}, + ); + return "Banned credit card" if $ban && $ban->bantype ne 'warn'; ### # massage data @@ -1285,7 +1285,8 @@ Implementation note: If I is unspecified or equal to the amount of the orignal payment, first an attempt is made to "void" the transaction via the gateway (to cancel a not-yet settled transaction) and then if that fails, the normal attempt is made to "refund" ("credit") the transaction via the -gateway is attempted. +gateway is attempted. No attempt to "void" the transaction is made if the +gateway has introspection data and doesn't support void. #The additional options I, I, I, I, I, #I, I and I are also available. Any of these options, @@ -1415,14 +1416,28 @@ sub realtime_refund_bop { } #first try void if applicable + my $void = new Business::OnlinePayment( $processor, @bop_options ); + + my $tryvoid = 1; + if ($void->can('info')) { + my $paytype = ''; + $paytype = 'ECHECK' if $cust_pay && $cust_pay->payby eq 'CHEK'; + $paytype = 'CC' if $cust_pay && $cust_pay->payby eq 'CARD'; + my %supported_actions = $void->info('supported_actions'); + $tryvoid = 0 + if ( %supported_actions && $paytype + && defined($supported_actions{$paytype}) + && !grep{ $_ eq 'Void' } @{$supported_actions{$paytype}} ); + } + if ( $cust_pay && $cust_pay->paid == $amount && ( ( not defined($disable_void_after) ) || ( time < ($cust_pay->_date + $disable_void_after ) ) ) + && $tryvoid ) { warn " attempting void\n" if $DEBUG > 1; - my $void = new Business::OnlinePayment( $processor, @bop_options ); if ( $void->can('info') ) { if ( $cust_pay->payby eq 'CARD' && $void->info('CC_void_requires_card') )