X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=c376476c3284fe2e533c1e02e7d6b5ae0ad0e087;hb=81e426fe755eaea508041bc2d7b25ac44c777434;hp=01c756e3fac682ed133b37faabdd4e9396a0a785;hpb=25b0525eb1f0d018b893a7bdc96b92a8f446020f;p=freeside.git diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 01c756e3f..c376476c3 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -107,6 +107,8 @@ sub signup_info { 'security_phrase' => $conf->exists('security_phrase'), + 'nomadix' => $conf->exists('signup_server-nomadix'), + 'payby' => [ $conf->config('signup_server-payby') ], 'card_types' => card_types(), @@ -512,14 +514,14 @@ sub new_customer { #return { 'error' => $error } if $error; #should be all auto-magic and shit - my $svc; + my @svc = (); if ( $svc_x eq 'svc_acct' ) { - $svc = new FS::svc_acct ( { + my $svc = new FS::svc_acct { 'svcpart' => $svcpart, map { $_ => $packet->{$_} } qw( username _password sec_phrase popnum ), - } ); + }; my @acct_snarf; my $snarfnum = 1; @@ -536,21 +538,48 @@ sub new_customer { } $svc->child_objects( \@acct_snarf ); + push @svc, $svc; + } elsif ( $svc_x eq 'svc_phone' ) { - $svc = new FS::svc_phone ( { + my $svc = new FS::svc_phone ( { 'svcpart' => $svcpart, map { $_ => $packet->{$_} } qw( countrycode phonenum sip_password pin ), } ); + push @svc, $svc; + } else { die "unknown signup service $svc_x"; } - - my $y = $svc->setdefault; # arguably should be in new method + my $y = $svc[0]->setdefault; # arguably should be in new method return { 'error' => $y } if $y && !ref($y); + if ($packet->{'mac_addr'} && $conf->exists('signup_server-mac_addr_svcparts')) + { + + my %mac_addr_svcparts = map { $_ => 1 } + $conf->config('signup_server-mac_addr_svcparts'); + my @pkg_svc = grep { $_->quantity && $mac_addr_svcparts{$_->svcpart} } + $cust_pkg->part_pkg->pkg_svc; + + return { 'error' => 'No service defined to assign mac address' } + unless @pkg_svc; + + my $svc = new FS::svc_acct { + 'svcpart' => $pkg_svc[0]->svcpart, #multiple matches? alas.. + 'username' => $packet->{'mac_addr'}, + '_password' => '', #blank as requested (set passwordmin to 0) + }; + + my $y = $svc->setdefault; # arguably should be in new method + return { 'error' => $y } if $y && !ref($y); + + push @svc, $svc; + + } + #$error = $svc->check; #return { 'error' => $error } if $error; @@ -564,7 +593,7 @@ sub new_customer { use Tie::RefHash; tie my %hash, 'Tie::RefHash'; - %hash = ( $cust_pkg => [ $svc ] ); + %hash = ( $cust_pkg => \@svc ); #msgcat $error = $cust_main->insert( \%hash, @@ -648,9 +677,9 @@ sub new_customer { ); if ( $svc_x eq 'svc_acct' ) { - $return{$_} = $svc->$_() for qw( username _password ); + $return{$_} = $svc[0]->$_() for qw( username _password ); } elsif ( $svc_x eq 'svc_phone' ) { - $return{$_} = $svc->$_() for qw( countrycode phonenum sip_password pin ); + $return{$_} = $svc[0]->$_() for qw( countrycode phonenum sip_password pin ); } else { die "unknown signup service $svc_x"; }