File size: 877 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Checkout validation and API

This module contains functions to validate and mask checkout form fields such as credit card fields.

## API

### `validatePaymentDetails( paymentDetails, paymentType )`

Returns an object containing the errors for each field. For example the returned object might look like this:

```js
const error = {
	number: [ 'Invalid credit card' ],
};
```

If there are any missing fields, there are no errors for that field.

### `getCreditCardType( number )`

Returns credit card brand for a given card number

### `maskField( fieldName, previousValue, nextValue )`

Returns a masked input value for the given field based on the current value and the next value to replace it with.

### `unmaskField( fieldName, previousValue, nextValue )`

Returns an unmasked input value that is meant to be used within the program rather than displayed to the user.