X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=f255405d35731f2cbb02311d88ff7e39fe43ee18;hb=83ac7e044f6ca98c57207537e9c7b0a4d469162a;hp=502b6db08a541dfc08779f495eabf5f4d1ce7518;hpb=43c24ae41069a9b5bbbbb508263687869f1cefd3;p=freeside.git diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 502b6db08..f255405d3 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -2,8 +2,10 @@ package FS::ClientAPI::Signup; use strict; use vars qw( $DEBUG $me ); +use subs qw( _myaccount_cache ); use Data::Dumper; use Tie::RefHash; +use Digest::SHA qw(sha512_hex); use FS::Conf; use FS::Record qw(qsearch qsearchs dbdef); use FS::CGI qw(popurl); @@ -537,6 +539,8 @@ sub new_customer { paystart_month paystart_year payissue payip + locale + referral_custnum comments ) ), @@ -665,7 +669,6 @@ sub new_customer { my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) or return { 'error' => "WARNING: unknown pkgpart: $pkgpart" }; - my $svcpart = $part_pkg->svcpart($svc_x); my $reg_code = ''; if ( $packet->{'reg_code'} ) { @@ -683,50 +686,55 @@ sub new_customer { #my $error = $cust_pkg->check; #return { 'error' => $error } if $error; - #should be all auto-magic and shit my @svc = (); - if ( $svc_x eq 'svc_acct' ) { - - my $svc = new FS::svc_acct { - 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( username _password sec_phrase popnum domsvc ), - }; + unless ( $svc_x eq 'none' ) { - my @acct_snarf; - my $snarfnum = 1; - while ( exists($packet->{"snarf_machine$snarfnum"}) - && length($packet->{"snarf_machine$snarfnum"}) ) { - my $acct_snarf = new FS::acct_snarf ( { - 'machine' => $packet->{"snarf_machine$snarfnum"}, - 'protocol' => $packet->{"snarf_protocol$snarfnum"}, - 'username' => $packet->{"snarf_username$snarfnum"}, - '_password' => $packet->{"snarf_password$snarfnum"}, - } ); - $snarfnum++; - push @acct_snarf, $acct_snarf; - } - $svc->child_objects( \@acct_snarf ); - push @svc, $svc; + my $svcpart = $part_pkg->svcpart($svc_x); + #should be all auto-magic and shit + if ( $svc_x eq 'svc_acct' ) { - } elsif ( $svc_x eq 'svc_phone' ) { + my $svc = new FS::svc_acct { + 'svcpart' => $svcpart, + map { $_ => $packet->{$_} } + qw( username _password sec_phrase popnum domsvc ), + }; - push @svc, new FS::svc_phone ( { - 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( countrycode phonenum sip_password pin ), - } ); + my @acct_snarf; + my $snarfnum = 1; + while ( exists($packet->{"snarf_machine$snarfnum"}) + && length($packet->{"snarf_machine$snarfnum"}) ) { + my $acct_snarf = new FS::acct_snarf ( { + 'machine' => $packet->{"snarf_machine$snarfnum"}, + 'protocol' => $packet->{"snarf_protocol$snarfnum"}, + 'username' => $packet->{"snarf_username$snarfnum"}, + '_password' => $packet->{"snarf_password$snarfnum"}, + } ); + $snarfnum++; + push @acct_snarf, $acct_snarf; + } + $svc->child_objects( \@acct_snarf ); + push @svc, $svc; - } elsif ( $svc_x eq 'svc_pbx' ) { + } elsif ( $svc_x eq 'svc_phone' ) { - push @svc, new FS::svc_pbx ( { + push @svc, new FS::svc_phone ( { 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( id title ), - } ); + map { $_ => $packet->{$_} } + qw( countrycode phonenum sip_password pin ), + } ); + + } 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"; + } else { + die "unknown signup service $svc_x"; + } + } if ($packet->{'mac_addr'} && $conf->exists('signup_server-mac_addr_svcparts')) @@ -785,7 +793,11 @@ sub new_customer { #warn "$me Billing customer...\n" if $Debug; - my $bill_error = $cust_main->bill( 'depend_jobnum'=>$placeholder->jobnum ); + my @cust_bill; + my $bill_error = $cust_main->bill( + 'depend_jobnum' => $placeholder->jobnum, + 'return_bill' => \@cust_bill, + ); #warn "$me error billing new customer: $bill_error" # if $bill_error; @@ -820,11 +832,11 @@ sub new_customer { if ( $cust_main->balance > 0 ) { - #this makes sense. credit is "un-doing" the invoice - $cust_main->credit( $cust_main->balance, 'signup server decline', - 'reason_type' => $conf->config('signup_credit_type'), - ); - $cust_main->apply_credits; + #this used to apply a credit, but now we can void invoices... + foreach my $cust_bill (@cust_bill) { + my $voiderror = $cust_bill->void(); + warn "Error voiding cust bill after decline: $voiderror"; + } #should check list for errors... #$cust_main->suspend; @@ -945,7 +957,14 @@ sub new_customer_minimal { map { $_ => $packet->{$_} } qw( salesnum last first company daytime night fax mobile - ss + ss stateid stateid_state + + payby + payinfo paycvv paydate payname paystate paytype + paystart_month paystart_year payissue + payip + + locale ), } ); @@ -976,7 +995,6 @@ sub new_customer_minimal { my $part_pkg = qsearchs( 'part_pkg', { 'pkgpart' => $pkgpart } ) or return { 'error' => "WARNING: unknown pkgpart: $pkgpart" }; - my $svcpart = $part_pkg->svcpart($svc_x); my $cust_pkg = new FS::cust_pkg ( { #later#'custnum' => $custnum, @@ -985,35 +1003,40 @@ sub new_customer_minimal { #my $error = $cust_pkg->check; #return { 'error' => $error } if $error; - #should be all auto-magic and shit - if ( $svc_x eq 'svc_acct' ) { + unless ( $svc_x eq 'none' ) { - my $svc = new FS::svc_acct { - 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( username _password sec_phrase popnum domsvc ), - }; + my $svcpart = $part_pkg->svcpart($svc_x); + #should be all auto-magic and shit + if ( $svc_x eq 'svc_acct' ) { - push @svc, $svc; + my $svc = new FS::svc_acct { + 'svcpart' => $svcpart, + map { $_ => $packet->{$_} } + qw( username _password sec_phrase popnum domsvc ), + }; - } elsif ( $svc_x eq 'svc_phone' ) { + push @svc, $svc; - push @svc, new FS::svc_phone ( { - 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( countrycode phonenum sip_password pin ), - } ); + } elsif ( $svc_x eq 'svc_phone' ) { - } elsif ( $svc_x eq 'svc_pbx' ) { - - push @svc, new FS::svc_pbx ( { + push @svc, new FS::svc_phone ( { 'svcpart' => $svcpart, - map { $_ => $packet->{$_} } - qw( id title ), - } ); + map { $_ => $packet->{$_} } + qw( countrycode phonenum sip_password pin ), + } ); + + } 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"; + } else { + die "unknown signup service $svc_x"; + } + } foreach my $svc ( @svc ) { @@ -1055,12 +1078,13 @@ sub new_customer_minimal { $session_id = sha512_hex(time(). {}. rand(). $$) } until ( ! defined _myaccount_cache->get($session_id) ); #just in case - _cache->set( $session_id, $session, '1 hour' ); # 1 hour? + _myaccount_cache->set( $session_id, $session, '1 hour' ); # 1 hour? my %return = ( 'error' => '', 'signup_service' => $svc_x, 'custnum' => $cust_main->custnum, 'session_id' => $session_id, + map { $_ => $cust_main->$_ } qw( first last company ), ); if ( $svc[0] ) {