StructureJS

0.15.2

A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.

MerchantUtil Class

Module: util
Parent Module: StructureJS

A MerchantUtility class that has several static methods to assist in development.

Methods

_updateRanges () protected

_validateCreditCard
(
  • cardNumber
)
Boolean

Determines if credit card is valid using the Luhn formula. https://gist.github.com/ShirtlessKirk/2134376

Parameters:

Returns:

_validateStructure
(
  • cardNumber
)
Boolean

encodeCreditCardNumber
(
  • strNumber
  • [digitsShown=4]
  • [encodeChar=*]
)
String public static

Encode a credit card number as a string and encode all digits except the last digitsShown.

Parameters:

  • strNumber String

    The credit card number as string.

  • [digitsShown=4] Number optional

    Display this many digits at the end of the card number for security purposes.

  • [encodeChar=*] String optional

    Optional encoding character to use instead of default '*'.

Returns:

Example:

 MerchantUtil.encodeCreditCardNumber('4556106734384949');
 // ************4949

 MerchantUtil.encodeCreditCardNumber('4556106734384949', 5, 'x');
 // xxxxxxxxxxx84949

getCreditCardProvider
(
  • cardNumber
)
String

Returns a credit card provider name from the credit card number passed in.

Parameters:

Returns:

Example:

 MerchantUtil.getCreditCardProvider("4");
 MerchantUtil.getCreditCardProvider("4556106734384949");
 // visa

 MerchantUtil.getCreditCardProvider("5428070016026573");
 // mastercard

isCreditCard
(
  • cardNumber
)
Boolean public static

Determines if credit card is valid

Parameters:

Returns:

Example:

 MerchantUtil.isCreditCard('4556106734384949');
 // true

isValidExpirationDate
(
  • month
  • year
)
Boolean

Validate a credit card's expiration date.

Parameters:

Returns:

Example:

 MerchantUtil.isValidExDate(11, 2010);
 // false

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index