From d01dbb663c0d58ed4294c9284106a0e46f274301 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Apr 2004 00:58:04 +0000 Subject: add methods for masking credit cards, add payment info modification to self-service --- FS/FS/ClientAPI/MyAccount.pm | 34 ++++++++++++++++++++++++++-- FS/FS/cust_main.pm | 15 ++++++++++++ FS/FS/cust_pay.pm | 17 ++++++++++---- FS/FS/cust_refund.pm | 20 ++++++++++++---- fs_selfservice/FS-SelfService/SelfService.pm | 4 ++-- httemplate/view/cust_main.cgi | 15 ++++++------ 6 files changed, 85 insertions(+), 20 deletions(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 44d81c999..16fb8bf7a 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -38,6 +38,7 @@ use vars qw( @cust_main_editable_fields ); county state zip country daytime night fax 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 ); #store in db? @@ -116,6 +117,16 @@ sub customer_info { $return{$_} = $cust_main->get($_); } + if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { + $return{payinfo} = $cust_main->masked_payinfo; + @return{'month', 'year'} = $cust_main->paydate_monthyear; + } + + $return{'invoicing_list'} = + join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list ); + $return{'postal_invoicing'} = + 0 < ( grep { $_ eq 'POST' } $cust_main->invoicing_list ); + } else { #no customer record my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $session->{'svcnum'} } ) @@ -145,7 +156,26 @@ sub edit_info { my $new = new FS::cust_main { $cust_main->hash }; $new->set( $_ => $p->{$_} ) foreach grep { exists $p->{$_} } @cust_main_editable_fields; - my $error = $new->replace($cust_main); + + if ( $p->{'payby'} =~ /^(CARD|DCRD)$/ ) { + $new->paydate($p->{'year'}. '-'. $p->{'month'}. '-01'); + if ( $new->payinfo eq $cust_main->payinfo_masked ) { + $new->payinfo($cust_main->payinfo); + } else { + $new->paycvv($p->{'paycvv'}); + } + } + + my @invoicing_list; + if ( exists $p->{'invoicing_list'} || exists $p->{'postal_invoicing'} ) { + #false laziness with httemplate/edit/process/cust_main.cgi + @invoicing_list = split( /\s*\,\s*/, $p->{'invoicing_list'} ); + push @invoicing_list, 'POST' if $p->{'postal_invoicing'}; + } else { + @invoicing_list = $cust_main->invoicing_list; + } + + my $error = $new->replace($cust_main, \@invoicing_list); return { 'error' => $error } if $error; #$cust_main = $new; @@ -174,7 +204,7 @@ sub payment_info { $return{payby} = $cust_main->payby; if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { - warn $return{card_type} = cardtype($cust_main->payinfo); + #warn $return{card_type} = cardtype($cust_main->payinfo); $return{payinfo} = $cust_main->payinfo; @return{'month', 'year'} = $cust_main->paydate_monthyear; diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 74015de34..ad5b0df1f 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2151,6 +2151,19 @@ sub paydate_monthyear { } } +=item payinfo_masked + +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; + my $payinfo = $self->payinfo; + 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); +} + =item invoicing_list [ ARRAYREF ] If an arguement is given, sets these email addresses as invoice recipients @@ -2844,6 +2857,8 @@ card types. No multiple currency support (probably a larger project than just this module). +payinfo_masked false laziness with cust_pay.pm and cust_refund.pm + =head1 SEE ALSO L, L, L, L diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index e1943ae2d..ba9924f99 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -396,16 +396,25 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +=item payinfo_masked -=back +Returns a "masked" payinfo field with all but the last four characters replaced +by 'x'es. Useful for displaying credit cards. + +=cut -=head1 VERSION +sub payinfo_masked { + my $self = shift; + my $payinfo = $self->payinfo; + 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); +} -$Id: cust_pay.pm,v 1.26 2003-09-10 10:54:46 ivan Exp $ +=back =head1 BUGS -Delete and replace methods. +Delete and replace methods. payinfo_masked false laziness with cust_main.pm +and cust_refund.pm =head1 SEE ALSO diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 250bd20e0..d60c01061 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -263,15 +263,27 @@ sub check { $self->SUPER::check; } -=back +=item payinfo_masked + +Returns a "masked" payinfo field with all but the last four characters replaced +by 'x'es. Useful for displaying credit cards. -=head1 VERSION +=cut -$Id: cust_refund.pm,v 1.21 2003-08-05 00:20:42 khoff Exp $ + +sub payinfo_masked { + my $self = shift; + my $payinfo = $self->payinfo; + 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); +} + + +=back =head1 BUGS -Delete and replace methods. +Delete and replace methods. payinfo_masked false laziness with cust_main.pm +and cust_pay.pm =head1 SEE ALSO diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 7cbf5ecad..920415e30 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -246,7 +246,7 @@ the following keys: invnum, date, owed An HTML fragment containing shipping and billing addresses. -=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax +=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax 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 month year invoicing_list postal_invoicing =back @@ -254,7 +254,7 @@ An HTML fragment containing shipping and billing addresses. Takes a hash reference as parameter with any of the following keys: -first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax +first last company address1 address2 city county state zip country daytime night fax 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 paycvv payname month year invoicing_list postal_invoicing If a field exists, the customer record is updated with the new value of that field. If a field does not exist, that field is not changed on the customer diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 624fe37d1..cf899d041 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -235,8 +235,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { ; if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { - my $payinfo = $cust_main->payinfo; - $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); + my $payinfo = $cust_main->payinfo_masked; print 'Credit card ', ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ), '', @@ -601,11 +600,11 @@ function cust_credit_areyousure(href) { foreach my $cust_pay ($cust_main->cust_pay) { my $payby = $cust_pay->payby; - my $payinfo = $cust_pay->payinfo; + my $payinfo = $payby eq 'CARD' + ? $cust_pay->payinfo_masked + : $cust_pay->payinfo; my @cust_bill_pay = $cust_pay->cust_bill_pay; - $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)) - if $payby eq 'CARD'; my $target = "$payby$payinfo"; $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^BILL$//; @@ -751,10 +750,10 @@ function cust_credit_areyousure(href) { foreach my $cust_refund ($cust_main->cust_refund) { my $payby = $cust_refund->payby; - my $payinfo = $cust_refund->payinfo; + my $payinfo = $payby eq 'CARD' + ? $cust_refund->payinfo_masked + : $cust_refund->payinfo; - $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)) - if $payby eq 'CARD'; $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^(CARD|COMP)$/$1 /; -- cgit v1.2.1 From 953a05aefc990758f185d5284cdcbe8566b0229d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Apr 2004 01:23:06 +0000 Subject: accept expiration dates in the same format they are output... --- FS/FS/cust_main.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ad5b0df1f..34dfac5bf 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -895,7 +895,7 @@ sub check { my( $m, $y ); if ( $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) { ( $m, $y ) = ( $1, length($2) == 4 ? $2 : "20$2" ); - } elsif ( $self->paydate =~ /^(20)?(\d{2})[\/\-](\d{2})[\/\-]\d+$/ ) { + } elsif ( $self->paydate =~ /^(20)?(\d{2})[\/\-](\d{1,2})[\/\-]\d+$/ ) { ( $m, $y ) = ( $3, "20$2" ); } else { return "Illegal expiration date: ". $self->paydate; -- cgit v1.2.1 From b563ce9b834e4b8c3b2f0508f6c528d8b881e08d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 20 Apr 2004 20:24:36 +0000 Subject: silly bug noticed by matthewd --- FS/FS/ClientAPI/MyAccount.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 16fb8bf7a..d2b6e0450 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -118,7 +118,7 @@ sub customer_info { } if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { - $return{payinfo} = $cust_main->masked_payinfo; + $return{payinfo} = $cust_main->payinfo_masked; @return{'month', 'year'} = $cust_main->paydate_monthyear; } -- cgit v1.2.1 From 896617d061b92dc9c324e51c4adcb3184adbc259 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Apr 2004 01:49:55 +0000 Subject: respect country default for batch import --- FS/FS/cust_main.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 34dfac5bf..2f01111ef 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2696,7 +2696,7 @@ sub batch_import { my %cust_main = ( agentnum => $agentnum, refnum => $refnum, - country => 'US', #default + country => $conf->config('countrydefault') || 'US', payby => 'BILL', #default paydate => '12/2037', #default ); -- cgit v1.2.1 From 04c0875f27d36309b6d8da8063a9254fef3a7398 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Apr 2004 20:52:32 +0000 Subject: as an invoice event, emailing/printing problems should be fatal and trigger retry --- FS/FS/cust_bill.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index a3e76620e..7e2c8fb55 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -339,7 +339,7 @@ sub send { 'subject' => 'Invoice', 'body' => \@print_text, ); - return "can't send invoice: $error" if $error; + die "can't email invoice: $error\n" if $error; } @@ -350,11 +350,11 @@ sub send { if ( grep { $_ eq 'POST' } @invoicing_list ) { #postal my $lpr = $conf->config('lpr'); open(LPR, "|$lpr") - or return "Can't open pipe to $lpr: $!"; + or die "Can't open pipe to $lpr: $!\n"; print LPR @print_text; close LPR - or return $! ? "Error closing $lpr: $!" - : "Exit status $? from $lpr"; + or die $! ? "Error closing $lpr: $!\n" + : "Exit status $? from $lpr\n"; } ''; -- cgit v1.2.1 From 47208f7694a6ec1cb979d7d0da7848dfe0e0aa7b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Apr 2004 07:07:30 +0000 Subject: initial copy from report_cust_pay.html --- httemplate/search/report_cust_credit.html | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 httemplate/search/report_cust_credit.html diff --git a/httemplate/search/report_cust_credit.html b/httemplate/search/report_cust_credit.html new file mode 100644 index 000000000..1b30685dc --- /dev/null +++ b/httemplate/search/report_cust_credit.html @@ -0,0 +1,54 @@ + + + Payment report criteria + + + + + + +

Payment report criteria

+
+ + + + + + + + + + + + + + + +
Payments of type: +
From:
m/d/y
To:
m/d/y
+
+
+ + -- cgit v1.2.1