3.0.33 • Published 6 months ago

creditcard.js v3.0.33

Weekly downloads
487
License
MIT
Repository
github
Last release
6 months ago

creditcard.js

Build Status Libraries.io dependency status for latest release npm

A simple credit cards validation library in JavaScript.

Project website: https://contaazul.github.io/creditcard.js

Install

creditcard.js is available as a NPM package. You can install through Yarn or NPM:

Yarn

yarn add creditcard.js

NPM

npm install creditcard.js

Usage

import { isValid, isExpirationDateValid, isSecurityCodeValid, getCreditCardNameByNumber } from 'creditcard.js';

isValid('4916108926268679'); // returns true
isExpirationDateValid('02', '2020'); // returns true
isSecurityCodeValid('4556603578296676', '250'); // returns true
getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'

Methods

isValid(number) -> boolean

Checks whether the credit card number format is valid. (See the full list of currently supported cards)

number

Required\ Type: string

options

Optional\ Type: { cards: string[] }


isExpirationDateValid(month, year) -> boolean

Checks that the expiration date is valid and not expired. (2 or 4 digit years are accepted)

month

Required\ Type: string

year

Required\ Type: string


isSecurityCodeValid(creditCardNumber, securityCode) -> boolean

Check that the security code is valid according to the type of credit card.

creditCardNumber

Required\ Type: string

securityCode

Required\ Type: string


getCreditCardNameByNumber(number) -> string

Returns the credit card type from the card number. (See the full list of currently supported cards)

number

Required\ Type: string


Supported credit card types

  • American Express
  • Aura
  • Banescard
  • Cabal
  • Diners
  • Discover
  • Elo
  • Goodcard
  • Hipercard
  • Mastercard
  • Maxxvan
  • Visa

Credits

The first version of this library was based on bin-cc.

License

MIT © Conta Azul

3.0.32

6 months ago

3.0.33

6 months ago

3.0.31

7 months ago

3.0.30

1 year ago

3.0.27

1 year ago

3.0.28

1 year ago

3.0.26

1 year ago

3.0.29

1 year ago

3.0.24

1 year ago

3.0.25

1 year ago

3.0.23

1 year ago

3.0.22

1 year ago

3.0.21

2 years ago

3.0.20

2 years ago

3.0.18

2 years ago

3.0.19

2 years ago

3.0.17

2 years ago

3.0.16

2 years ago

3.0.14

2 years ago

3.0.15

2 years ago

3.0.12

3 years ago

3.0.13

3 years ago

3.0.11

3 years ago

3.0.10

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.4

3 years ago

3.0.5

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.7

3 years ago

2.1.6

5 years ago

2.1.5

6 years ago

2.1.3

6 years ago

2.1.0

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago

0.1.2

8 years ago

0.1.0

8 years ago