From 8800e519dc0e4b8eee4ab2cddc74d52c205bc536 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Sep 2009 12:29:16 +0000 Subject: processing fee on credit card recharges, RT#5889 --- httemplate/misc/payment.cgi | 73 ++++++++++++++++++++++++++++++++++--- httemplate/misc/process/payment.cgi | 14 +++++++ 2 files changed, 82 insertions(+), 5 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 45aeacad4..472763b2d 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -10,16 +10,66 @@ % #include( '/elements/table.html', '#cccccc' ) +% my $amount = $balance > 0 ? sprintf("%.2f", $balance) : ''; + <% ntable('#cccccc') %> Payment amount - +
- $"> + <% $money_char %> + +% if ( $fee ) { + + + + + <% $money_char . $fee %> + + <% $fee_pkg->pkg |h %> + = + + <% length($amount) ? $money_char. sprintf('%.2f', $amount + $fee ) : '' %> TOTAL + +% }
+% if ( $fee ) { + + + +% } + + % if ( $payby eq 'CARD' ) { % % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); @@ -237,16 +287,29 @@ my $balance = $cust_main->balance; my $payinfo = ''; -#false laziness w/selfservice make_payment.html shortcut for one-country my $conf = new FS::Conf; + +my $money_char = $conf->config('money_char') || '$'; + +#false laziness w/selfservice make_payment.html shortcut for one-country my %states = map { $_->state => 1 } qsearch('cust_main_county', { 'country' => $conf->config('countrydefault') || 'US' } ); my @states = sort { $a cmp $b } keys %states; -my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; +my $fee = ''; +my $fee_pkg = ''; +if ( $conf->config('manual_process-pkgpart') ) { + $fee_pkg = + qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } ); - + #well ->unit_setup or ->calc_setup both call for a $cust_pkg + # (though ->unit_setup doesn't use it...) + $fee = $fee_pkg->option('setup_fee') + if $fee_pkg; #in case.. better than dying with a perl traceback +} +my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; + diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index ea0c7946d..d41bc0f14 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -32,6 +32,11 @@ $cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/ my $amount = $1; errorpage("amount <= 0") unless $amount > 0; +if ( $cgi->param('fee') =~ /^\s*(\d*(\.\d\d)?)\s*$/ ) { + my $fee = $1; + $amount = sprintf('%.2f', $amount + $fee); +} + $cgi->param('year') =~ /^(\d+)$/ or errorpage("illegal year ". $cgi->param('year')); my $year = $1; @@ -143,6 +148,15 @@ if ( $cgi->param('batch') ) { ); errorpage($error) if $error; + #no error, so order the fee package if applicable... + if ( $cgi->param('fee_pkgpart') =~ /^(\d+)$/ ) { + my $error = $cust_main->order_pkg( + 'cust_pkg' => new FS::cust_pkg { 'pkgpart' => $1 } + ); + errorpage("payment processed successfully, but error ordering fee: $error") + if $error; + } + $cust_main->apply_payments; } -- cgit v1.2.1