$DEBUG = 0;
$me = '[FS::ClientAPI::Signup]';
+sub clear_cache {
+ warn "$me clear_cache called\n" if $DEBUG;
+ my $cache = new FS::ClientAPI_SessionCache( {
+ 'namespace' => 'FS::ClientAPI::Signup',
+ } );
+ $cache->clear();
+ return {};
+}
+
sub signup_info {
my $packet = shift;
],
'agent' => [ map { my $agent = $_;
- map { $_ => $agent->get($_) } @agent_fields;
+ +{ map { $_ => $agent->get($_) } @agent_fields }
}
qsearch('agent', { 'disabled' => '' } )
],
'payby' => [ $conf->config('signup_server-payby') ],
+ 'payby_longname' => [ map { FS::payby->longname($_) }
+ $conf->config('signup_server-payby') ],
+
'card_types' => card_types(),
'paytypes' => [ @FS::cust_main::paytypes ],
my $agent_signup_info = { %$signup_info };
delete $agent_signup_info->{agentnum2part_pkg};
$agent_signup_info->{'agent'} = $session->{'agent'};
- $agent_signup_info;
- } else {
- $signup_info;
+ return $agent_signup_info;
+ }
+ elsif ( exists $packet->{'keys'} ) {
+ my @keys = @{ $packet->{'keys'} };
+ return { map { $_ => $signup_info->{$_} } @keys };
+ }
+ else {
+ return $signup_info;
}
}
unless $packet->{'popnum'} || !scalar(qsearch('svc_acct_pop',{} ));
}
+ elsif ( $svc_x eq 'svc_pbx' ) {
+ #possibly some validation will be needed
+ }
my $agentnum;
if ( exists $packet->{'session_id'} ) {
}
$svc->child_objects( \@acct_snarf );
- push @svc, $svc;
} elsif ( $svc_x eq 'svc_phone' ) {
- my $svc = new FS::svc_phone ( {
+ push @svc, new FS::svc_phone ( {
'svcpart' => $svcpart,
map { $_ => $packet->{$_} }
qw( countrycode phonenum sip_password pin ),
} );
- push @svc, $svc;
+ } elsif ( $svc_x eq 'svc_pbx' ) {
+ push @svc, new FS::svc_pbx ( {
+ 'svcpart' => $svcpart,
+ map { $_ => $packet->{$_} }
+ qw( id title ),
+ } );
+
} else {
die "unknown signup service $svc_x";
}
if ( $conf->exists('signup_server-realtime') ) {
- #warn "[fs_signup_server] Billing customer...\n" if $Debug;
+ #warn "$me Billing customer...\n" if $Debug;
my $bill_error = $cust_main->bill;
- #warn "[fs_signup_server] error billing new customer: $bill_error"
+ #warn "$me error billing new customer: $bill_error"
# if $bill_error;
$bill_error = $cust_main->apply_payments_and_credits;
- #warn "[fs_signup_server] error applying payments and credits for".
+ #warn "$me error applying payments and credits for".
# " new customer: $bill_error"
# if $bill_error;
- if ($cust_main->_new_bop_required()) {
- $bill_error = $cust_main->realtime_collect(
- method => FS::payby->payby2bop( $packet->{payby} ),
- depend_jobnum => $placeholder->jobnum,
- );
- } else {
- $bill_error = $cust_main->collect('realtime' => 1);
- }
- #warn "[fs_signup_server] error collecting from new customer: $bill_error"
+ $bill_error = $cust_main->realtime_collect(
+ method => FS::payby->payby2bop( $packet->{payby} ),
+ depend_jobnum => $placeholder->jobnum,
+ );
+ #warn "$me error collecting from new customer: $bill_error"
# if $bill_error;
if ($bill_error && ref($bill_error) eq 'HASH') {
};
}
+ $bill_error = $cust_main->apply_payments_and_credits;
+ #warn "$me error applying payments and credits for".
+ # " new customer: $bill_error"
+ # if $bill_error;
+
if ( $cust_main->balance > 0 ) {
#this makes sense. credit is "un-doing" the invoice
my %return = ( 'error' => '',
'signup_service' => $svc_x,
+ 'svcnum' => $svc[0]->svcnum,
+ 'custnum' => $cust_main->custnum,
);
if ( $svc_x eq 'svc_acct' ) {
$return{$_} = $svc[0]->$_() for qw( username _password );
} elsif ( $svc_x eq 'svc_phone' ) {
$return{$_} = $svc[0]->$_() for qw( countrycode phonenum sip_password pin );
+ } elsif ( $svc_x eq 'svc_pbx' ) {
+ #$return{$_} = $svc[0]->$_() for qw( ) #nothing yet
} else {
- die "unknown signup service $svc_x";
+ return { 'error' => "configuration error: unknown signup service $svc_x" };
+ #die "unknown signup service $svc_x";
+ # return an error that's visible to someone somewhere
}
return \%return;