X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling_Realtime.pm;fp=FS%2FFS%2Fcust_main%2FBilling_Realtime.pm;h=61acb1d920c2d2ad21ee7b32aafab8526a92eaf8;hp=f33c4549ac992da66725289d844817c8fa8aed35;hb=fdc589c5d08623f437df749c5e43360248ccce11;hpb=159e3b1170a3011738e0937ea1b155488ee5a83c diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index f33c4549a..61acb1d92 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -1311,14 +1311,14 @@ L for supported gateways. Available methods are: I, I and I -Available options are: I, I, I, I +Available options are: I, I, I, I Most gateways require a reference to an original payment transaction to refund, so you probably need to specify a I. I defaults to the original amount of the payment if not specified. -I specifies a reason for the refund. +I specifies a reason for the refund. I specifies the expiration date for a credit card overriding the value from the customer record or the payment record. Specified as yyyy-mm-dd @@ -1356,6 +1356,27 @@ sub realtime_refund_bop { $options{method} = $method; } + my ($reason, $reason_text); + if ( $options{'reasonnum'} ) { + # do this here, because we need the plain text reason string in case we + # void the payment + $reason = FS::reason->by_key($options{'reasonnum'}); + $reason_text = $reason->reason; + } else { + # support old 'reason' string parameter in case it's still used, + # or else set a default + $reason_text = $options{'reason'} || 'card or ACH refund'; + local $@; + $reason = FS::reason->new_or_existing( + reason => $reason_text, + type => 'Refund reason', + class => 'F', + ); + if ($@) { + return "failed to add refund reason: $@"; + } + } + if ( $DEBUG ) { warn "$me realtime_refund_bop (new): $options{method} refund\n"; warn " $_ => $options{$_}\n" foreach keys %options; @@ -1523,7 +1544,7 @@ sub realtime_refund_bop { if $conf->exists('business-onlinepayment-test_transaction'); $void->submit(); if ( $void->is_success ) { - my $error = $cust_pay->void($options{'reason'}); + my $error = $cust_pay->void($reason_text); if ( $error ) { # gah, even with transactions. my $e = 'WARNING: Card/ACH voided but database not updated - '. @@ -1648,7 +1669,7 @@ sub realtime_refund_bop { '_date' => '', 'payby' => $bop_method2payby{$options{method}}, 'payinfo' => $payinfo, - 'reason' => $options{'reason'} || 'card or ACH refund', + 'reasonnum' => $reason->reasonnum, 'gatewaynum' => $gatewaynum, # may be null 'processor' => $processor, 'auth' => $refund->authorization,