From da757c2af713bedd8706e30ac002658b0c97ce28 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 24 Dec 2006 01:28:38 +0000 Subject: [PATCH] fix more paymask regressions: allow editing records with existing expired cards, fix masking just-entered values when erroring out, fix echeck entry inserting as empty routing code and "xxEK" account number, remove old/deprecated/unused payinfo_maksed subs and calls --- FS/FS/cust_main.pm | 61 +++++++++---------------- FS/FS/cust_pay.pm | 20 +-------- FS/FS/cust_pay_void.pm | 14 ------ FS/FS/cust_refund.pm | 19 +------- httemplate/edit/cust_main.cgi | 5 +++ httemplate/edit/cust_main/billing.html | 62 +++++++++++--------------- httemplate/view/cust_main/payment_history.html | 4 +- 7 files changed, 56 insertions(+), 129 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 2a9c4c7ba..ebe4c242e 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1093,7 +1093,7 @@ sub replace { local($ignore_expired_card) = 1 if $old->payby =~ /^(CARD|DCRD)$/ && $self->payby =~ /^(CARD|DCRD)$/ - && $old->payinfo eq $self->payinfo; + && ( $old->payinfo eq $self->payinfo || $old->paymask eq $self->paymask ); my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; @@ -1321,7 +1321,10 @@ sub check { } } - $self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY|CASH|WEST|MCRD)$/ + #$self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY|CASH|WEST|MCRD)$/ + # or return "Illegal payby: ". $self->payby; + #$self->payby($1); + FS::payby->can_payby($self->table, $self->payby) or return "Illegal payby: ". $self->payby; $error = $self->ut_numbern('paystart_month') @@ -1346,8 +1349,6 @@ sub check { $check_payinfo = 0; } - $self->payby($1); - if ( $check_payinfo && $self->payby =~ /^(CARD|DCRD)$/ ) { my $payinfo = $self->payinfo; @@ -1370,20 +1371,18 @@ sub check { ' (ban# '. $ban->bannum. ')'; } - if ( defined $self->dbdef_table->column('paycvv') ) { - if (length($self->paycvv) && !$self->is_encrypted($self->paycvv)) { - if ( cardtype($self->payinfo) eq 'American Express card' ) { - $self->paycvv =~ /^(\d{4})$/ - or return "CVV2 (CID) for American Express cards is four digits."; - $self->paycvv($1); - } else { - $self->paycvv =~ /^(\d{3})$/ - or return "CVV2 (CVC2/CID) is three digits."; - $self->paycvv($1); - } + if (length($self->paycvv) && !$self->is_encrypted($self->paycvv)) { + if ( cardtype($self->payinfo) eq 'American Express card' ) { + $self->paycvv =~ /^(\d{4})$/ + or return "CVV2 (CID) for American Express cards is four digits."; + $self->paycvv($1); } else { - $self->paycvv(''); + $self->paycvv =~ /^(\d{3})$/ + or return "CVV2 (CVC2/CID) is three digits."; + $self->paycvv($1); } + } else { + $self->paycvv(''); } my $cardtype = cardtype($payinfo); @@ -1416,12 +1415,13 @@ sub check { $payinfo =~ s/[^\d\@]//g; if ( $conf->exists('echeck-nonus') ) { $payinfo =~ /^(\d+)\@(\d+)$/ or return 'invalid echeck account@aba'; + $payinfo = "$1\@$2"; } else { $payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba'; + $payinfo = "$1\@$2"; } - $payinfo = "$1\@$2"; $self->payinfo($payinfo); - $self->paycvv('') if $self->dbdef_table->column('paycvv'); + $self->paycvv(''); my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref); if ( $ban ) { @@ -1438,13 +1438,13 @@ sub check { $payinfo =~ /^1?(\d{10})$/ or return 'invalid btn billing telephone number'; $payinfo = $1; $self->payinfo($payinfo); - $self->paycvv('') if $self->dbdef_table->column('paycvv'); + $self->paycvv(''); } elsif ( $self->payby eq 'BILL' ) { $error = $self->ut_textn('payinfo'); return "Illegal P.O. number: ". $self->payinfo if $error; - $self->paycvv('') if $self->dbdef_table->column('paycvv'); + $self->paycvv(''); } elsif ( $self->payby eq 'COMP' ) { @@ -1458,7 +1458,7 @@ sub check { $error = $self->ut_textn('payinfo'); return "Illegal comp account issuer: ". $self->payinfo if $error; - $self->paycvv('') if $self->dbdef_table->column('paycvv'); + $self->paycvv(''); } elsif ( $self->payby eq 'PREPAY' ) { @@ -1469,7 +1469,7 @@ sub check { return "Illegal prepayment identifier: ". $self->payinfo if $error; return "Unknown prepayment identifier" unless qsearchs('prepay_credit', { 'identifier' => $self->payinfo } ); - $self->paycvv('') if $self->dbdef_table->column('paycvv'); + $self->paycvv(''); } @@ -3337,23 +3337,6 @@ sub paydate_monthyear { } } -=item payinfo_masked - -< DEPRICATED > Use $self->paymask - -Returns a "masked" payinfo field appropriate to the payment type. Masked characters are replaced by 'x'es. Use this to display publicly accessable account Information. - -Credit Cards - Mask all but the last four characters. -Checks - Mask all but last 2 of account number and bank routing number. -Others - Do nothing, return the unmasked string. - -=cut - -sub payinfo_masked { - my $self = shift; - return $self->paymask; -} - =item invoicing_list [ ARRAYREF ] If an arguement is given, sets these email addresses as invoice recipients diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index a86bbc23a..21b15f170 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -201,7 +201,7 @@ sub insert { my $payby = $self->payby; my $payinfo = $self->payinfo; $payby =~ s/^BILL$/Check/ if $payinfo; - $payinfo = $self->payinfo_masked if $payby eq 'CARD' || $payby eq 'CHEK'; + $payinfo = $self->paymask if $payby eq 'CARD' || $payby eq 'CHEK'; $payby =~ s/^CHEK$/Electronic check/; my $error = send_email( @@ -518,24 +518,6 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } -=item payinfo_masked - - Use $self->paymask - -Returns a "masked" payinfo field appropriate to the payment type. Masked characters are replaced by 'x'es. Use this to display publicly accessable account Information. - -Credit Cards - Mask all but the last four characters. -Checks - Mask all but last 2 of account number and bank routing number. -Others - Do nothing, return the unmasked string. - -=cut - -sub payinfo_masked { - my $self = shift; - return $self->paymask; -} - - =back =head1 BUGS diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index 9a0e58293..de05f710b 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -209,20 +209,6 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } -=item payinfo_masked - -< DEPRICATED > Use $self->paymask - -Returns a "masked" payinfo field with all but the last four characters replaced -by 'x'es. Useful for displaying credit cards. - -=cut - -sub payinfo_masked { - my $self = shift; - return $self->paymask; -} - =back =head1 BUGS diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index a3a0e5ede..3f17f9aa2 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -267,28 +267,11 @@ sub unapplied { sprintf("%.2f", $amount ); } -=item payinfo_masked - - Use $self->paymask - -Returns a "masked" payinfo field with all but the last four characters replaced -by 'x'es. Useful for displaying credit cards. - -=cut - - -sub payinfo_masked { - my $self = shift; - return $self->paymask; -} - - =back =head1 BUGS -Delete and replace methods. payinfo_masked false laziness with cust_main.pm -and cust_pay.pm +Delete and replace methods. =head1 SEE ALSO diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 748cdde5f..e2ed0f1da 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -17,6 +17,7 @@ %my $error = ''; %my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); %my(@invoicing_list); +%my $payinfo; %my $same = ''; %if ( $cgi->param('error') ) { % $error = $cgi->param('error'); @@ -36,6 +37,7 @@ % @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); % $same = $cgi->param('same'); % $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); +% $payinfo = $cust_main->payinfo; # don't mask an entered value on errors %} elsif ( $cgi->keywords ) { #editing % my( $query ) = $cgi->keywords; % $query =~ /^(\d+)$/; @@ -52,6 +54,7 @@ % $password = ''; % $popnum = 0; % @invoicing_list = $cust_main->invoicing_list; +% $payinfo = $cust_main->paymask; %} else { % $custnum=''; % $cust_main = new FS::cust_main ( {} ); @@ -64,6 +67,7 @@ % @invoicing_list = (); % push @invoicing_list, 'POST' % unless $conf->exists('disablepostalinvoicedefault'); +% $payinfo = ''; %} %$cgi->delete_all(); % @@ -259,6 +263,7 @@ Service address <% include( 'cust_main/billing.html', $cust_main, + 'payinfo' => $payinfo, 'invoicing_list' => \@invoicing_list, ) %> diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index d3cd77dbb..b38d284c4 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -1,37 +1,21 @@ -% -% -%my( $cust_main, %options ) = @_; -%my @invoicing_list = @{ $options{'invoicing_list'} }; -%my $conf = new FS::Conf; -%my $payby_default = $conf->config('payby-default'); -% -%my @payby = grep /\w/, $conf->config('payby'); -%#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) -%@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) -% unless @payby; -% %if ( $payby_default eq 'HIDE' ) { % % $cust_main->payby('BILL') unless $cust_main->payby; -% -% -
-% # XXX key - -% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip )) { +% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip )) { + % } -% + % #false laziness w/elements/select-month_year.html & view/cust_main/billing.html % my( $mon, $year ); % my $date = $cust_main->paydate || '12-2037'; @@ -42,8 +26,6 @@ % } else { % die "unrecognized expiration date format: $date"; % } -% - @@ -57,12 +39,10 @@
+ % } else { % % my $r = qq!* !; -% -% -
Billing information <% &ntable("#cccccc") %> @@ -137,19 +117,14 @@ +'
[iframe not supported]
'); } -% -% -% my($payby, $paymask, $payname)=( -% $cust_main->payby, -% $cust_main->paymask, -% $cust_main->payname, -% ); -% my( $account, $aba ) = split('@', $paymask); + +% my $payby = $cust_main->payby; +% my( $account, $aba ) = split('@', $payinfo); % % my $disabled = 'DISABLED style="background-color: #dddddd"'; % my $text_disabled = 'style="color: #999999"'; % -% if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($paymask) =~ /^(Switch|Solo)$/ ) { +% if ( $payby =~ /^(CARD|DCRD)$/ && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) { % $disabled = 'style="background-color: #ffffff"'; % $text_disabled = 'style="color: #000000";' % } @@ -161,7 +136,7 @@ % ''. % % qq!!. -% qq!!. +% qq!!. % % qq!!. % '
${r}Card number
${r}Expiration '. @@ -192,7 +167,7 @@ % 'end_year' => (localtime())[5] + 1900, % 'selected_date' => ( % ( $payby =~ /^(CARD|DCRD)$/ -% && cardtype($paymask) =~ /^(Switch|Solo)$/ ) +% && cardtype($payinfo) =~ /^(Switch|Solo)$/ ) % ? $cust_main->paystart_month. '-'. % $cust_main->paystart_year % : '' @@ -240,7 +215,7 @@ % ''. % % qq!!. -% qq!!. +% qq!!. % % qq!!. % qq!!. @@ -260,7 +235,7 @@ % '
${r}Phone number
'. % % qq!!. -% qq!!. +% qq!!. % % qq!!. % qq!!. @@ -451,4 +426,17 @@ <% $r %> required fields % } +<%init> + +my( $cust_main, %options ) = @_; +my @invoicing_list = @{ $options{'invoicing_list'} }; +my $payinfo = $options{'payinfo'}; +my $conf = new FS::Conf; +my $payby_default = $conf->config('payby-default'); + +my @payby = grep /\w/, $conf->config('payby'); +#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) + unless @payby; + diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 57d11b9e8..a23ca9ac7 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -229,7 +229,7 @@ % % my $payby = $cust_pay_void->payby; % my $payinfo = $payby eq 'CARD' -% ? $cust_pay_void->payinfo_masked +% ? $cust_pay_void->paymask % : $cust_pay_void->payinfo; % % $payby =~ s/^BILL$/Check #/ if $payinfo; @@ -365,7 +365,7 @@ % % my $payby = $cust_refund->payby; % my $payinfo = $payby eq 'CARD' -% ? $cust_refund->payinfo_masked +% ? $cust_refund->paymask % : $cust_refund->payinfo; % % $payby =~ s/^BILL$/Check #/ if $payinfo; -- 2.11.0
P.O.