Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate BankAccount_SetupWithdrawalAccount API #3507

Merged
merged 26 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c219c9e
add models
marcaaron Jun 10, 2021
6eac7d4
add BankAccount model
marcaaron Jun 10, 2021
cc78e01
update some consts
marcaaron Jun 10, 2021
c810c56
attempt to migrate stuff to a controller page for now while make sens…
marcaaron Jun 10, 2021
4f96379
sketch out plan
marcaaron Jun 11, 2021
99e0f81
move setupWithdrawalAccount into an action so that our views can pure…
marcaaron Jun 11, 2021
3319c16
move everything into actions clean up temp view
marcaaron Jun 11, 2021
ca91a0c
fix conflicts
marcaaron Jun 11, 2021
d61a525
fix conflicts and rename some things
marcaaron Jun 11, 2021
e966390
reorganize things a bit and fix incorrect API usage
marcaaron Jun 11, 2021
a7eaefe
dont pass achData
marcaaron Jun 11, 2021
4bebfbb
fix Permissions issue. rename goToStepID to goToWithdrawalStepID
marcaaron Jun 11, 2021
76b67ce
use unmasked accountNumber
marcaaron Jun 11, 2021
c3b8007
clean up some TODOs
marcaaron Jun 11, 2021
e31e101
fix up some CONSTs
marcaaron Jun 11, 2021
36e5a97
fix propTypes and error messages
marcaaron Jun 11, 2021
b96c297
change BusinessBankAccountNewPage to BankAccountStep
marcaaron Jun 11, 2021
661ee34
Fix comments style etc
marcaaron Jun 11, 2021
e01ae51
fix conflicts
marcaaron Jun 14, 2021
e85f587
fix new workspace modal
marcaaron Jun 14, 2021
825d108
make some requested changes
marcaaron Jun 14, 2021
c900d39
Make requested changes
marcaaron Jun 14, 2021
1b1e210
Make some requested changes
marcaaron Jun 15, 2021
a48ddb5
use promiseAllSettled
marcaaron Jun 15, 2021
635bebf
add growl for errors
marcaaron Jun 15, 2021
b408663
fix comment
marcaaron Jun 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,40 @@ const CONST = {
IOS: 'https://apps.apple.com/us/app/expensify-cash/id1530278510',
DESKTOP: 'https://expensify.cash/Expensify.cash.dmg',
},
SMS: {
DOMAIN: '@expensify.sms',
},
BANK_ACCOUNT: {
ADD_METHOD: {
STEP: {
BANK_ACCOUNT: 'BankAccountStep',
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
COMPANY: 'CompanyStep',
REQUESTOR: 'RequestorStep',
ACH_CONTRACT: 'ACHContractStep',
VALIDATION: 'ValidationStep',
ENABLE: 'EnableStep',
},
SUBSTEP: {
MANUAL: 'manual',
},
VERIFICATIONS: {
ERROR_MESSAGE: 'verifications.errorMessage',
EXTERNAL_API_RESPONSES: 'verifications.externalApiResponses',
REQUESTOR_IDENTITY_ID: 'verifications.externalApiResponses.requestorIdentityID',
REQUESTOR_IDENTITY_ONFIDO: 'verifications.externalApiResponses.requestorIdentityOnfido',
THROTTLED: 'verifications.throttled',
},
FIELDS_TYPE: {
LOCAL: 'local',
},
ONFIDO_RESPONSE: {
SDK_TOKEN: 'apiResult.sdkToken',
PASS: 'pass',
},
QUESTIONS: {
QUESTION: 'apiResult.questions.question',
DIFFERENTIATOR_QUESTION: 'apiResult.differentiator-question',
},
SETUP_TYPE: {
MANUAL: 'manual',
PLAID: 'plaid',
},
Expand All @@ -30,6 +62,12 @@ const CONST = {
PRESSED: 'pressed',
COMPLETE: 'complete',
},
COUNTRY: {
US: 'US',
MX: 'MX',
AU: 'AU',
CA: 'CA',
},
PLATFORM: {
IOS: 'ios',
ANDROID: 'android',
Expand Down Expand Up @@ -120,6 +158,8 @@ const CONST = {
PAYPAL_ME_ADDRESS: 'expensify_payPalMeAddress',
PRIORITY_MODE: 'priorityMode',
TIMEZONE: 'timeZone',
FREE_PLAN_BANK_ACCOUNT_ID: 'expensify_freePlanBankAccountID',
ACH_DATA_THROTTLED: 'expensify_ACHData_throttled',
},
DEFAULT_TIME_ZONE: {automatic: true, selected: 'America/Los_Angeles'},
DEFAULT_ACCOUNT_DATA: {error: '', success: '', loading: false},
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ export default {

// Object containing Wallet terms step state
WALLET_TERMS: 'walletTerms',

// Stores information about the active reimbursement account being set up
REIMBURSEMENT_ACCOUNT: 'reimbursementAccount',
};
2 changes: 1 addition & 1 deletion src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const REPORT = 'r';

export default {
ADD_PERSONAL_BANK_ACCOUNT: 'add-personal-bank-account',
BANK_ACCOUNT_NEW: 'bank-account/new',
ADD_VERIFIED_BANK_ACCOUNT: 'add-verified-bank-account',
HOME: '',
SETTINGS: 'settings',
SETTINGS_PROFILE: 'settings/profile',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ export default {
plaidBodyCopy: 'Give your employees an easier way to pay - and get paid back - for company expenses.',
checkHelpLine: 'Your routing number and account number can be found on a check for the account.',
iAcceptThe: 'I accept the ',
hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.',
hasBeenThrottledError: ({fromNow}) => `For security reasons, we're taking a break from bank account setup so you can double-check your company information. Please try again ${fromNow}. Sorry!`,
},
addPersonalBankAccountPage: {
enterPassword: 'Enter password',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ export default {
plaidBodyCopy: 'Ofrezca a sus empleados una forma más sencilla de pagar - y recuperar - los gastos de la empresa.',
checkHelpLine: 'Su número de ruta y número de cuenta se pueden encontrar en un cheque para la cuenta.',
iAcceptThe: 'Acepto los ',
hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrese de que su inicio de sesión principal sea un correo electrónico válido y vuelva a intentarlo. Puede agregar su número de teléfono como inicio de sesión secundario.',
hasBeenThrottledError: ({fromNow}) => `Por razones de seguridad, nos tomamos un descanso de la configuración de la cuenta bancaria para que pueda verificar la información de su empresa. Inténtalo de nuevo ${fromNow}. Lo siento!`,
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
},
addPersonalBankAccountPage: {
enterPassword: 'Escribe una contraseña',
Expand Down
43 changes: 43 additions & 0 deletions src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,48 @@ function BankAccount_Create(parameters) {
return Network.post(commandName, parameters, CONST.NETWORK.METHOD.POST, true);
}

/**
* @param {*} parameters
* @returns {Promise}
*/
function BankAccount_SetupWithdrawal(parameters) {
const commandName = 'BankAccount_SetupWithdrawal';
let allowedParameters = [
'currentStep', 'policyID', 'bankAccountID', 'useOnfido', 'errorAttemptsCount',

// data from bankAccount step:
'setupType', 'routingNumber', 'accountNumber', 'addressName', 'plaidAccountID', 'ownershipType', 'isSavings',
'acceptTerms', 'bankName', 'plaidAccessToken', 'alternateRoutingNumber',

// data from company step:
'companyName', 'companyTaxID', 'addressStreet', 'addressCity', 'addressState', 'addressZipCode',
'hasNoConnectionToCannabis', 'incorporationType', 'incorporationState', 'incorporationDate', 'industryCode',
'website', 'companyPhone', 'ficticiousBusinessName',

// data from requestor step:
'firstName', 'lastName', 'dob', 'requestorAddressStreet', 'requestorAddressCity', 'requestorAddressState',
'requestorAddressZipCode', 'isOnfidoSetupComplete', 'onfidoData', 'isControllingOfficer', 'ssnLast4',

// data from ACHContract step (which became the "Beneficial Owners" step, but the key is still ACHContract as
// it's used in several logic:
'ownsMoreThan25Percent', 'beneficialOwners', 'acceptTermsAndConditions', 'certifyTrueInformation',
];

if (!parameters.useOnfido) {
allowedParameters = allowedParameters.concat(['passport', 'answers']);
}

// Only keep allowed parameters in the additionalData object
const additionalData = _.pick(parameters, allowedParameters);

requireParameters(['currentStep'], parameters, commandName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another thing we could create a follow-up for, but are there different sets of required parameters for each step? Might be more comprehensible to have something like:

const requiredParameters = [
    CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: [
        // the required parameters for this step
    ],
    CONST.BANK_ACCOUNT.STEP.COMPANY: [
        // the required parameters for this step
    ],
    ...
    ...
];

And that could help us do better client-side validation 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I think something like that would clean this up maybe. They are also not used anywhere else atm.

return Network.post(
commandName, {additionalData: JSON.stringify(additionalData), password: parameters.password},
CONST.NETWORK.METHOD.POST,
true,
);
}

/**
* @param {Object} parameters
* @param {String[]} data
Expand Down Expand Up @@ -850,6 +892,7 @@ export {
Authenticate,
BankAccount_Create,
BankAccount_Get,
BankAccount_SetupWithdrawal,
ChangePassword,
CreateChatReport,
CreateLogin,
Expand Down
12 changes: 6 additions & 6 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import {
NewChatModalStackNavigator,
SettingsModalStackNavigator,
EnablePaymentsStackNavigator,
BusinessBankAccountModalStackNavigator,
AddPersonalBankAccountModalStackNavigator,
ReimbursementAccountModalStackNavigator,
NewWorkspaceStackNavigator,
} from './ModalStackNavigators';
import SCREENS from '../../../SCREENS';
Expand Down Expand Up @@ -278,15 +278,15 @@ class AuthScreens extends React.Component {
listeners={modalScreenListeners}
/>
<RootStack.Screen
name="NewWorkspace"
name="ReimbursementAccount"
options={modalScreenOptions}
component={NewWorkspaceStackNavigator}
component={ReimbursementAccountModalStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name="BusinessBankAccount"
name="NewWorkspace"
options={modalScreenOptions}
component={BusinessBankAccountModalStackNavigator}
listeners={modalScreenListeners}
component={NewWorkspaceStackNavigator}
/>
</RootStack.Navigator>
);
Expand Down
16 changes: 7 additions & 9 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import SettingsAddSecondaryLoginPage from '../../../pages/settings/AddSecondaryL
import IOUCurrencySelection from '../../../pages/iou/IOUCurrencySelection';
import ReportParticipantsPage from '../../../pages/ReportParticipantsPage';
import EnablePaymentsPage from '../../../pages/EnablePayments';
import BusinessBankAccountNewPage from '../../../pages/BusinessBankAccount/NewPage';
import AddPersonalBankAccountPage from '../../../pages/AddPersonalBankAccountPage';
import ReimbursementAccountPage from '../../../pages/ReimbursementAccount/ReimbursementAccountPage';
import NewWorkspacePage from '../../../pages/workspace/NewWorkspacePage';

const defaultSubRouteOptions = {
Expand Down Expand Up @@ -154,18 +154,16 @@ const AddPersonalBankAccountModalStackNavigator = createModalStackNavigator([{
name: 'AddPersonalBankAccount_Root',
}]);

const ReimbursementAccountModalStackNavigator = createModalStackNavigator([{
Component: ReimbursementAccountPage,
name: 'ReimbursementAccount_Root',
}]);

const NewWorkspaceStackNavigator = createModalStackNavigator([{
Component: NewWorkspacePage,
name: 'NewWorkspace_Root',
}]);

const BusinessBankAccountModalStackNavigator = createModalStackNavigator([
{
Component: BusinessBankAccountNewPage,
name: 'BusinessBankAccount_New',
},
]);

export {
IOUBillStackNavigator,
IOURequestModalStackNavigator,
Expand All @@ -177,7 +175,7 @@ export {
NewChatModalStackNavigator,
SettingsModalStackNavigator,
EnablePaymentsStackNavigator,
BusinessBankAccountModalStackNavigator,
AddPersonalBankAccountModalStackNavigator,
ReimbursementAccountModalStackNavigator,
NewWorkspaceStackNavigator,
};
8 changes: 4 additions & 4 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ export default {
AddPersonalBankAccount_Root: ROUTES.ADD_PERSONAL_BANK_ACCOUNT,
},
},
BusinessBankAccount: {
EnablePayments: {
screens: {
BusinessBankAccount_New: ROUTES.BANK_ACCOUNT_NEW,
EnablePayments_Root: ROUTES.ENABLE_PAYMENTS,
},
},
EnablePayments: {
ReimbursementAccount: {
screens: {
EnablePayments_Root: ROUTES.ENABLE_PAYMENTS,
ReimbursementAccount_Root: ROUTES.ADD_VERIFIED_BANK_ACCOUNT,
},
},
NewWorkspace: {
Expand Down
Loading