[freeside-commits] branch FREESIDE_3_BRANCH updated. eb03a0ceaa55a44ceb7d16106feea9cac7c07e2f
Ivan
ivan at 420.am
Tue Jan 26 20:19:47 PST 2016
The branch, FREESIDE_3_BRANCH has been updated
via eb03a0ceaa55a44ceb7d16106feea9cac7c07e2f (commit)
from 7e89a2aacd07ca6ebe4c5fd2569f3b734e58726a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit eb03a0ceaa55a44ceb7d16106feea9cac7c07e2f
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Jan 26 20:19:45 2016 -0800
respect card-types config in backend (new customer payment types / 3.x), RT#39861
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 9cf0ba6..a25321a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -35,7 +35,7 @@ use File::Temp; #qw( tempfile );
use Business::CreditCard 0.28;
use FS::UID qw( getotaker dbh driver_name );
use FS::Record qw( qsearchs qsearch dbdef regexp_sql );
-use FS::Misc qw( generate_email send_email generate_ps do_print money_pretty );
+use FS::Misc qw( generate_email send_email generate_ps do_print money_pretty card_types );
use FS::Msgcat qw(gettext);
use FS::CurrentUser;
use FS::TicketSystem;
@@ -455,7 +455,8 @@ sub insert {
$self->auto_agent_custid()
if $conf->config('cust_main-auto_agent_custid') && ! $self->agent_custid;
- my $error = $self->SUPER::insert;
+ my $error = $self->check_payinfo_cardtype
+ || $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
#return "inserting cust_main record (transaction rolled back): $error";
@@ -1530,6 +1531,14 @@ sub replace {
|| $old->payby =~ /^(CHEK|DCHK)$/ && $self->payby =~ /^(CHEK|DCHK)$/ )
&& ( $old->payinfo eq $self->payinfo || $old->paymask eq $self->paymask );
+ if ( $self->payby =~ /^(CARD|DCRD)$/
+ && $old->payinfo ne $self->payinfo
+ && $old->paymask ne $self->paymask )
+ {
+ my $error = $self->check_payinfo_cardtype;
+ return $error if $error;
+ }
+
return "Invoicing locale is required"
if $old->locale
&& ! $self->locale
@@ -2120,6 +2129,25 @@ sub check {
$self->SUPER::check;
}
+sub check_payinfo_cardtype {
+ my $self = shift;
+
+ return '' unless $self->payby =~ /^(CARD|CHEK)$/;
+
+ my $payinfo = $self->payinfo;
+ $payinfo =~ s/\D//g;
+
+ return '' if $payinfo =~ /^99\d{14}$/; #token
+
+ my %bop_card_types = map { $_=>1 } values %{ card_types() };
+ my $cardtype = cardtype($payinfo);
+
+ return "$cardtype not accepted" unless $bop_card_types{$cardtype};
+
+ '';
+
+}
+
=item replace_check
Additional checks for replace only.
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main.pm | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
More information about the freeside-commits
mailing list