From: Christopher Burger Date: Thu, 3 Aug 2017 15:53:07 +0000 (-0400) Subject: Merge branch 'FREESIDE_3_BRANCH' of freeside.biz:/home/git/freeside into FREESIDE_3_B... X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=184b8e2c118ef3bd17f36b59f2a3f9690bf3d1bc;hp=c5bafe5c81eed4223adad4b313d060fc14d88bc2 Merge branch 'FREESIDE_3_BRANCH' of freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH --- diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 558e694b2..d604491af 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -722,6 +722,11 @@ sub edit_info { my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) or return { 'error' => "unknown custnum $custnum" }; + my $conf = new FS::Conf; + if (($p->{payby} eq "CHEK" || $p->{payby} eq "DCHK") && $conf->exists('selfservice-ACH_info_readonly')) { + return { 'error' => "You do not have authority to add a bank account" }; + } + my $new = new FS::cust_main { $cust_main->hash }; $new->set( $_ => $p->{$_} ) @@ -756,8 +761,6 @@ sub edit_info { $payby = $1; } - my $conf = new FS::Conf; - if ( $payby =~ /^(CARD|DCRD)$/ ) { $new->paydate($p->{'year'}. '-'. $p->{'month'}. '-01'); @@ -867,6 +870,7 @@ sub payment_info { 'show_paystate' => $conf->exists('show_bankstate'), 'save_unchecked' => $conf->exists('selfservice-save_unchecked'), + 'ach_read_only' => $conf->exists('selfservice-ACH_info_readonly'), }; @@ -1010,6 +1014,16 @@ sub validate_payment { $payinfo = $cust_main->payinfo if $cust_main->paymask eq $payinfo; + + my $achonfile = 0; + if ( $cust_main->paymask eq $payinfo ) { + $payinfo = $cust_main->payinfo; + $achonfile = 1; + } + + if ($conf->exists('selfservice-ACH_info_readonly') && !$achonfile) { + return { 'error' => "You are not allowed to change your payment information." }; + } } elsif ( $payby eq 'CARD' || $payby eq 'DCRD' ) { @@ -1637,6 +1651,128 @@ sub payment_receipt { }; } +sub list_payby { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + return { + 'payby' => [ map { + my $cust_payby = $_; + +{ + map { $_ => $cust_payby->$_ } + qw( custpaybynum weight payby paymask paydate + payname paystate paytype + ) + }; + } + $cust_main->cust_payby + ], + }; +} + +sub insert_payby { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + #XXX payinfo1 + payinfo2 for CHEK? + #or take the opportunity to use separate, more well- named fields? + # my $payinfo; + # $p->{'payinfo1'} =~ /^([\dx]+)$/ + # or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; + # my $payinfo1 = $1; + # $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? + # or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; + # my $payinfo2 = $1; + # $payinfo = $payinfo1. '@'. $payinfo2; + + my $cust_payby = new FS::cust_payby { + 'custnum' => $custnum, + map { $_ => $p->{$_} } qw( weight payby payinfo paycvv paydate payname + paystate paytype payip + ), + }; + + my $error = $cust_payby->insert; + if ( $error ) { + return { 'error' => $error }; + } else { + return { 'custpaybynum' => $cust_payby->custpaybynum }; + } + +} + +sub update_payby { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_payby = qsearchs('cust_payby', { + 'custnum' => $custnum, + 'custpaybynum' => $p->{'custpaybynum'}, + }) + or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} }; + + foreach my $field ( + qw( weight payby payinfo paycvv paydate payname paystate paytype payip ) + ) { + next unless exists($p->{$field}); + $cust_payby->set($field,$p->{$field}); + } + + my $error = $cust_payby->replace; + if ( $error ) { + return { 'error' => $error }; + } else { + return { 'custpaybynum' => $cust_payby->custpaybynum }; + } + +} + +sub verify_payby { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_payby = qsearchs('cust_payby', { + 'custnum' => $custnum, + 'custpaybynum' => $p->{'custpaybynum'}, + }) + or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} }; + + return { 'error' => $cust_payby->verify }; + +} + +sub delete_payby { + my $p = shift; + + my($context, $session, $custnum) = _custoragent_session_custnum($p); + return { 'error' => $session } if $context eq 'error'; + + my $cust_payby = qsearchs('cust_payby', { + 'custnum' => $custnum, + 'custpaybynum' => $p->{'custpaybynum'}, + }) + or return { 'error' => 'unknown custpaybynum '. $p->{'custpaybynum'} }; + + my $conf = new FS::Conf; + if (($cust_payby->payby eq "DCHK" || $cust_payby->payby eq "CHEK") && $conf->exists('selfservice-ACH_info_readonly')) { + return { 'error' => "Sorry you do not have permission to delete bank information." }; + } + else { + return { 'error' => $cust_payby->delete }; + } +} + sub cancel { my $p = shift; my $session = _cache->get($p->{'session_id'}) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index c0e7cd0be..77add5d97 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -6109,6 +6109,13 @@ and customer address. Include units.', }, { + 'key' => 'selfservice-ACH_info_readonly', + 'section' => 'self-service', + 'description' => 'make ACH on self service portal read only', + 'type' => 'checkbox', + }, + + { 'key' => 'selfservice-announcement', 'section' => 'self-service', 'description' => 'HTML announcement to display to all authenticated users on account overview page', diff --git a/fs_selfservice/FS-SelfService/cgi/change_pay.html b/fs_selfservice/FS-SelfService/cgi/change_pay.html index 6898dc7f8..e38ba762d 100644 --- a/fs_selfservice/FS-SelfService/cgi/change_pay.html +++ b/fs_selfservice/FS-SelfService/cgi/change_pay.html @@ -37,6 +37,11 @@ 'PREP' => qq/Prepaid Card/, 'PREPAY' => qq/Prepaid Card/, ); + + ## Don't show CHEK or DCHK option if ACH is read only + delete( $payby_index{'CHEK'} ) unless !$ach_read_only; + delete( $payby_index{'DCHK'} ) unless !$ach_read_only; + tie my %options, 'Tie::IxHash', (); foreach my $payby_option ( grep { exists( $payby_index{$_} ) } @paybys ) { $options{$payby_option} = $payby_index{$payby_option}; @@ -55,6 +60,9 @@ delete $options{'DCRD'} unless $payby eq 'DCRD' || ! exists $options{'CARD'}; delete $options{'DCHK'} unless $payby eq 'DCHK' || ! exists $options{'CHEK'}; + ## setting payby to default to layer if only one. should we always display first layer? + if (keys %options == 1) { @p = keys %options; $payby = $p[0]; } + HTML::Widgets::SelectLayers->new( options => \%options, selected_layer => $payby, diff --git a/fs_selfservice/FS-SelfService/cgi/check.html b/fs_selfservice/FS-SelfService/cgi/check.html index 68753fe08..17635c306 100644 --- a/fs_selfservice/FS-SelfService/cgi/check.html +++ b/fs_selfservice/FS-SelfService/cgi/check.html @@ -1,54 +1,97 @@ Account type - - + > + <%= + if ($ach_read_only) { + $OUT = $paytype . ''; + } else { + $OUT .= ''; + } + %> - + Account number - - + > + <%= if ($ach_read_only) { + $OUT = qq! $payinfo1 !; + } else { + $OUT = qq! !; + } + %> + + ABA/Routing number - + > + <%= + if ($ach_read_only) { + $OUT = qq! $payinfo2 !; + } else { + $OUT = qq! !; + } + %> + Bank name - - + > + <%= + if ($ach_read_only) { + $OUT = qq! $payname !; + } else { + $OUT = qq! !; + } + %> + + <%= $OUT = ''; if ($show_paystate) { - $OUT .= qq!Bank state !; + } else { + $OUT .= ''; } - $OUT .= ''; + $OUT .= ''; } %> <%= $OUT = ''; if ($show_ss) { - $OUT .= 'Account holder
Social '; - $OUT .= 'security or tax ID #'; - $OUT .= qq!!; - $OUT .= ''; + $OUT .= 'Account holder
Social '; + $OUT .= 'security or tax ID #'; + if ($ach_read_only) { + $OUT .= qq! $ss !; + } else { + $OUT .= qq!!; + } + $OUT .= ''; } %> <%= $OUT = ''; if ($show_stateid) { - $OUT .= ''; - $OUT .= qq!Account holder
$stateid_label!; - $OUT .= qq!!; - $OUT .= qq!$stateid_state_label!; - $OUT .= '!; + } else { + $OUT .= qq!!; + $OUT .= qq!$stateid_state_label!; + $OUT .= ''; } - $OUT .=''; + $OUT .=''; } %> - diff --git a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html index 8c2dfe305..1183b2ba0 100644 --- a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html @@ -20,24 +20,28 @@ EOF Payment amount - <%= include('discount_term') %> <%= include('check') %> - - - - - + +<%= + $OUT = ''; + if ($ach_read_only) { + if ($payby eq 'CHEK') { + $OUT .= ''; + } + } else { + $OUT .= ''; + $OUT .= ''; + } +%> +
+
<%= $money_char %>
- NAME="save" VALUE="1"> - Remember this information -
- NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> - Charge future payments to this account automatically -
'; + $OUT .= 'Remember this information
'; + $OUT .= 'Charge future payments to this account automatically

diff --git a/fs_selfservice/FS-SelfService/cgi/process_change_pay.html b/fs_selfservice/FS-SelfService/cgi/process_change_pay.html index 8fb33b299..11fda9043 100644 --- a/fs_selfservice/FS-SelfService/cgi/process_change_pay.html +++ b/fs_selfservice/FS-SelfService/cgi/process_change_pay.html @@ -1,3 +1,12 @@ <%= include('header', 'Information updated successfully' ) %> -Information updated successfully. + +<%= + if ($error) { + $OUT = $error; + } + else { + $OUT = 'Information updated successfully.'; + } + %> + <%= include('footer') %> diff --git a/ng_selfservice/elements/check.php b/ng_selfservice/elements/check.php index b026c92e4..fd0cd6d91 100644 --- a/ng_selfservice/elements/check.php +++ b/ng_selfservice/elements/check.php @@ -1,50 +1,88 @@ + Account type - - + + + + Account number - - + > + + + + + + + ABA/Routing number - + > + + + + + Bank name - + > + + + + + - Bank state - - - - + + Bank state + > + + + + + + - Account holder
Social security or tax ID # - - + + Account holder
Social security or tax ID # + > + + + + + + - - Account holder
- - - + > + + + + + - + - diff --git a/ng_selfservice/payment_accounts.php b/ng_selfservice/payment_accounts.php new file mode 100644 index 000000000..e70142a0a --- /dev/null +++ b/ng_selfservice/payment_accounts.php @@ -0,0 +1,78 @@ + + +

My Payment Accounts

+
+ +delete_payby( array( + 'session_id' => $_COOKIE['session_id'], + 'custpaybynum' => $paybynum, + ) ); + } + else { + $error['error'] = 'Bad Payby Number'; + } + } + + if ( isset($error['error']) && $error['error'] ) { + $error = $error['error']; + } + else { + $error = "Account " . $paybynum . " Deleted"; + } + +?> + +

+list_payby( array( + 'session_id' => $_COOKIE['session_id'], + ) ); + + if ( isset($payment_info['error']) && $payment_info['error'] ) { + $error = $payment_info['error']; + header('Location:index.php?error='. urlencode($error)); + die(); + } + + extract($payment_info); +?> + + + + + + + + + + + + + + + + + + + + +
 TypeAccount TypeAccount MaskBank Name
delete
+ + + diff --git a/ng_selfservice/payment_ach.php b/ng_selfservice/payment_ach.php index e58664f81..aebb5e3e9 100644 --- a/ng_selfservice/payment_ach.php +++ b/ng_selfservice/payment_ach.php @@ -53,7 +53,7 @@ if ( $receipt_html ) { ?> $error = $payment_error; - ?> +?> @@ -81,6 +81,12 @@ if ( $receipt_html ) { ?> + + + + + + NAME="save" VALUE="1"> @@ -92,6 +98,8 @@ if ( $receipt_html ) { ?> Charge future payments to this account automatically + +