[freeside-commits] freeside/FS/FS/ClientAPI MasonComponent.pm, 1.1, 1.2 MyAccount.pm, 1.85, 1.86
Ivan,,,
ivan at wavetail.420.am
Sun May 24 18:49:36 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv15684/FS/FS/ClientAPI
Modified Files:
MasonComponent.pm MyAccount.pm
Log Message:
international self-service payments, RT#1592
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- MyAccount.pm 18 May 2009 09:55:29 -0000 1.85
+++ MyAccount.pm 25 May 2009 01:49:33 -0000 1.86
@@ -506,7 +506,8 @@
}
my %payby2fields = (
- 'CARD' => [ qw( paystart_month paystart_year payissue address1 address2 city state zip payip ) ],
+ 'CARD' => [ qw( paystart_month paystart_year payissue payip
+ address1 address2 city state zip country ) ],
'CHEK' => [ qw( ss paytype paystate stateid stateid_state payip ) ],
);
@@ -527,8 +528,8 @@
my $new = new FS::cust_main { $cust_main->hash };
if ($payby eq 'CARD' || $payby eq 'DCRD') {
$new->set( $_ => $p->{$_} )
- foreach qw( payname paystart_month paystart_year payissue payip
- address1 address2 city state zip payinfo );
+ foreach qw( payinfo payname paystart_month paystart_year payissue payip
+ address1 address2 city state zip country );
$new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
} elsif ($payby eq 'CHEK' || $payby eq 'DCHK') {
$new->set( $_ => $p->{$_} )
Index: MasonComponent.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MasonComponent.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- MasonComponent.pm 21 Jul 2008 19:09:35 -0000 1.1
+++ MasonComponent.pm 25 May 2009 01:49:33 -0000 1.2
@@ -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 @@
/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 @@
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 @@
}
+#hmm
+sub _cache {
+ $cache ||= new FS::ClientAPI_SessionCache( {
+ 'namespace' => 'FS::ClientAPI::MyAccount',
+ } );
+}
+
1;
More information about the freeside-commits
mailing list