X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2FFS-SelfService%2Fcgi%2Fselfservice.cgi;h=ed6d623d9d1915032a50ad9c586aa61a311b0cdf;hb=7d5f7731cd62642051cfa8915924eda1f70a267d;hp=0816758fb62b4b37616e03176e3c4d8c5524b489;hpb=2041a9143fac20b79ead4a1ae01224dedf5b27c2;p=freeside.git diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 0816758fb..ed6d623d9 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -1,7 +1,8 @@ +#!/usr/bin/perl -T #!/usr/bin/perl -Tw use strict; -use vars qw($cgi $session_id $form_max $template_dir); +use vars qw($DEBUG $cgi $session_id $form_max $template_dir); use subs qw(do_template); use CGI; use CGI::Carp qw(fatalsToBrowser); @@ -9,13 +10,17 @@ use Text::Template; use HTML::Entities; use FS::SelfService qw( login customer_info invoice payment_info process_payment + process_prepay list_pkgs part_svc_info provision_acct provision_external unprovision_svc + list_svcs myaccount_passwd ); $template_dir = '.'; +$DEBUG = 1; + $form_max = 255; $cgi = new CGI; @@ -61,10 +66,13 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|payment_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc)$/ + /^(myaccount|view_invoice|make_payment|payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|change_password|process_change_password)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; +warn "calling $action sub\n" + if $DEBUG; +$FS::SelfService::DEBUG = $DEBUG; my $result = eval "&$action();"; die $@ if $@; @@ -76,9 +84,11 @@ if ( $result->{error} eq "Can't resume session" ) { #ick #warn $result->{'open_invoices'}; #warn scalar(@{$result->{'open_invoices'}}); -warn "processing template $action\n"; +warn "processing template $action\n" + if $DEBUG; do_template($action, { 'session_id' => $session_id, + 'action' => $action, #so the menu knows what tab we're on... %{$result} }); @@ -118,9 +128,12 @@ sub payment_results { validate($payinfo) #or $error ||= $init_data->{msgcat}{invalid_card}; #. $self->payinfo; or die "invalid card"; #!!! - cardtype($payinfo) eq $cgi->param('card_type') - #or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); - or die "not a ". $cgi->param('card_type'); + + if ( $cgi->param('card_type') ) { + cardtype($payinfo) eq $cgi->param('card_type') + #or $error ||= $init_data->{msgcat}{not_a}. $cgi->param('CARD_type'); + or die "not a ". $cgi->param('card_type'); + } $cgi->param('month') =~ /^(\d{2})$/ or die "illegal month"; my $month = $1; @@ -173,6 +186,22 @@ sub payment_results { } +sub recharge_prepay { + customer_info( 'session_id' => $session_id ); +} + +sub recharge_results { + + my $prepaid_cardnum = $cgi->param('prepaid_cardnum'); + $prepaid_cardnum =~ s/\W//g; + $prepaid_cardnum =~ /^(\w*)$/ or die "illegal prepaid card number"; + $prepaid_cardnum = $1; + + process_prepay ( 'session_id' => $session_id, + 'prepaid_cardnum' => $prepaid_cardnum, + ); +} + sub logout { FS::SelfService::logout( 'session_id' => $session_id ); } @@ -239,6 +268,41 @@ sub delete_svc { ); } +sub change_password { + list_svcs( + 'session_id' => $session_id, + 'svcdb' => 'svc_acct', + ); +}; + +sub process_change_password { + + my $result = myaccount_passwd( + 'session_id' => $session_id, + map { $_ => $cgi->param($_) } qw( svcnum new_password new_password2 ) + ); + + if ( exists $result->{'error'} && $result->{'error'} ) { + + $action = 'change_password'; + return { + $cgi->Vars, + %{ list_svcs( 'session_id' => $session_id, + 'svcdb' => 'svc_acct', + ) + }, + #'svcnum' => $cgi->param('svcnum'), + 'error' => $result->{'error'} + }; + + } else { + + return $result; + + } + +} + #-- sub do_template {