From c647fbae23dc64cdecb1c6fa6fee671cca7e8e7a Mon Sep 17 00:00:00 2001 From: levinse Date: Tue, 7 Jun 2011 16:49:07 +0000 Subject: [PATCH] Billing_Realtime.pm: skip void attempt on refund if gateway doesn't support void, RT13058 --- FS/FS/cust_main/Billing_Realtime.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index fd192416d..545e94339 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -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') ) -- 2.11.0