projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4e6767f
)
respect card-types config in backend (new customer payment types / 4.x), RT#39861
author
Ivan Kohler
<ivan@freeside.biz>
Wed, 27 Jan 2016 04:11:11 +0000
(20:11 -0800)
committer
Ivan Kohler
<ivan@freeside.biz>
Wed, 27 Jan 2016 04:11:11 +0000
(20:11 -0800)
FS/FS/cust_payby.pm
patch
|
blob
|
history
diff --git
a/FS/FS/cust_payby.pm
b/FS/FS/cust_payby.pm
index
83b951e
..
79a1468
100644
(file)
--- a/
FS/FS/cust_payby.pm
+++ b/
FS/FS/cust_payby.pm
@@
-7,6
+7,7
@@
use Digest::SHA qw( sha512_base64 );
use Business::CreditCard qw( validate cardtype );
use FS::UID qw( dbh );
use FS::Msgcat qw( gettext );
use Business::CreditCard qw( validate cardtype );
use FS::UID qw( dbh );
use FS::Msgcat qw( gettext );
+use FS::Misc qw( card_types );
use FS::Record; #qw( qsearch qsearchs );
use FS::payby;
use FS::cust_main;
use FS::Record; #qw( qsearch qsearchs );
use FS::payby;
use FS::cust_main;
@@
-154,7
+155,8
@@
sub insert {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $error = $self->SUPER::insert;
+ my $error = $self->check_payinfo_cardtype
+ || $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@
-228,6
+230,14
@@
sub replace {
|| $old->payby =~ /^(CHEK|DCHK)$/ && $self->payby =~ /^(CHEK|DCHK)$/ )
&& ( $old->payinfo eq $self->payinfo || $old->paymask eq $self->paymask );
|| $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;
+ }
+
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
local $SIG{QUIT} = 'IGNORE';
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
local $SIG{QUIT} = 'IGNORE';
@@
-483,6
+493,23
@@
sub check {
$self->SUPER::check;
}
$self->SUPER::check;
}
+sub check_payinfo_cardtype {
+ my $self = shift;
+
+ 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};
+
+ '';
+
+}
+
sub _banned_pay_hashref {
my $self = shift;
sub _banned_pay_hashref {
my $self = shift;