[freeside-commits] freeside/httemplate/misc/process recharge_svc.html, 1.7, 1.8
Ivan,,,
ivan at wavetail.420.am
Sun Mar 15 03:34:32 PDT 2009
Update of /home/cvs/cvsroot/freeside/httemplate/misc/process
In directory wavetail.420.am:/tmp/cvs-serv23471/httemplate/misc/process
Modified Files:
recharge_svc.html
Log Message:
apply byte values from prepaid cards as well as time value, RT#4995
Index: recharge_svc.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/process/recharge_svc.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- recharge_svc.html 13 Jan 2008 21:14:19 -0000 1.7
+++ recharge_svc.html 15 Mar 2009 10:34:30 -0000 1.8
@@ -1,62 +1,13 @@
-%unless ($error) {
-%
-% my ($amount, $seconds, $up, $down, $total) = (0, 0, 0, 0, 0);
-% #should probably use payby.pm but whatever
-% if ($payby eq 'PREP') {
-% $error = $cust_main->get_prepay($prepaid, \$amount, \$seconds, \$up, \$down, \$total)
-% || $svc_acct->increment_seconds($seconds)
-% || $svc_acct->increment_upbytes($up)
-% || $svc_acct->increment_downbytes($down)
-% || $svc_acct->increment_totalbytes($total)
-% || $cust_main->insert_cust_pay_prepay( $amount, $prepaid );
-% } elsif ( $payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP)$/ ) {
-% my $part_pkg = $svc_acct->cust_svc->cust_pkg->part_pkg;
-% $amount = $part_pkg->option('recharge_amount', 1);
-% my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_) }
-% grep { $part_pkg->option($_, 1) }
-% qw ( recharge_seconds recharge_upbytes recharge_downbytes
-% recharge_totalbytes );
-%
-% my $description = "Recharge";
-% $description .= " $rhash{seconds}s" if $rhash{seconds};
-% $description .= " $rhash{upbytes} up" if $rhash{upbytes};
-% $description .= " $rhash{downbytes} down" if $rhash{downbytes};
-% $description .= " $rhash{totalbytes} total" if $rhash{totalbytes};
-%
-% $error = $cust_main->charge($amount, "Recharge " . $svc_acct->label,
-% $description, $part_pkg->taxclass);
-%
-% if ($part_pkg->option('recharge_reset', 1)) {
-% $error ||= $svc_acct->set_usage(\%rhash);
-% }else{
-% $error ||= $svc_acct->recharge(\%rhash);
-% }
-%
-% my $old_balance = $cust_main->balance;
-% $error ||= $cust_main->bill;
-% $error ||= $cust_main->apply_payments_and_credits;
-% my $bill_error = $cust_main->collect('realtime' => 1) unless $error;
-% $error ||= "Failed to collect - $bill_error"
-% if $cust_main->balance > $old_balance && $cust_main->balance > 0
-% && $payby ne 'BILL';
-%
-% } else {
-% $error = "fatal error - unknown payby: $payby";
-% }
-%}
-%
%if ($error) {
% $cgi->param('error', $error);
-% $dbh->rollback if $oldAutoCommit;
-% print $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string );
-%}
-%$dbh->commit or die $dbh->errstr if $oldAutoCommit;
-%
+<% cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %>
+%} else {
<% header("Package recharged") %>
<SCRIPT TYPE="text/javascript">
window.top.location.reload();
</SCRIPT>
</BODY></HTML>
+%}
<%init>
my $conf = new FS::Conf;
@@ -89,4 +40,52 @@
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+unless ($error) {
+
+ #should probably use payby.pm but whatever
+ if ($payby eq 'PREP') {
+ $error = $cust_main->recharge_prepay( $prepaid );
+ } elsif ( $payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP)$/ ) {
+ my $part_pkg = $svc_acct->cust_svc->cust_pkg->part_pkg;
+ $amount = $part_pkg->option('recharge_amount', 1);
+ my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_) }
+ grep { $part_pkg->option($_, 1) }
+ qw ( recharge_seconds recharge_upbytes recharge_downbytes
+ recharge_totalbytes );
+
+ my $description = "Recharge";
+ $description .= " $rhash{seconds}s" if $rhash{seconds};
+ $description .= " $rhash{upbytes} up" if $rhash{upbytes};
+ $description .= " $rhash{downbytes} down" if $rhash{downbytes};
+ $description .= " $rhash{totalbytes} total" if $rhash{totalbytes};
+
+ $error = $cust_main->charge($amount, "Recharge " . $svc_acct->label,
+ $description, $part_pkg->taxclass);
+
+ if ($part_pkg->option('recharge_reset', 1)) {
+ $error ||= $svc_acct->set_usage(\%rhash);
+ }else{
+ $error ||= $svc_acct->recharge(\%rhash);
+ }
+
+ my $old_balance = $cust_main->balance;
+ $error ||= $cust_main->bill;
+ $error ||= $cust_main->apply_payments_and_credits;
+ my $bill_error = $cust_main->collect('realtime' => 1) unless $error;
+ $error ||= "Failed to collect - $bill_error"
+ if $cust_main->balance > $old_balance && $cust_main->balance > 0
+ && $payby ne 'BILL';
+
+ } else {
+ $error = "fatal error - unknown payby: $payby";
+ }
+
+}
+
+if ($error) {
+ $dbh->rollback if $oldAutoCommit;
+} else {
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+}
+
</%init>
More information about the freeside-commits
mailing list