freeside/FS/FS/ClientAPI MyAccount.pm,1.35,1.36
Ivan Kohler
ivan at pouncequick.420.am
Wed Jun 8 02:03:10 PDT 2005
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory pouncequick:/tmp/cvs-serv25069/FS/FS/ClientAPI
Modified Files:
MyAccount.pm
Log Message:
prepaid card recharge
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- MyAccount.pm 21 Mar 2005 22:13:37 -0000 1.35
+++ MyAccount.pm 8 Jun 2005 09:03:05 -0000 1.36
@@ -6,6 +6,7 @@
use Digest::MD5 qw(md5_hex);
use Date::Format;
use Business::CreditCard;
+use Time::Duration;
use FS::CGI qw(small_custview); #doh
use FS::Conf;
use FS::Record qw(qsearch qsearchs);
@@ -135,12 +136,16 @@
$return{'postal_invoicing'} =
0 < ( grep { $_ eq 'POST' } $cust_main->invoicing_list );
- } else { #no customer record
+ } elsif ( $session->{'svcnum'} ) { #no customer record
my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $session->{'svcnum'} } )
or die "unknown svcnum";
$return{name} = $svc_acct->email;
+ } else {
+
+ return { 'error' => 'Expired session' }; #XXX redirect to login w/this err!
+
}
return { 'error' => '',
@@ -354,6 +359,36 @@
}
return { 'error' => '' };
+
+}
+
+sub process_prepay {
+
+ my $p = shift;
+
+ my $session = _cache->get($p->{'session_id'})
+ or return { 'error' => "Can't resume session" }; #better error message
+
+ my %return;
+
+ my $custnum = $session->{'custnum'};
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my( $amount, $seconds ) = ( 0, 0 );
+ my $error = $cust_main->recharge_prepay( $p->{'prepaid_cardnum'},
+ \$amount,
+ \$seconds
+ );
+
+ return { 'error' => $error } if $error;
+
+ return { 'error' => '',
+ 'amount' => $amount,
+ 'seconds' => $seconds,
+ 'duration' => duration_exact($seconds),
+ };
}
More information about the freeside-commits
mailing list