summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2004-04-20 00:58:04 +0000
committerivan <ivan>2004-04-20 00:58:04 +0000
commitd01dbb663c0d58ed4294c9284106a0e46f274301 (patch)
treeb8fd6c34afe7de09916f4494a8618cca62937437 /FS
parent1b8f95fc90575c120f1b178e05b3fbd1da35bfc9 (diff)
add methods for masking credit cards, add payment info modification to self-service
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm34
-rw-r--r--FS/FS/cust_main.pm15
-rw-r--r--FS/FS/cust_pay.pm17
-rw-r--r--FS/FS/cust_refund.pm20
4 files changed, 76 insertions, 10 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<FS::Record>, L<FS::cust_pkg>, L<FS::cust_bill>, L<FS::cust_credit>
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