Skip to content

Commit

Permalink
Merge pull request Expensify#7929 from Expensify/vit-improveWalletErrors
Browse files Browse the repository at this point in the history
Use more user friendly errors when choosing default fund for Wallet
  • Loading branch information
mountiny authored Mar 10, 2022
2 parents afaccd9 + d1fdfa6 commit 41bd789
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ const CONST = {
UNEXPECTED: 'Unexpected error',
MISSING_FIELD: 'Missing required additional details fields',
UNABLE_TO_VERIFY: 'Unable to verify identity',
NO_ACCOUNT_TO_LINK: '405 No account to link to wallet',
INVALID_WALLET: '405 Invalid wallet account',
NOT_OWNER_OF_BANK_ACCOUNT: '401 Wallet owner does not own linked bank account',
INVALID_BANK_ACCOUNT: '405 Attempting to link an invalid bank account to a wallet',
NOT_OWNER_OF_FUND: '401 Wallet owner does not own linked fund',
INVALID_FUND: '405 Attempting to link an invalid fund to a wallet',
},
STEP: {
ONFIDO: 'OnfidoStep',
Expand Down
8 changes: 7 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default {
enterManually: 'Enter it manually',
message: 'Message ',
leaveRoom: 'Leave room',
conciergeHelp: 'Please reach out to Concierge for help.',
},
attachmentPicker: {
cameraPermissionRequired: 'Camera permission required',
Expand Down Expand Up @@ -357,7 +358,6 @@ export default {
paymentMethodsTitle: 'Payment methods',
setDefaultConfirmation: 'Make default payment method',
setDefaultSuccess: 'Default payment method set!',
setDefaultFailure: 'Failed to set default payment method.',
deleteAccount: 'Delete Account',
deleteConfirmation: 'Are you sure that you want to delete this account?',
deleteBankAccountSuccess: 'Bank account successfully deleted',
Expand All @@ -366,6 +366,12 @@ export default {
allSet: 'All Set!',
transferConfirmText: ({amount}) => `${amount} will hit your account shortly!`,
gotIt: 'Got it, Thanks!',
error: {
notOwnerOfBankAccount: 'There was an error setting this bank account as your default payment method.',
invalidBankAccount: 'This bank account is temporarily suspended.',
notOwnerOfFund: 'There was an error setting this card as your default payment method.',
setDefaultFailure: 'Something went wrong. Please chat with Concierge for further assistance.',
},
},
transferAmountPage: {
transfer: ({amount}) => `Transfer${amount ? ` ${amount}` : ''}`,
Expand Down
8 changes: 7 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default {
enterManually: 'Ingresar manualmente',
message: 'Chatear con ',
leaveRoom: 'Salir de la sala de chat',
conciergeHelp: 'Por favor contacta con Concierge para obtener ayuda.',
},
attachmentPicker: {
cameraPermissionRequired: 'Se necesita permiso para usar la cámara',
Expand Down Expand Up @@ -357,7 +358,6 @@ export default {
paymentMethodsTitle: 'Métodos de pago',
setDefaultConfirmation: 'Marcar como método de pago predeterminado',
setDefaultSuccess: 'Método de pago configurado',
setDefaultFailure: 'No se ha podido configurar el método de pago.',
deleteAccount: 'Eliminar cuenta',
deleteConfirmation: '¿Estás seguro de que quieres eliminar esta cuenta?',
deleteBankAccountSuccess: 'Cuenta bancaria eliminada correctamente',
Expand All @@ -366,6 +366,12 @@ export default {
allSet: 'Todo listo!',
transferConfirmText: ({amount}) => `${amount} llegará a tu cuenta en breve!`,
gotIt: 'Gracias!',
error: {
notOwnerOfBankAccount: 'Ha ocurrido un error al establecer esta cuenta bancaria como tu método de pago predeterminado.',
invalidBankAccount: 'Esta cuenta bancaria está temporalmente suspendida.',
notOwnerOfFund: 'Ha ocurrido un error al establecer esta tarjeta de crédito como tu método de pago predeterminado.',
setDefaultFailure: 'No se ha podido configurar el método de pago.',
},
},
transferAmountPage: {
transfer: ({amount}) => `Transferir${amount ? ` ${amount}` : ''}`,
Expand Down
24 changes: 19 additions & 5 deletions src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,26 @@ function setWalletLinkedAccount(password, bankAccountID, fundID) {
walletLinkedAccountID: bankAccountID || fundID, walletLinkedAccountType: bankAccountID ? CONST.PAYMENT_METHODS.BANK_ACCOUNT : CONST.PAYMENT_METHODS.DEBIT_CARD,
});
Growl.show(Localize.translateLocal('paymentsPage.setDefaultSuccess'), CONST.GROWL.SUCCESS, 5000);
} else {
Growl.show(Localize.translateLocal('paymentsPage.setDefaultFailure'), CONST.GROWL.ERROR, 5000);
return;
}
Growl.show(Localize.translateLocal('paymentsPage.error.setDefaultFailure'), CONST.GROWL.ERROR, 5000);
}).catch((error) => {
// Make sure to show user more specific errors which will help support identify the problem faster.
switch (error.message) {
case CONST.WALLET.ERROR.INVALID_WALLET:
case CONST.WALLET.ERROR.NOT_OWNER_OF_BANK_ACCOUNT:
Growl.show(`${Localize.translateLocal('paymentsPage.error.notOwnerOfBankAccount')} ${Localize.translateLocal('common.conciergeHelp')}`, CONST.GROWL.ERROR, 5000);
return;
case CONST.WALLET.ERROR.NOT_OWNER_OF_FUND:
case CONST.WALLET.ERROR.INVALID_FUND:
Growl.show(`${Localize.translateLocal('paymentsPage.error.notOwnerOfFund')} ${Localize.translateLocal('common.conciergeHelp')}`, CONST.GROWL.ERROR, 5000);
return;
case CONST.WALLET.ERROR.INVALID_BANK_ACCOUNT:
Growl.show(`${Localize.translateLocal('paymentsPage.error.invalidBankAccount')} ${Localize.translateLocal('common.conciergeHelp')}`, CONST.GROWL.ERROR, 5000);
return;
default:
Growl.show(Localize.translateLocal('paymentsPage.error.setDefaultFailure'), CONST.GROWL.ERROR, 5000);
}
})
.catch(() => {
Growl.show(Localize.translateLocal('paymentsPage.setDefaultFailure'), CONST.GROWL.ERROR, 5000);
});
}

Expand Down

0 comments on commit 41bd789

Please sign in to comment.