projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
quiet self-service server cancels
[freeside.git]
/
FS
/
FS
/
ClientAPI
/
Signup.pm
diff --git
a/FS/FS/ClientAPI/Signup.pm
b/FS/FS/ClientAPI/Signup.pm
index
0bb9f7b
..
36045d9
100644
(file)
--- a/
FS/FS/ClientAPI/Signup.pm
+++ b/
FS/FS/ClientAPI/Signup.pm
@@
-23,7
+23,8
@@
sub signup_info {
my $conf = new FS::Conf;
my $conf = new FS::Conf;
- my $signup_info = {
+ use vars qw($signup_info); #cache for performance;
+ $signup_info ||= {
'cust_main_county' =>
[ map { $_->hashref } qsearch('cust_main_county', {}) ],
'cust_main_county' =>
[ map { $_->hashref } qsearch('cust_main_county', {}) ],
@@
-57,7
+58,10
@@
sub signup_info {
};
};
- if ( $conf->config('signup_server-default_agentnum') ) {
+ if (
+ $conf->config('signup_server-default_agentnum')
+ && !exists $signup_info->{'part_pkg'} #cache for performance
+ ) {
my $agentnum = $conf->config('signup_server-default_agentnum');
my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } )
or die "fatal: signup_server-default_agentnum $agentnum not found\n";
my $agentnum = $conf->config('signup_server-default_agentnum');
my $agent = qsearchs( 'agent', { 'agentnum' => $agentnum } )
or die "fatal: signup_server-default_agentnum $agentnum not found\n";
@@
-79,14
+83,14
@@
sub new_customer {
my $packet = shift;
my $conf = new FS::Conf;
my $packet = shift;
my $conf = new FS::Conf;
- my $error = '';
#things that aren't necessary in base class, but are for signup server
#return "Passwords don't match"
# if $hashref->{'_password'} ne $hashref->{'_password2'}
#things that aren't necessary in base class, but are for signup server
#return "Passwords don't match"
# if $hashref->{'_password'} ne $hashref->{'_password2'}
- $error ||= gettext('empty_password') unless $packet->{'_password'};
+ return { 'error' => gettext('empty_password') }
+ unless $packet->{'_password'};
# a bit inefficient for large numbers of pops
# a bit inefficient for large numbers of pops
- $error ||= gettext('no_access_number_selected')
+ return { 'error' => gettext('no_access_number_selected') }
unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
#shares some stuff with htdocs/edit/process/cust_main.cgi... take any
unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
#shares some stuff with htdocs/edit/process/cust_main.cgi... take any
@@
-105,7
+109,7
@@
sub new_customer {
} );
} );
- $error ||= "Illegal payment type"
+ return { 'error' => "Illegal payment type" }
unless grep { $_ eq $packet->{'payby'} }
$conf->config('signup_server-payby');
unless grep { $_ eq $packet->{'payby'} }
$conf->config('signup_server-payby');
@@
-116,17
+120,19
@@
sub new_customer {
$packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/;
my $pkgpart = $1;
$packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/;
my $pkgpart = $1;
+ return { 'error' => 'Please select a package' } unless $pkgpart; #msgcat
my $part_pkg =
qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } )
my $part_pkg =
qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } )
- or
$error ||= "WARNING: unknown pkgpart: $pkgpart"
;
- my $svcpart = $part_pkg->svcpart('svc_acct')
unless $error
;
+ or
return { 'error' => "WARNING: unknown pkgpart: $pkgpart" }
;
+ my $svcpart = $part_pkg->svcpart('svc_acct');
my $cust_pkg = new FS::cust_pkg ( {
#later#'custnum' => $custnum,
'pkgpart' => $packet->{'pkgpart'},
} );
my $cust_pkg = new FS::cust_pkg ( {
#later#'custnum' => $custnum,
'pkgpart' => $packet->{'pkgpart'},
} );
- $error ||= $cust_pkg->check;
+ my $error = $cust_pkg->check;
+ return { 'error' => $error } if $error;
my $svc_acct = new FS::svc_acct ( {
'svcpart' => $svcpart,
my $svc_acct = new FS::svc_acct ( {
'svcpart' => $svcpart,
@@
-135,17
+141,19
@@
sub new_customer {
} );
my $y = $svc_acct->setdefault; # arguably should be in new method
} );
my $y = $svc_acct->setdefault; # arguably should be in new method
-
$error ||= $y unless
ref($y);
+
return { 'error' => $y } if $y && !
ref($y);
- $error ||= $svc_acct->check;
+ $error = $svc_acct->check;
+ return { 'error' => $error } if $error;
use Tie::RefHash;
tie my %hash, 'Tie::RefHash';
%hash = ( $cust_pkg => [ $svc_acct ] );
#msgcat
use Tie::RefHash;
tie my %hash, 'Tie::RefHash';
%hash = ( $cust_pkg => [ $svc_acct ] );
#msgcat
- $error ||= $cust_main->insert( \%hash, \@invoicing_list, 'noexport' => 1 );
+ $error = $cust_main->insert( \%hash, \@invoicing_list, 'noexport' => 1 );
+ return { 'error' => $error } if $error;
- if (
! $error &&
$conf->exists('signup_server-realtime') ) {
+ if ( $conf->exists('signup_server-realtime') ) {
#warn "[fs_signup_server] Billing customer...\n" if $Debug;
#warn "[fs_signup_server] Billing customer...\n" if $Debug;
@@
-169,15
+177,16
@@
sub new_customer {
#should check list for errors...
#$cust_main->suspend;
local $FS::svc_Common::noexport_hack = 1;
#should check list for errors...
#$cust_main->suspend;
local $FS::svc_Common::noexport_hack = 1;
- $cust_main->cancel;
+ $cust_main->cancel
('quiet'=>1)
;
-
$error = '_decline'
;
+
return { 'error' => '_decline' }
;
}
}
}
}
- $cust_main->reexport
unless $error
;
+ $cust_main->reexport;
- return { error =>
$error
};
+ return { error =>
''
};
}
}
+1;