ngx-card icon indicating copy to clipboard operation
ngx-card copied to clipboard

How to get card type

Open ayyappan1991 opened this issue 7 years ago • 5 comments

How to get card type

ayyappan1991 avatar Jan 08 '18 11:01 ayyappan1991

Same here.

LeandroideAndroide avatar May 30 '18 12:05 LeandroideAndroide

another request for returning the card type, works great in Ionic 4!

RZR666 avatar Aug 07 '18 14:08 RZR666

The card type is given in the classes in the number input field, along with various statuses

AnthonyLenglet avatar Oct 03 '18 10:10 AnthonyLenglet

const creditCardElements = this.elementRef.nativeElement.querySelectorAll('.jp-card-logo');
    creditCardElements.forEach(ccElement => {
      if (window.getComputedStyle(ccElement).getPropertyValue('opacity') == 1) {
        console.log(ccElement.classList[1].substring(8));
      }
    });

it logs 'visa'

pawmel avatar Dec 06 '18 13:12 pawmel

Add Payment library on your .ts file declare var Payment: any; No need to import anything, it's already been included from ngx-card

And use as such to get card type, let cardType = Payment.fns.cardType(this.cardNumber);

It returns the string representation of the card type. Eg. Visa, MasterCard etc.

jrbuniel15 avatar Jul 05 '20 08:07 jrbuniel15