From a53dc991aa0c04c5b9a5d06256100af5e93943e1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Mar 2009 10:34:30 +0000 Subject: apply byte values from prepaid cards as well as time value, RT#4995 --- httemplate/misc/process/recharge_svc.html | 103 +++++++++++++++--------------- 1 file changed, 51 insertions(+), 52 deletions(-) (limited to 'httemplate/misc/process') diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html index 147b9533a..8c4d13e63 100755 --- a/httemplate/misc/process/recharge_svc.html +++ b/httemplate/misc/process/recharge_svc.html @@ -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") %> +%} <%init> my $conf = new FS::Conf; @@ -89,4 +40,52 @@ my $oldAutoCommit = $FS::UID::AutoCommit; 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; +} + -- cgit v1.2.1 From 26119738eaf2b519d91c855c23986f873303887f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Mar 2009 07:14:29 +0000 Subject: allow country selection on credit card entry, RT#4997 --- httemplate/misc/process/payment.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/misc/process') diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 2baca1e39..ea0c7946d 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -44,7 +44,7 @@ $cgi->param('payby') =~ /^(CARD|CHEK)$/ or errorpage("illegal payby ". $cgi->param('payby')); my $payby = $1; my %payby2fields = ( - 'CARD' => [ qw( address1 address2 city state zip ) ], + 'CARD' => [ qw( address1 address2 city county state zip country ) ], 'CHEK' => [ qw( ss paytype paystate stateid stateid_state ) ], ); my %type = ( 'CARD' => 'credit card', -- cgit v1.2.1 From 42682206b4ba30de01c82743042f5fb9d48a93ed Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 23 Mar 2009 23:33:04 +0000 Subject: more DTRT with usage on service transfer between packages and recharges RT #2884, #5040 + #4995 fallout --- httemplate/misc/process/recharge_svc.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/misc/process') diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html index 8c4d13e63..5f68bf151 100755 --- a/httemplate/misc/process/recharge_svc.html +++ b/httemplate/misc/process/recharge_svc.html @@ -1,6 +1,6 @@ %if ($error) { % $cgi->param('error', $error); -<% cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %> +<% $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %> %} else { <% header("Package recharged") %>