Skip to content

Commit

Permalink
Ask for full SSN when lexisNexis cannot find it for P2P KYC
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuoch committed Feb 28, 2022
1 parent 5d6eeb9 commit efca071
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ const CONST = {
},
},
ERROR: {
FULL_SSN_NOT_FOUND: 'Full SSN not found',
IDENTITY_NOT_FOUND: 'Identity not found',
INVALID_SSN: 'Invalid SSN',
UNEXPECTED: 'Unexpected error',
Expand Down Expand Up @@ -570,6 +571,7 @@ const CONST = {
ZIP_CODE: /[0-9]{5}(?:[- ][0-9]{4})?/,
INDUSTRY_CODE: /^[0-9]{6}$/,
SSN_LAST_FOUR: /^(?!0000)[0-9]{4}$/,
SSN_FULL_NINE: /^(?!0000)[0-9]{9}$/,
NUMBER: /^[0-9]+$/,
CARD_NUMBER: /^[0-9]{15,16}$/,
CARD_SECURITY_CODE: /^[0-9]{3,4}$/,
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
here: 'here',
dob: 'Date of birth',
ssnLast4: 'Last 4 digits of SSN',
ssnFull9: 'Full 9 digits of SSN',
personalAddress: 'Personal address',
companyAddress: 'Company address',
noPO: 'PO boxes and mail drop addresses are not allowed',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
here: 'aquí',
dob: 'Fecha de Nacimiento',
ssnLast4: 'Últimos 4 dígitos de su SSN',
ssnFull9: 'Los 9 dígitos del SSN',
personalAddress: 'Dirección física personal',
companyAddress: 'Dirección física de la empresa',
noPO: 'No se aceptan apartados ni direcciones postales',
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ValidationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ function isValidSSNLastFour(ssnLast4) {
return CONST.REGEX.SSN_LAST_FOUR.test(ssnLast4);
}

/**
* @param {String} ssnFull9
* @returns {Boolean}
*/
function isValidSSNFullNine(ssnFull9) {
return CONST.REGEX.SSN_FULL_NINE.test(ssnFull9);
}

/**
*
* @param {String} paypalUsername
Expand Down Expand Up @@ -370,6 +378,7 @@ export {
isValidPaypalUsername,
isValidRoutingNumber,
isValidSSNLastFour,
isValidSSNFullNine,
doesFailCharacterLimit,
isReservedRoomName,
isExistingRoomName,
Expand Down
33 changes: 18 additions & 15 deletions src/libs/actions/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function setAdditionalDetailsErrorMessage(additionalErrorMessage) {
Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {additionalErrorMessage});
}

/**
* @param {Boolean} shouldAskForFullSSN
*/
function setAdditionalDetailsShouldAskForFullSSN(shouldAskForFullSSN) {
Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {shouldAskForFullSSN});
}

/**
* This action can be called repeatedly with different steps until an Expensify Wallet has been activated.
*
Expand Down Expand Up @@ -105,36 +112,34 @@ function activateWallet(currentStep, parameters) {
}

if (currentStep === CONST.WALLET.STEP.ADDITIONAL_DETAILS) {
// Hide the loader
setAdditionalDetailsLoading(false);

if (response.title === CONST.WALLET.ERROR.MISSING_FIELD) {
// Errors for missing fields are returned from the API as an array of strings so we are converting this to an
// object with field names as keys and boolean for values
const errorFields = _.reduce(response.data.fieldNames, (errors, fieldName) => ({
// Convert array of strings to object with field names as keys and boolean for values (true if error, false if not)
const errorFields = _.has(response, ['data', 'fieldNames']) ? _.reduce(response.data.fieldNames, (errors, fieldName) => ({
...errors,
[fieldName]: true,
}), {});
setAdditionalDetailsLoading(false);
}), {}) : {};
setAdditionalDetailsErrors(errorFields);
setAdditionalDetailsErrorMessage('');
return;
}

if (response.title === CONST.WALLET.ERROR.FULL_SSN_NOT_FOUND) {
setAdditionalDetailsShouldAskForFullSSN(true);
}

const errorTitles = [
CONST.WALLET.ERROR.FULL_SSN_NOT_FOUND,
CONST.WALLET.ERROR.IDENTITY_NOT_FOUND,
CONST.WALLET.ERROR.INVALID_SSN,
CONST.WALLET.ERROR.UNEXPECTED,
CONST.WALLET.ERROR.UNABLE_TO_VERIFY,
];

if (_.contains(errorTitles, response.title)) {
setAdditionalDetailsLoading(false);
setAdditionalDetailsErrorMessage(response.message);
setAdditionalDetailsErrors(null);
return;
}

setAdditionalDetailsLoading(false);
setAdditionalDetailsErrors(null);
setAdditionalDetailsErrorMessage('');
return;
}

Expand All @@ -154,8 +159,6 @@ function activateWallet(currentStep, parameters) {
Onyx.merge(ONYXKEYS.WALLET_ONFIDO, {error: '', loading: true});
} else if (currentStep === CONST.WALLET.STEP.ADDITIONAL_DETAILS) {
setAdditionalDetailsLoading(false);
setAdditionalDetailsErrors(null);
setAdditionalDetailsErrorMessage('');
} else if (currentStep === CONST.WALLET.STEP.TERMS) {
Onyx.merge(ONYXKEYS.WALLET_TERMS, {loading: false});
}
Expand Down
12 changes: 8 additions & 4 deletions src/pages/EnablePayments/AdditionalDetailsStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const propTypes = {

const defaultProps = {
walletAdditionalDetails: {
errorFields: [],
errorFields: {},
loading: false,
additionalErrorMessage: '',
},
Expand Down Expand Up @@ -78,6 +78,7 @@ class AdditionalDetailsStep extends React.Component {
phoneNumber: 'common.phoneNumber',
dob: 'common.dob',
ssn: 'common.ssnLast4',
ssnFull9: 'common.ssnFull9',
};

this.state = {
Expand Down Expand Up @@ -141,7 +142,7 @@ class AdditionalDetailsStep extends React.Component {
errors.addressStreet = true;
}

if (!ValidationUtils.isValidSSNLastFour(this.state.ssn)) {
if (!ValidationUtils.isValidSSNLastFour(this.state.ssn) && !ValidationUtils.isValidSSNFullNine(this.state.ssn)) {
errors.ssn = true;
}

Expand Down Expand Up @@ -180,6 +181,8 @@ class AdditionalDetailsStep extends React.Component {
render() {
const isErrorVisible = _.size(this.getErrors()) > 0
|| lodashGet(this.props, 'walletAdditionalDetails.additionalErrorMessage', '').length > 0;
const shouldAskForFullSSN = this.props.walletAdditionalDetails.shouldAskForFullSSN;

return (
<ScreenWrapper>
<KeyboardAvoidingView style={[styles.flex1]} behavior="height">
Expand Down Expand Up @@ -230,6 +233,7 @@ class AdditionalDetailsStep extends React.Component {
});
}}
errorText={this.getErrorText('addressStreet')}
autoComplete="off"
/>
<Text style={[styles.mutedTextLabel, styles.mt1]}>
{this.props.translate('common.noPO')}
Expand All @@ -253,11 +257,11 @@ class AdditionalDetailsStep extends React.Component {
/>
<TextInput
containerStyles={[styles.mt4]}
label={this.props.translate(this.fieldNameTranslationKeys.ssn)}
label={this.props.translate(this.fieldNameTranslationKeys[shouldAskForFullSSN ? 'ssnFull9' : 'ssn'])}
onChangeText={val => this.clearErrorAndSetValue('ssn', val)}
value={this.state.ssn}
errorText={this.getErrorText('ssn')}
maxLength={4}
maxLength={shouldAskForFullSSN ? 9 : 4}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
/>
</View>
Expand Down

0 comments on commit efca071

Please sign in to comment.