summaryrefslogtreecommitdiff
path: root/httemplate/misc/payment.cgi
diff options
context:
space:
mode:
authorivan <ivan>2009-09-25 12:29:16 +0000
committerivan <ivan>2009-09-25 12:29:16 +0000
commit8800e519dc0e4b8eee4ab2cddc74d52c205bc536 (patch)
tree63cc8c893b7e8a8b2d5b3ef3ffd6fc1e6a6ec590 /httemplate/misc/payment.cgi
parent5f0e4d1d57c18d5bb8a52de4f7d4f519db5327f0 (diff)
processing fee on credit card recharges, RT#5889
Diffstat (limited to 'httemplate/misc/payment.cgi')
-rw-r--r--httemplate/misc/payment.cgi73
1 files changed, 68 insertions, 5 deletions
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 45aeaca..472763b 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') %>
<TR>
<TH ALIGN="right">Payment amount</TH>
- <TD>
+ <TD COLSPAN=7>
<TABLE><TR><TD BGCOLOR="#ffffff">
- $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<% $balance > 0 ? sprintf("%.2f", $balance) : '' %>">
+ <% $money_char %><INPUT NAME = "amount"
+ TYPE = "text"
+ VALUE = "<% $amount %>"
+ SIZE = 8
+ STYLE = "text-align:right;"
+% if ( $fee ) {
+ onChange = "amount_changed(this)"
+ onKeyDown = "amount_changed(this)"
+ onKeyUp = "amount_changed(this)"
+ onKeyPress = "amount_changed(this)"
+% }
+ >
+ </TD><TD BGCOLOR="#cccccc">
+% if ( $fee ) {
+ <INPUT TYPE="hidden" NAME="fee_pkgpart" VALUE="<% $fee_pkg->pkgpart %>">
+ <INPUT TYPE="hidden" NAME="fee" VALUE="<% $fee %>">
+ <B><FONT SIZE='+1'>+</FONT>
+ <% $money_char . $fee %>
+ </B>
+ <% $fee_pkg->pkg |h %>
+ <B><FONT SIZE='+1'>=</FONT></B>
+ </TD><TD ID="ajax_total_cell" BGCOLOR="#dddddd" STYLE="border:1px solid blue">
+ <FONT SIZE="+1"><% length($amount) ? $money_char. sprintf('%.2f', $amount + $fee ) : '' %> TOTAL</FONT>
+
+% }
</TD></TR></TABLE>
</TD>
</TR>
+% if ( $fee ) {
+
+ <SCRIPT TYPE="text/javascript">
+
+ function amount_changed(what) {
+
+
+ var total = '';
+ if ( what.value.length ) {
+ total = parseFloat(what.value) + <% $fee %>;
+ /* total = Math.round(total*100)/100; */
+ total = '<% $money_char %>' + total.toFixed(2);
+ }
+
+ var total_cell = document.getElementById('ajax_total_cell');
+ total_cell.innerHTML = '<FONT SIZE="+1">' + total + ' TOTAL</FONT>';
+
+ }
+
+ </SCRIPT>
+
+% }
+
+
% 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') } );
-</%init>
+ #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;
+</%init>