[freeside-commits] freeside/fs_selfservice/FS-SelfService/cgi discount_term.html, NONE, 1.1 make_ach_payment.html, 1.6, 1.7 make_payment.html, 1.19, 1.20 myaccount.html, 1.17, 1.18 selfservice.cgi, 1.45, 1.46

Jeff Finucane,420,, jeff at wavetail.420.am
Wed Sep 22 12:16:20 PDT 2010


Update of /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi
In directory wavetail.420.am:/tmp/cvs-serv19099/fs_selfservice/FS-SelfService/cgi

Modified Files:
	make_ach_payment.html make_payment.html myaccount.html 
	selfservice.cgi 
Added Files:
	discount_term.html 
Log Message:
prepayment discounts rt#5318

Index: make_ach_payment.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- make_ach_payment.html	16 Feb 2010 18:36:41 -0000	1.6
+++ make_ach_payment.html	22 Sep 2010 19:16:18 -0000	1.7
@@ -21,6 +21,7 @@
     </TD></TR></TABLE>
   </TD>
 </TR>
+<%= include('discount_term') %>
 <%= include('check') %>
 <TR>
   <TD COLSPAN=2>

Index: selfservice.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/selfservice.cgi,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -w -d -r1.45 -r1.46
--- selfservice.cgi	21 Jan 2010 08:38:52 -0000	1.45
+++ selfservice.cgi	22 Sep 2010 19:16:18 -0000	1.46
@@ -73,7 +73,7 @@
 
 #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 @@
 
 #--
 
-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 @@
   $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 @@
     'save'       => $save,
     'auto'       => $auto,
     'paybatch'   => $paybatch,
+    'discount_term' => $discount_term,
   );
 
 }
@@ -529,6 +535,20 @@
   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 );
 }

Index: myaccount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/myaccount.html,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -w -d -r1.17 -r1.18
--- myaccount.html	21 Jan 2010 08:34:01 -0000	1.17
+++ myaccount.html	22 Sep 2010 19:16:18 -0000	1.18
@@ -14,7 +14,15 @@
   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>!;
   }
 } %>
 <%=

--- NEW FILE: discount_term.html ---
<%=
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 .= '';
%>

Index: make_payment.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/make_payment.html,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -d -r1.19 -r1.20
--- make_payment.html	16 Feb 2010 18:36:41 -0000	1.19
+++ make_payment.html	22 Sep 2010 19:16:18 -0000	1.20
@@ -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&nbsp;type</TH>
   <TD COLSPAN=7>
     <SELECT NAME="card_type"><OPTION></OPTION>



More information about the freeside-commits mailing list