diff options
author | ivan <ivan> | 2009-05-25 01:49:34 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-05-25 01:49:34 +0000 |
commit | d6b6f81e383f9d876e67e9704914e887a331012e (patch) | |
tree | 5385587c8c736ae27a4fa411e58fc49482eb25b9 /FS/FS/ClientAPI/MasonComponent.pm | |
parent | aa6c509c76c647d05d7bc94ca58effa845cac245 (diff) |
international self-service payments, RT#1592
Diffstat (limited to 'FS/FS/ClientAPI/MasonComponent.pm')
-rw-r--r-- | FS/FS/ClientAPI/MasonComponent.pm | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm index 78ea9bd..d158ce8 100644 --- a/FS/FS/ClientAPI/MasonComponent.pm +++ b/FS/FS/ClientAPI/MasonComponent.pm @@ -1,9 +1,13 @@ package FS::ClientAPI::MasonComponent; use strict; -use vars qw($DEBUG $me); +use vars qw( $cache $DEBUG $me ); +use subs qw( _cache ); use FS::Mason qw( mason_interps ); use FS::Conf; +use FS::ClientAPI_SessionCache; +use FS::Record qw(qsearchs); +use FS::cust_main; $DEBUG = 0; $me = '[FS::ClientAPI::MasonComponent]'; @@ -13,6 +17,24 @@ my %allowed_comps = map { $_=>1 } qw( /misc/areacodes.cgi /misc/exchanges.cgi /misc/phonenums.cgi + /misc/states.cgi + /misc/counties.cgi +); + +my %session_comps = map { $_=>1 } qw( + /elements/location.html +); + +my %session_callbacks = ( + '/elements/location.html' => sub { + my( $custnum, $argsref ) = @_; + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return "unknown custnum $custnum"; + my %args = @$argsref; + $args{object} = $cust_main; + @$argsref = ( %args ); + return ''; #no error + }, ); my $outbuf; @@ -24,12 +46,23 @@ sub mason_comp { warn "$me mason_comp called on $packet\n" if $DEBUG; my $comp = $packet->{'comp'}; - unless ( $allowed_comps{$comp} ) { + unless ( $allowed_comps{$comp} || $session_comps{$comp} ) { return { 'error' => 'Illegal component' }; } my @args = $packet->{'args'} ? @{ $packet->{'args'} } : (); + if ( $session_comps{$comp} ) { + + my $session = _cache->get($packet->{'session_id'}) + or return ( 'error' => "Can't resume session" ); #better error message + my $custnum = $session->{'custnum'}; + + my $error = &{ $session_callbacks{$comp} }( $custnum, \@args ); + return { 'error' => $error } if $error; + + } + my $conf = new FS::Conf; $FS::Mason::Request::FSURL = $conf->config('selfservice_server-base_url'); $FS::Mason::Request::QUERY_STRING = $packet->{'query_string'} || ''; @@ -43,4 +76,11 @@ sub mason_comp { } +#hmm +sub _cache { + $cache ||= new FS::ClientAPI_SessionCache( { + 'namespace' => 'FS::ClientAPI::MyAccount', + } ); +} + 1; |