summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_main.pm61
-rw-r--r--FS/FS/cust_pay.pm20
-rw-r--r--FS/FS/cust_pay_void.pm14
-rw-r--r--FS/FS/cust_refund.pm19
-rwxr-xr-xhttemplate/edit/cust_main.cgi5
-rw-r--r--httemplate/edit/cust_main/billing.html62
-rw-r--r--httemplate/view/cust_main/payment_history.html4
7 files changed, 56 insertions, 129 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 2a9c4c7..ebe4c24 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 a86bbc2..21b15f1 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
-
-<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;
-}
-
-
=back
=head1 BUGS
diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm
index 9a0e582..de05f71 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 a3a0e5e..3f17f9a 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
-
-<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
-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 748cdde..e2ed0f1 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
<!-- billing info -->
<% 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 d3cd77d..b38d284 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;
-%
-%
-
<INPUT TYPE="hidden" NAME="select" VALUE="<% $cust_main->payby %>">
</FORM>
<FORM NAME="<% $cust_main->payby %>" STYLE="margin-top: 0; margin-bottom: 0">
-% # XXX key
-
<INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $cust_main->paymask %>">
-% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip )) {
+% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip )) {
<INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $cust_main->getfield($field) %>">
+
% }
-%
+
% #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";
% }
-%
-
<INPUT TYPE="hidden" NAME="exp_month" VALUE="<% $mon %>">
<INPUT TYPE="hidden" NAME="exp_year" VALUE="<% $year %>">
@@ -57,12 +39,10 @@
<INPUT TYPE="hidden" NAME="invoicing_list" VALUE="<% join(', ', @invoicing_list) %>">
</FORM>
+
% } else {
%
% my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
-%
-%
-
<BR>Billing information
<% &ntable("#cccccc") %>
@@ -137,19 +117,14 @@
+'<div>[iframe not supported]</div></iframe>');
}
</SCRIPT>
-%
-%
-% 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 @@
% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
%
% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Card number </TD>!.
-% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $paymask : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!.
+% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby =~ /^(CARD|DCRD)$/ ? $payinfo : '' ). qq!" MAXLENGTH=19 onChange="card_changed(this)" onKeyUp="card_changed(this)"></TD></TR>!.
%
% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Expiration </TD>!.
% '<TD WIDTH="408">'.
@@ -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 @@
% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
%
% qq!<TR><TD ALIGN="right" WIDTH="200">${r}Phone number </TD>!.
-% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->paymask : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!.
+% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'LECB' ? $cust_main->payinfo : '' ). qq!" MAXLENGTH=15 SIZE=16></TD></TR>!.
%
% qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!.
% qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
@@ -260,7 +235,7 @@
% '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
%
% qq!<TR><TD ALIGN="right" WIDTH="200">P.O. </TD>!.
-% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->paymask : '' ). qq!"></TD></TR>!.
+% qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payinfo" VALUE="!. ( $payby eq 'BILL' ? $cust_main->payinfo : '' ). qq!"></TD></TR>!.
%
% qq!<INPUT TYPE="hidden" NAME="exp_month" VALUE="12">!.
% qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
@@ -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;
+</%init>
diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html
index 57d11b9..a23ca9a 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;