X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fselfservice.cgi;h=2252852d964d07953956ac36a5bb55ad0d182d77;hb=1958c28884c750ca37979f19bec3e3daf0386731;hp=a5a7d1844ed29ed7e1a6da4ea963a8c8cead322e;hpb=99100d7e0d0b22a1844dde88acd529e79d096463;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index a5a7d1844..2252852d9 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -17,6 +17,7 @@ use FS::SelfService qw( unprovision_svc change_pkg domainselector list_svcs list_svc_usage list_cdr_usage list_support_usage myaccount_passwd + mason_comp ); $template_dir = '.'; @@ -28,7 +29,7 @@ $form_max = 255; $cgi = new CGI; unless ( defined $cgi->param('session') ) { - my $login_info = login_info(); + my $login_info = login_info( 'agentnum' => scalar($cgi->param('agentnum')) ); do_template('login', $login_info ); exit; @@ -54,7 +55,7 @@ if ( $cgi->param('session') eq 'login' ) { 'password' => $password, ); if ( $rv->{error} ) { - my $login_info = login_info(); + my $login_info = login_info( 'agentnum' => $cgi->param('agentnum') ); do_template('login', { 'error' => $rv->{error}, 'username' => $username, @@ -164,13 +165,18 @@ sub process_change_ship { sub process_change_pay { my $postal = $cgi->param( 'postal_invoicing' ); + my $payby = $cgi->param( 'payby' ); my @list = qw( payby payinfo payinfo1 payinfo2 month year payname address1 address2 city county state zip country auto paytype paystate ss stateid stateid_state invoicing_list ); push @list, 'postal_invoicing' if $postal; - unless ( $postal || $cgi->param( 'invoicing_list' ) ) { + unless ( $payby ne 'BILL' + || $postal + || $cgi->param( 'invoicing_list' ) + ) + { $action = 'change_pay'; return { %{&change_pay()}, @@ -199,11 +205,24 @@ sub customer_order_pkg { my $customer_info = customer_info( 'session_id' => $session_id ); return $customer_info if ( $customer_info->{'error'} ); + my $pkgselect = mason_comp( + 'session_id' => $session_id, + 'comp' => '/edit/cust_main/first_pkg/select-part_pkg.html', + 'args' => [ 'password_verify' => 1, + 'onchange' => 'enable_order_pkg()', + 'relurls' => 1, + 'empty_label' => 'Select package', + ], + ); + + $pkgselect = $pkgselect->{'error'} || $pkgselect->{'output'}; + return { ( map { $_ => $init_data->{$_} } qw( part_pkg security_phrase svc_acct_pop ), ), %$customer_info, + 'pkg_selector' => $pkgselect, }; } @@ -229,23 +248,46 @@ sub process_order_pkg { my $results = ''; - unless ( length($cgi->param('_password')) ) { - my $init_data = signup_info( 'customer_session_id' => $session_id ); - $results = { 'error' => $init_data->{msgcat}{empty_password} }; - $results = { 'error' => $init_data->{error} } if($init_data->{error}); + my @params = (qw( custnum pkgpart )); + my $svcdb = ''; + if ( $cgi->param('pkgpart_svcpart') =~ /^(\d+)_(\d+)$/ ) { + $cgi->param('pkgpart', $1); + $cgi->param('svcpart', $2); + push @params, 'svcpart'; + $svcdb = $cgi->param('svcdb'); + push @params, 'domsvc' if $svcdb eq 'svc_acct'; + } else { + $svcdb = 'svc_acct'; } - if ( $cgi->param('_password') ne $cgi->param('_password2') ) { - my $init_data = signup_info( 'customer_session_id' => $session_id ); - $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} }; - $results = { 'error' => $init_data->{error} } if($init_data->{error}); - $cgi->param('_password', ''); - $cgi->param('_password2', ''); + + if ( $svcdb eq 'svc_acct' ) { + + push @params, qw( username _password _password2 sec_phrase popnum ); + + unless ( length($cgi->param('_password')) ) { + my $init_data = signup_info( 'customer_session_id' => $session_id ); + $results = { 'error' => $init_data->{msgcat}{empty_password} }; + $results = { 'error' => $init_data->{error} } if($init_data->{error}); + } + if ( $cgi->param('_password') ne $cgi->param('_password2') ) { + my $init_data = signup_info( 'customer_session_id' => $session_id ); + $results = { 'error' => $init_data->{msgcat}{passwords_dont_match} }; + $results = { 'error' => $init_data->{error} } if($init_data->{error}); + $cgi->param('_password', ''); + $cgi->param('_password2', ''); + } + + } elsif ( $svcdb eq 'svc_phone' ) { + + push @params, qw( phonenum sip_password pin phone_name ); + + } else { + die "$svcdb not handled on process_order_pkg yet"; } $results ||= order_pkg ( 'session_id' => $session_id, - map { $_ => $cgi->param($_) } - qw( custnum pkgpart username _password _password2 sec_phrase popnum ) + map { $_ => $cgi->param($_) } @params ); @@ -319,7 +361,7 @@ sub make_payment { sub payment_results { - use Business::CreditCard; + use Business::CreditCard 0.30; #we should only do basic checking here for DoS attacks and things #that couldn't be constructed by the web form... let process_payment() do @@ -330,14 +372,16 @@ sub payment_results { my $amount = $1; my $payinfo = $cgi->param('payinfo'); - $payinfo =~ s/\D//g; - $payinfo =~ /^(\d{13,16})$/ + $payinfo =~ s/[^\dx]//g; + $payinfo =~ /^([\dx]{13,16})$/ #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; or die "illegal card"; #!!! $payinfo = $1; - validate($payinfo) - #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; - or die "invalid card"; #!!! + unless ( $payinfo =~ /x/ ) { + validate($payinfo) + #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; + or die "invalid card"; #!!! + } if ( $cgi->param('card_type') ) { cardtype($payinfo) eq $cgi->param('card_type') @@ -420,14 +464,16 @@ sub ach_payment_results { my $amount = $1; my $payinfo1 = $cgi->param('payinfo1'); - $payinfo1=~ /^(\d+)$/ + $payinfo1 =~ s/[^\dx]//g; + $payinfo1 =~ /^([\dx]+)$/ or die "illegal account"; #!!! - $payinfo1= $1; + $payinfo1 = $1; my $payinfo2 = $cgi->param('payinfo2'); - $payinfo2=~ /^(\d+)$/ + $payinfo2 =~ s/[^\dx]//g; + $payinfo2 =~ /^([\dx]+)$/ or die "illegal ABA/routing code"; #!!! - $payinfo2= $1; + $payinfo2 = $1; $cgi->param('payname') =~ /^(.{0,80})$/ or die "illegal payname"; my $payname = $1; @@ -675,8 +721,12 @@ use HTML::Entities; use FS::SelfService qw(regionselector popselector domainselector location_form); #false laziness w/agent.cgi +use vars qw(@INCLUDE_ARGS); sub include { my $name = shift; + + @INCLUDE_ARGS = @_; + my $template = new Text::Template( TYPE => 'FILE', SOURCE => "$main::template_dir/$name.html", DELIMITERS => [ '<%=', '%>' ], @@ -690,3 +740,4 @@ sub include { } +1;