From c0fdb0884f3e5fb72e83e0b65d52b5a593bd670a Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 23 Jan 2008 19:18:39 +0000 Subject: [PATCH] change service, billing, and payment info in selfservice --- FS/FS/ClientAPI/MyAccount.pm | 49 +++++++- fs_selfservice/FS-SelfService/cgi/bill.html | 7 ++ fs_selfservice/FS-SelfService/cgi/card.html | 73 +++++++++++ fs_selfservice/FS-SelfService/cgi/change_bill.html | 25 ++++ fs_selfservice/FS-SelfService/cgi/change_pay.html | 75 ++++++++++++ fs_selfservice/FS-SelfService/cgi/change_ship.html | 104 ++++++++++++++++ fs_selfservice/FS-SelfService/cgi/check.html | 54 +++++++++ fs_selfservice/FS-SelfService/cgi/contact.html | 135 +++++++++++++++++++++ .../FS-SelfService/cgi/make_ach_payment.html | 56 +-------- .../FS-SelfService/cgi/make_payment.html | 69 +---------- .../FS-SelfService/cgi/myaccount_menu.html | 5 +- .../FS-SelfService/cgi/process_change_bill.html | 13 ++ .../FS-SelfService/cgi/process_change_pay.html | 13 ++ .../FS-SelfService/cgi/process_change_ship.html | 13 ++ fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 70 ++++++++++- 15 files changed, 634 insertions(+), 127 deletions(-) create mode 100644 fs_selfservice/FS-SelfService/cgi/bill.html create mode 100644 fs_selfservice/FS-SelfService/cgi/card.html create mode 100755 fs_selfservice/FS-SelfService/cgi/change_bill.html create mode 100644 fs_selfservice/FS-SelfService/cgi/change_pay.html create mode 100755 fs_selfservice/FS-SelfService/cgi/change_ship.html create mode 100644 fs_selfservice/FS-SelfService/cgi/check.html create mode 100644 fs_selfservice/FS-SelfService/cgi/contact.html create mode 100644 fs_selfservice/FS-SelfService/cgi/process_change_bill.html create mode 100644 fs_selfservice/FS-SelfService/cgi/process_change_pay.html create mode 100644 fs_selfservice/FS-SelfService/cgi/process_change_ship.html diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 61078a94e..2d3951006 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -42,6 +42,7 @@ use vars qw( @cust_main_editable_fields ); ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax payby payinfo payname paystart_month paystart_year payissue payip + ss paytype paystate stateid stateid_state ); use subs qw(_provision); @@ -113,6 +114,14 @@ sub customer_info { return { 'error' => $session } if $context eq 'error'; my %return; + + my $conf = new FS::Conf; + if ($conf->exists('cust_main-require_address2')) { + $return{'require_address2'} = '1'; + }else{ + $return{'require_address2'} = ''; + } + if ( $custnum ) { #customer record my $search = { 'custnum' => $custnum }; @@ -133,7 +142,6 @@ sub customer_info { } $cust_main->open_cust_bill; $return{open_invoices} = \@open; - my $conf = new FS::Conf; $return{small_custview} = small_custview( $cust_main, $conf->config('countrydefault') ); @@ -208,13 +216,46 @@ sub edit_info { $new->set( $_ => $p->{$_} ) foreach grep { exists $p->{$_} } @cust_main_editable_fields; - if ( $p->{'payby'} =~ /^(CARD|DCRD)$/ ) { + my $payby = ''; + if (exists($p->{'payby'})) { + $p->{'payby'} =~ /^([A-Z]{4})$/ + or return { 'error' => "illegal_payby " . $p->{'payby'} }; + $payby = $1; + } + + if ( $payby =~ /^(CARD|DCRD)$/ ) { + $new->paydate($p->{'year'}. '-'. $p->{'month'}. '-01'); + if ( $new->payinfo eq $cust_main->paymask ) { $new->payinfo($cust_main->payinfo); } else { - $new->paycvv($p->{'paycvv'}); + $new->payinfo($p->{'payinfo'}); } + + $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' ); + + }elsif ( $payby =~ /^(CHEK|DCHK)$/ ) { + my $payinfo; + $p->{'payinfo1'} =~ /^([\dx]+)$/ + or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; + my $payinfo1 = $1; + $p->{'payinfo2'} =~ /^([\dx]+)$/ + or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; + my $payinfo2 = $1; + $payinfo = $payinfo1. '@'. $payinfo2; + + if ( $payinfo eq $cust_main->paymask ) { + $new->payinfo($cust_main->payinfo); + } else { + $new->payinfo($payinfo); + } + + $new->set( 'payby' => $p->{'auto'} ? 'CHEK' : 'DCHK' ); + + }elsif ( $payby =~ /^(BILL)$/ ) { + } elsif ( $payby ) { #notyet ready + return { 'error' => "unknown payby $payby" }; } my @invoicing_list; @@ -265,6 +306,8 @@ sub payment_info { 'paytypes' => [ @FS::cust_main::paytypes ], + 'paybys' => [ $conf->config('signup_server-payby') ], + 'stateid_label' => FS::Msgcat::_gettext('stateid'), 'stateid_state_label' => FS::Msgcat::_gettext('stateid_state'), diff --git a/fs_selfservice/FS-SelfService/cgi/bill.html b/fs_selfservice/FS-SelfService/cgi/bill.html new file mode 100644 index 000000000..bbdf1f210 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/bill.html @@ -0,0 +1,7 @@ + + P.O. number + + + Attention + + diff --git a/fs_selfservice/FS-SelfService/cgi/card.html b/fs_selfservice/FS-SelfService/cgi/card.html new file mode 100644 index 000000000..cf6d20d8d --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/card.html @@ -0,0 +1,73 @@ + + Card number + + + + + + + + + +
+ Exp. + + / + +
+ + +<%= + if ( $withcvv ) { + $OUT .= qq!!; + $OUT .= qq!CVV2 (help)!; + $OUT .= qq!!; + $OUT .= qq!!; + } + ''; +%> + + Exact name on card + + + Card billing address + + + + + Address line 2 + + + + + City + + + + + + + + + +
+ + State + + Zip + +
+ + diff --git a/fs_selfservice/FS-SelfService/cgi/change_bill.html b/fs_selfservice/FS-SelfService/cgi/change_bill.html new file mode 100755 index 000000000..0bc47d069 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/change_bill.html @@ -0,0 +1,25 @@ +MyAccount + +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + +Edit billing address

+<%= if ( $error ) { + $OUT .= qq!Error: $error

!; +} ''; %> + +
+ + + + +<%= $r=qq!* !; include('contact') %> + +"> +
+ +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/change_pay.html b/fs_selfservice/FS-SelfService/cgi/change_pay.html new file mode 100644 index 000000000..d26abfa7a --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/change_pay.html @@ -0,0 +1,75 @@ +MyAccount + + +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + +Change payment information

+<%= if ( $error ) { + $OUT .= qq!Error: $error

!; + } ''; %> + +
+<%= + use Tie::IxHash; + use HTML::Widgets::SelectLayers; + + my $preauto = '). + qq(). + qq(
). + qq( ). + qq(); + + + my %paybychecked = ( + 'BILL' => include('bill'), + 'CARD' => include('card')."$preauto CHECKED $postauto", + 'DCRD' => include('card')."$preauto $postauto", + 'CHEK' => include('check')."$preauto CHECKED $postauto", + 'DCHK' => include('check')."$preauto $postauto", + ); + my %payby_index = ( 'CARD' => qq/Credit Card/, + 'DCRD' => qq/Credit Card/, + 'CHEK' => qq/Check/, + 'DCHK' => qq/Check/, + 'LECB' => qq/Phone Bill Billing/, + 'BILL' => qq/Billing/, + 'COMP' => qq/Complimentary/, + 'PREPAY' => qq/Prepaid Card/, + ); + tie my %options, 'Tie::IxHash', (); + foreach my $payby_option ( @paybys ) { + $options{$payby_option} = $payby_index{$payby_option}; + } + $options{$payby} = $payby_index{$payby} + unless exists($options{$payby}); + + HTML::Widgets::SelectLayers->new( + options => \%options, + selected_layer => $payby, +# form_name => 'dummy', +# form_action => 'dummy.cgi', + layer_callback => sub { my $layer = shift; return ''.$paybychecked{$layer}.qq!$tail!; }, + )->html; + +%> +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/change_ship.html b/fs_selfservice/FS-SelfService/cgi/change_ship.html new file mode 100755 index 000000000..1a3b85d6d --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/change_ship.html @@ -0,0 +1,104 @@ +MyAccount + +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + +Edit service address

+<%= if ( $error ) { + $OUT .= qq!Error: $error

!; +} ''; %> + + + + + + +<%= + foreach ( + qw( last first company address1 address2 city county state zip country + daytime night fax ) + ) { + $OUT .= qq!!; + }; + ''; +%> + +(param('same') eq 'Y') ? 'CHECKED' : '' %> + >same as billing address) +<%= $r=qq!* !; + if (!$ship_last || $cgi->param('same') eq 'Y') { + $disabled = 'DISABLED STYLE="background-color: #dddddd"'; + foreach ( qw( last first company address1 address2 city county state + zip country daytime night fax ) + ) { + ${"ship_$_"} = ${$_}; + } + }else{ + $disabled = ''; + } + $pre = 'ship_'; + include('contact'); +%> + +"> +
+ +
+
+powered by freeside + diff --git a/fs_selfservice/FS-SelfService/cgi/check.html b/fs_selfservice/FS-SelfService/cgi/check.html new file mode 100644 index 000000000..68753fe08 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/check.html @@ -0,0 +1,54 @@ + + Account type + + + + + Account number + + + ABA/Routing number + + + Bank name + + + <%= + $OUT = ''; + if ($show_paystate) { + $OUT .= qq!Bank state'; + } + %> + <%= + $OUT = ''; + if ($show_ss) { + $OUT .= 'Account holder
Social '; + $OUT .= 'security or tax ID #'; + $OUT .= qq!!; + $OUT .= ''; + } + %> + <%= + $OUT = ''; + if ($show_stateid) { + $OUT .= ''; + $OUT .= qq!Account holder
$stateid_label!; + $OUT .= qq!!; + $OUT .= qq!$stateid_state_label!; + $OUT .= ''; + } + %> + diff --git a/fs_selfservice/FS-SelfService/cgi/contact.html b/fs_selfservice/FS-SelfService/cgi/contact.html new file mode 100644 index 000000000..20c15df78 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/contact.html @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + <%= + ($county_html, $state_html, $country_html) = + FS::SelfService::regionselector( { + prefix => $pre, + selected_county => ${$pre.'county'}, + selected_state => ${$pre.'state'}, + selected_country => ${$pre.'country'}, + default_state => $statedefault, + default_country => $countrydefault, + locales => \@cust_main_county, + } ); + + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + $OUT .= qq!!; + %> + + + + + + + + + + + + + + + + + + + +
<%=$r%>Contact name
(last, first)
+ > , + > +
Company + > +
<%=$r%>Address + > +
+ <%= + my $style = + ( $disabled + || !$require_address2 + || ( !$pre && $ship_last ) + ) + ? 'visibility:hidden' + : ''; + + $OUT .= qq!* Unit #!; + %> + + > +
<%=$r%>City + > + ${r}State/County$county_html $state_html${r}Zip
${r}Country$country_html
Day Phone + > +
Night Phone + > +
Fax + > +
+<%=$r%>required fields
+ + diff --git a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html index 83d36b9b9..f80142325 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html @@ -36,59 +36,9 @@ $"> - - Account type - - - - - Account number - - - ABA/Routing number - - - Bank name - - - <%= - $OUT = ''; - if ($show_paystate) { - $OUT .= qq!Bank state'; - } - %> - <%= - $OUT = ''; - if ($show_ss) { - $OUT .= 'Account holder
Social '; - $OUT .= 'security or tax ID #'; - $OUT .= qq!!; - $OUT .= ''; - } - %> - <%= - $OUT = ''; - if ($show_stateid) { - $OUT .= ''; - $OUT .= qq!Account holder
$stateid_label!; - $OUT .= qq!!; - $OUT .= qq!$stateid_state_label!; - $OUT .= ''; - } - %> + +<%= include('check') %> + Remember this information diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html index 64b1e00b5..89239c06b 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html @@ -46,72 +46,9 @@ } %> - - Card number - - - - - - - - - -
- Exp. - - / - -
- - - CVV2 (help) - - - Exact name on card - - - Card billing address - - - - - Address line 2 - - - - - City - - - - - - - - - -
- - State - - Zip - -
- - + +<%= include('card') %> + Remember this information diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index defd817c0..ec5a8fa42 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -39,8 +39,9 @@ push @menu, ( { title=>' ' }, { title=>'Change my information', size=>'+1', }, -# { title=>'Change payment information*', url=>'change_bill', indent=>2 }, -# { title=>'Change service address*', url=>'change_ship', indent=>2 }, + { title=>'Change billing address', url=>'change_bill', indent=>2 }, + { title=>'Change service address', url=>'change_ship', indent=>2 }, + { title=>'Change payment information', url=>'change_pay', indent=>2 }, { title=>'Change password(s)', url=>'change_password', indent=>2 }, { title=>' ' }, diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_bill.html b/fs_selfservice/FS-SelfService/cgi/process_change_bill.html new file mode 100644 index 000000000..66a71e6e8 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_change_bill.html @@ -0,0 +1,13 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + + +Information updated successfully. + + +
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_pay.html b/fs_selfservice/FS-SelfService/cgi/process_change_pay.html new file mode 100644 index 000000000..66a71e6e8 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_change_pay.html @@ -0,0 +1,13 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + + +Information updated successfully. + + +
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_ship.html b/fs_selfservice/FS-SelfService/cgi/process_change_ship.html new file mode 100644 index 000000000..66a71e6e8 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/process_change_ship.html @@ -0,0 +1,13 @@ +MyAccount +MyAccount

+<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + + +Information updated successfully. + + +
+powered by freeside + + diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index b5a672059..36557b662 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -9,7 +9,7 @@ use Text::Template; use HTML::Entities; use Date::Format; use Number::Format 1.50; -use FS::SelfService qw( login customer_info invoice +use FS::SelfService qw( login customer_info edit_info invoice payment_info process_payment process_prepay list_pkgs order_pkg signup_info order_recharge @@ -68,7 +68,7 @@ $session_id = $cgi->param('session'); #order|pw_list XXX ??? $cgi->param('action') =~ - /^(myaccount|view_invoice|make_payment|make_ach_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_support_details|change_password|process_change_password)$/ + /^(myaccount|view_invoice|make_payment|make_ach_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_support_details|change_password|process_change_password)$/ or die "unknown action ". $cgi->param('action'); my $action = $1; @@ -100,6 +100,70 @@ do_template($action, { sub myaccount { customer_info( 'session_id' => $session_id ); } +sub change_bill { my $payment_info = + payment_info( 'session_id' => $session_id ); + return $payment_info if ( $payment_info->{'error'} ); + my $customer_info = + customer_info( 'session_id' => $session_id ); + return { + %$payment_info, + %$customer_info, + }; + } +sub change_ship { change_bill(@_); } +sub change_pay { change_bill(@_); } + +sub _process_change_info { + my ($erroraction, @fields) = @_; + + my $results = ''; + + $results ||= edit_info ( + 'session_id' => $session_id, + map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields, + ); + + + if ( $results->{'error'} ) { + no strict 'refs'; + $action = $erroraction; + return { + $cgi->Vars, + %{&$action()}, + 'error' => ''. $results->{'error'}. '', + }; + } else { + return $results; + } +} + +sub process_change_bill { + _process_change_info( 'change_bill', + qw( first last company address1 address2 city state + county state zip country daytime night fax ) + ); +} + +sub process_change_ship { + my @list = map { "ship_$_" } + qw( first last company address1 address2 city state + county zip country daytime night fax + ); + if ($cgi->param('same') eq 'Y') { + foreach (@list) { $cgi->param($_, '') } + } + + _process_change_info( 'change_ship', @list ); +} + +sub process_change_pay { + _process_change_info( 'change_pay', + qw( payby payinfo payinfo1 payinfo2 month year payname + address1 address2 city county state zip country auto paytype + paystate ss stateid stateid_state ) + ); +} + sub view_invoice { $cgi->param('invnum') =~ /^(\d+)$/ or die "illegal invnum"; @@ -563,7 +627,7 @@ package FS::SelfService::_selfservicecgi; #use FS::SelfService qw(regionselector expselect popselector); use HTML::Entities; -use FS::SelfService qw(popselector domainselector); +use FS::SelfService qw(regionselector popselector domainselector); #false laziness w/agent.cgi sub include { -- 2.11.0