summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2018-05-11 11:29:36 -0400
committerChristopher Burger <burgerc@freeside.biz>2018-05-24 08:02:52 -0400
commit9f40a9761707d5ea38e3a53e01ed2dab31aabca7 (patch)
tree167b9ad1ea8a08b04cb10015e9b14d73ee3c54af /FS/FS/cust_main
parent44966ebb81f3dba2aeefa108744edb960320614c (diff)
RT# 79737 - Added ability to us a cc surcharge of a flat fee.
Conflicts: httemplate/elements/tr-select-payment_options.html
Diffstat (limited to 'FS/FS/cust_main')
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm22
1 files changed, 16 insertions, 6 deletions
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index e2b1c7d..df14104 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -421,6 +421,8 @@ sub realtime_bop {
$options{amount} = $amount;
}
+ return '' unless $options{amount} > 0;
+
# set fields from passed cust_payby
_bop_cust_payby_options(\%options);
@@ -454,16 +456,24 @@ sub realtime_bop {
if $conf->config('credit-card-surcharge-percentage', $self->agentnum)
&& $options{method} eq 'CC';
+ my $cc_surcharge_flat = 0;
+ $cc_surcharge_flat = $conf->config('credit-card-surcharge-flatfee', $self->agentnum)
+ if $conf->config('credit-card-surcharge-flatfee', $self->agentnum)
+ && $options{method} eq 'CC';
+
# always add cc surcharge if called from event
- if($options{'cc_surcharge_from_event'} && $cc_surcharge_pct > 0) {
- $cc_surcharge = $options{'amount'} * $cc_surcharge_pct / 100;
+ if($options{'cc_surcharge_from_event'} && ($cc_surcharge_pct > 0 || $cc_surcharge_flat > 0)) {
+ if ($options{'amount'} > 0) {
+ $cc_surcharge = ($options{'amount'} * ($cc_surcharge_pct / 100)) + $cc_surcharge_flat;
$options{'amount'} += $cc_surcharge;
$options{'amount'} = sprintf("%.2f", $options{'amount'}); # round (again)?
+ }
}
- elsif($cc_surcharge_pct > 0) { # we're called not from event (i.e. from a
- # payment screen), so consider the given
- # amount as post-surcharge
- $cc_surcharge = $options{'amount'} - ($options{'amount'} / ( 1 + $cc_surcharge_pct/100 ));
+ elsif($cc_surcharge_pct > 0 || $cc_surcharge_flat > 0) {
+ # we're called not from event (i.e. from a
+ # payment screen), so consider the given
+ # amount as post-surcharge
+ $cc_surcharge = $options{'amount'} - (($options{'amount'} - $cc_surcharge_flat) / ( 1 + $cc_surcharge_pct/100 )) if $options{'amount'} > 0;
}
$cc_surcharge = sprintf("%.2f",$cc_surcharge) if $cc_surcharge > 0;