+sub check_payinfo_cardtype {
+ my $self = shift;
+
+ return '' if $ignore_cardtype;
+
+ return '' unless $self->payby =~ /^(CARD|CHEK)$/;
+
+ my $payinfo = $self->payinfo;
+ $payinfo =~ s/\D//g;
+
+ # see parallel checks in cust_payby::check & payinfo_Mixin::payinfo_check
+ if ( $self->tokenized($payinfo) ) {
+ $self->set('is_tokenized', 'Y'); #so we don't try to do it again
+ 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 '';
+ }
+
+ my %bop_card_types = map { $_=>1 } values %{ card_types() };
+ my $cardtype = cardtype($payinfo);
+ $self->set('paycardtype', $cardtype);
+
+ return "$cardtype not accepted" unless $bop_card_types{$cardtype};
+
+ '';
+
+}
+