All Projects → juspay → card-validator

juspay / card-validator

Licence: MIT License
Card validation helpers for payment forms.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to card-validator

laravel-sibs-payments
Laravel library to communicate with SIBS - Open Payment Platform. The library includes payments: MBWAY, VISA, MASTER, AMEX, VPAY, MAESTRO, VISADEBIT, VISAELECTRON.
Stars: ✭ 30 (+36.36%)
Mutual labels:  payments, amex, visa
PaystackJS-Sample-code
Bare Paystack JS implementation. Style pay.html as required
Stars: ✭ 15 (-31.82%)
Mutual labels:  payments, visa, mastercard
paymentgateway
Dokumentace ČSOB platební brány a jejího eAPI pro platby platebními kartami, Apple Pay, mallpay a platebními tlačítky ČSOB.
Stars: ✭ 104 (+372.73%)
Mutual labels:  payments, visa, mastercard
PaymentCardView
Custom Credit/Debit card view
Stars: ✭ 62 (+181.82%)
Mutual labels:  credit-card, visa, mastercard
Checkout Sdk Node
Checkout.com SDK for Node.js. Documentation here:
Stars: ✭ 28 (+27.27%)
Mutual labels:  credit-card, payments
Payment
💰 A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers.
Stars: ✭ 467 (+2022.73%)
Mutual labels:  credit-card, payments
Offset
Offset payment engine
Stars: ✭ 152 (+590.91%)
Mutual labels:  credit-card, payments
Elements Examples
Stripe Elements examples.
Stars: ✭ 874 (+3872.73%)
Mutual labels:  card, payments
Mfcard
Easily integrate Credit Card payments module in iOS App. Swift 4.0
Stars: ✭ 356 (+1518.18%)
Mutual labels:  card, credit-card
Vue Paycard
Credit card component made with Vue.js
Stars: ✭ 52 (+136.36%)
Mutual labels:  card, credit-card
terms-dictionary
Simple definitions of terms, acronyms, abbreviations, companies, and projects related to financial services and Moov.
Stars: ✭ 48 (+118.18%)
Mutual labels:  credit-card, payments
credit-card-prompt
Credit card prompt with validation and address lookup
Stars: ✭ 13 (-40.91%)
Mutual labels:  card, credit-card
Braintree android
Braintree SDK for Android
Stars: ✭ 343 (+1459.09%)
Mutual labels:  credit-card, payments
Android Card Form
A ready-made card form layout that can be included in your Android app, making it easy to accept credit and debit cards.
Stars: ✭ 310 (+1309.09%)
Mutual labels:  credit-card, payments
Card
💳 make your credit card form better in one line of code
Stars: ✭ 11,365 (+51559.09%)
Mutual labels:  credit-card, payments
pyamex
Python library for accessing American Express account data
Stars: ✭ 15 (-31.82%)
Mutual labels:  credit-card, amex
Swipeablecard
A simple implementation of swipe card like StreetView
Stars: ✭ 812 (+3590.91%)
Mutual labels:  card, credit-card
cybersource-android-sdk
The CyberSource InApp SDK enables developers to simply and securely incorporate mobile payments into their Android applications.
Stars: ✭ 25 (+13.64%)
Mutual labels:  payments, visa
J2pay
Multi-gateway payment processing library for java
Stars: ✭ 125 (+468.18%)
Mutual labels:  card, credit-card
cybersource-sdk-java
Java SDK for CyberSource Simple Order API
Stars: ✭ 44 (+100%)
Mutual labels:  payments, visa

Card Validator

Generic helpers for card number, expiry and CVV validations

npm version

Usage:

Import the library and initialize card object.

Install from npm:

npm i @juspay/simple-card-validator --save

var cardValidator = require('simple-card-validator');

Or, you can simply use the file from dist/validator.js if you are not using node/npm.

var card = new cardValidator('4242-4242-4242-4242');

Getting card details

card.getCardDetails(); This would output, card brand and different validation outputs like below:

{ card_type: 'visa',
  valid: true,
  luhn_valid: true,
  length_valid: true,
  cvv_length: [ 3 ],
  gaps: [ 4, 8, 12 ],
  supported_lengths: [ 16 ],
  max_length: 16 }

Output format

Field Description Type
card_type The card issuer for the provided card String
valid Are the card details valid Boolean
luhn_valid Is the card number valid Boolean
length_valid If the card number length is valid Boolean
cvv_length If the CVV/CAVV length is valid Array [ Integer ]
gaps Gaps for UI as printed in cards Array [ Integer ]
supported_lengths Supported lengths for the card type Array [ Integer ]
max_length Maximum length for the card type Integer

Validations

To simply validate a card, call: card.validateCard(); The result will be a validity boolean.

For validating expiry date, card.validateExpiry('12/2018');

Additionally, the base date can be set for expiry validations. The base month and date can be provided by using, card.setBaseDate(month, year);

eg: card.setBaseDate('02', '2016');

For validating CVV, use: card.validateCvv(111); CVV will be validated based on the brand of the card.

Contribution

Read through the development guidelines.

License

MIT license. Copyright © 2018 - juspay.in.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].