StructureJS

0.13.3

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

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

Index

Show:

Methods

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:

String:

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:

  • cardNumber String

Returns:

String:

Example:

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

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

isCreditCard
(
  • cardNumber
)
Boolean public static

Determines if credit card is valid using the Luhn formula.

Parameters:

  • cardNumber String

    The credit card number.

Returns:

Boolean:

true if String is a valid credit card number; otherwise false.

Example:

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

isValidExpirationDate
(
  • month
  • year
)
Boolean

Validate a credit card's expiration date.

Parameters:

  • month Number
  • year Number

Returns:

Boolean:

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