# MerchantUtil Class

Defined in: `js/util/MerchantUtil.js:9`
Module: util
Parent Module: StructureJS

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

## Index

Show: Inherited Protected Private Deprecated

### Methods

- encodeCreditCardNumber static
- getCreditCardProvider
- isCreditCard static
- isValidExpirationDate

## Methods

### `encodeCreditCardNumber`
(

- `strNumber`
- `[digitsShown=4]`
- `[encodeChar=*]`

)
String public static

Defined in `js/util/MerchantUtil.js:54`

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

Defined in `js/util/MerchantUtil.js:81`

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

Defined in `js/util/MerchantUtil.js:22`

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

Defined in `js/util/MerchantUtil.js:117`

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