summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2017-02-01 14:00:53 -0600
committerJonathan Prykop <jonathan@freeside.biz>2017-02-01 14:00:53 -0600
commit57ac39c47a28bcf9dc1f689e6bd6234f0218d0ad (patch)
treee1cc68d1b695640f42d677258e9cd260bce4f595
parent87d108d379a5c077370afc04728d1c28e9edef30 (diff)
71513: Card tokenization [tweaks to paycardtype checks]
-rw-r--r--FS/FS/cust_payby.pm22
-rw-r--r--FS/FS/payinfo_Mixin.pm39
2 files changed, 37 insertions, 24 deletions
diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm
index 36f90dfb5..e25d73ecd 100644
--- a/FS/FS/cust_payby.pm
+++ b/FS/FS/cust_payby.pm
@@ -356,7 +356,19 @@ sub check {
validate($payinfo)
or return gettext('invalid_card'); # . ": ". $self->payinfo;
- my $cardtype = $self->paycardtype || cardtype($payinfo);
+ # see parallel checks in check_payinfo_cardtype & payinfo_Mixin::payinfo_check
+ my $cardtype = '';
+ if ( $self->tokenized ) {
+ if ( $self->paymask =~ /^\d+x/ ) {
+ $cardtype = cardtype($self->paymask);
+ } else {
+ $cardtype = '';
+ #return "paycardtype required ".
+ # "(can't derive from a token and no paymask w/prefix provided)";
+ }
+ } else {
+ $cardtype = cardtype($self->payinfo);
+ }
return gettext('unknown_card_type') if $cardtype eq "Unknown";
@@ -545,7 +557,15 @@ sub check_payinfo_cardtype {
my $payinfo = $self->payinfo;
$payinfo =~ s/\D//g;
+ # see parallel checks in cust_payby::check & payinfo_Mixin::payinfo_check
if ( $self->tokenized($payinfo) ) {
+ if ( $self->paymask =~ /^\d+x/ ) {
+ $self->set('paycardtype', cardtype($self->paymask));
+ } else {
+ $self->set('paycardtype', '');
+ #return "paycardtype required ".
+ # "(can't derive from a token and no paymask w/prefix provided)";
+ }
return '';
}
diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm
index 7401eb9c8..cb9b72318 100644
--- a/FS/FS/payinfo_Mixin.pm
+++ b/FS/FS/payinfo_Mixin.pm
@@ -197,20 +197,17 @@ sub payinfo_check {
if ( $self->payby eq 'CARD' && ! $self->is_encrypted($self->payinfo) ) {
- unless ( $self->paycardtype ) {
-
- if ( $self->tokenized ) {
- if ( $self->paymask =~ /^\d+x/ ) {
- $self->set('paycardtype', cardtype($self->paymask));
- } else {
- $self->set('paycardtype', '');
- # return "paycardtype required ".
- # "(can't derive from a token and no paymask w/prefix provided)";
- }
+ # see parallel checks in cust_payby::check & cust_payby::check_payinfo_cardtype
+ if ( $self->tokenized ) {
+ if ( $self->paymask =~ /^\d+x/ ) {
+ $self->set('paycardtype', cardtype($self->paymask));
} else {
- $self->set('paycardtype', cardtype($self->payinfo));
+ $self->set('paycardtype', '');
+ #return "paycardtype required ".
+ # "(can't derive from a token and no paymask w/prefix provided)";
}
-
+ } else {
+ $self->set('paycardtype', cardtype($self->payinfo));
}
if ( $ignore_masked_payinfo and $self->mask_payinfo eq $self->payinfo ) {
@@ -232,17 +229,13 @@ sub payinfo_check {
} else {
- unless ( $self->paycardtype ) {
-
- if ( $self->payby eq 'CARD' && $self->paymask =~ /^\d+x/ ) {
- # if we can't decrypt the card, at least detect the cardtype
- $self->set('paycardtype', cardtype($self->paymask));
- } else {
- $self->set('paycardtype', '');
- # return "paycardtype required ".
- # "(can't derive from a token and no paymask w/prefix provided)";
- }
-
+ if ( $self->payby eq 'CARD' && $self->paymask =~ /^\d+x/ ) {
+ # if we can't decrypt the card, at least detect the cardtype
+ $self->set('paycardtype', cardtype($self->paymask));
+ } else {
+ $self->set('paycardtype', '');
+ # return "paycardtype required ".
+ # "(can't derive from a token and no paymask w/prefix provided)";
}
if ( $self->is_encrypted($self->payinfo) ) {