diff options
author | jeff <jeff> | 2010-09-22 19:16:20 +0000 |
---|---|---|
committer | jeff <jeff> | 2010-09-22 19:16:20 +0000 |
commit | 5250c44bd7f282c7d782bf0e8349af12376929df (patch) | |
tree | b2afcd8e47270c6f5b78cff378849168d17ed765 /fs_selfservice | |
parent | 60ee9af0e885def0dd61f4a5506ac0e55d779e89 (diff) |
prepayment discounts rt#5318
Diffstat (limited to 'fs_selfservice')
5 files changed, 52 insertions, 4 deletions
diff --git a/fs_selfservice/FS-SelfService/cgi/discount_term.html b/fs_selfservice/FS-SelfService/cgi/discount_term.html new file mode 100644 index 0000000..7d9ee4d --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/discount_term.html @@ -0,0 +1,17 @@ +<%= +if ( scalar(keys %discount_terms_hash) ) { + $OUT .= '<TR>'; + $OUT .= '<TD ALIGN="right">Prepayment for</TD>'; + $OUT .= '<TD>'; + $OUT .= '<SELECT NAME="discount_term">'; + $OUT .= qq(<OPTION VALUE="">1 month\n); + foreach ( keys %discount_terms_hash ) { + $selected = $discount_term eq $_ ? ' SELECTED' : ''; + $OUT .= qq(<OPTION$selected VALUE="$_">$_ months\n); + } + $OUT .= '</SELECT>'; + $OUT .= '</TD>'; + $OUT .= '</TR>'; +} +$OUT .= ''; +%> diff --git a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html index 09391e7..5b81b00 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html @@ -21,6 +21,7 @@ </TD></TR></TABLE> </TD> </TR> +<%= include('discount_term') %> <%= include('check') %> <TR> <TD COLSPAN=2> diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index e454647..645b68e 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -20,7 +20,9 @@ $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%=sprintf("%.2f",$balance)%>"> </TD></TR></TABLE> </TD> -</TR><TR> +</TR> +<%= include('discount_term') %> +<TR> <TH ALIGN="right">Card type</TH> <TD COLSPAN=7> <SELECT NAME="card_type"><OPTION></OPTION> diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index 0de7385..6b4187f 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -14,7 +14,15 @@ Hello <%= $name %>!<BR><BR> if (scalar(grep $_, @hide_payment_fields)) { $OUT .= qq! <B><A HREF="${url}make_thirdparty_payment&payby_method=CC">Make a payment</A></B><BR><BR>!; } else { - $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR><BR>!; + $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR>!; + foreach my $term ( sort { $b <=> $a } keys %discount_terms_hash ) { + my $saved = $discount_terms_hash{$term}->[1]; + my $amount = $discount_terms_hash{$term}->[2]; + my $savings = ( $amount + $saved > 0 ) + ? sprintf('%d', $saved / ( $amount + $saved ) * 100 ) : '0'; + $OUT .= qq! <B><A HREF="${url}make_term_payment;discount_term=$term;amount=$amount">Save $savings\% by paying for $term months: $amount</A></B><BR>!; + } + $OUT .= qq! <BR>!; } } %> <%= diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 2252852..711bd4e 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -73,7 +73,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|make_ach_payment|make_thirdparty_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_cdr_details|view_support_details|change_password|process_change_password)$/ + /^(myaccount|view_invoice|make_payment|make_ach_payment|make_term_payment|make_thirdparty_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_cdr_details|view_support_details|change_password|process_change_password)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -105,7 +105,8 @@ do_template($action, { #-- -sub myaccount { customer_info( 'session_id' => $session_id ); } +use Data::Dumper; +sub myaccount { my $result = customer_info( 'session_id' => $session_id ); warn Dumper($result); $result;} sub change_bill { my $payment_info = payment_info( 'session_id' => $session_id ); @@ -427,6 +428,10 @@ sub payment_results { $cgi->param('paybatch') =~ /^([\w\-\.]+)$/ or die "illegal paybatch"; my $paybatch = $1; + $cgi->param('discount_term') =~ /^(\d*)$/ or die "illegal discount_term"; + my $discount_term = $1; + + process_payment( 'session_id' => $session_id, 'payby' => 'CARD', @@ -445,6 +450,7 @@ sub payment_results { 'save' => $save, 'auto' => $auto, 'paybatch' => $paybatch, + 'discount_term' => $discount_term, ); } @@ -529,6 +535,20 @@ sub make_thirdparty_payment { realtime_collect( 'session_id' => $session_id, 'method' => $1 ); } +sub make_term_payment { + $cgi->param('amount') =~ /^(\d+\.\d{2})$/ + or die "illegal payment amount"; + my $balance = $1; + $cgi->param('discount_term') =~ /^(\d+)$/ + or die "illegal discount term"; + my $discount_term = $1; + $action = 'make_payment'; + ({ %{payment_info( 'session_id' => $session_id )}, + 'balance' => $balance, + 'discount_term' => $discount_term, + }) +} + sub recharge_prepay { customer_info( 'session_id' => $session_id ); } |