-
Notifications
You must be signed in to change notification settings - Fork 3k
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
P2P Enable adding deposit account as payment method #6638
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Popover from './Popover'; | ||
import MenuItem from './MenuItem'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
import styles from '../styles/styles'; | ||
import compose from '../libs/compose'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
import CONST from '../CONST'; | ||
|
||
const propTypes = { | ||
isVisible: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
anchorPosition: PropTypes.shape({ | ||
top: PropTypes.number, | ||
left: PropTypes.number, | ||
}), | ||
|
||
/** Username for PayPal.Me */ | ||
payPalMeUsername: PropTypes.string, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
anchorPosition: {}, | ||
payPalMeUsername: '', | ||
}; | ||
|
||
const AddPaymentMethodMenu = props => ( | ||
<Popover | ||
isVisible={props.isVisible} | ||
onClose={props.onClose} | ||
anchorPosition={props.anchorPosition} | ||
> | ||
<MenuItem | ||
title={props.translate('common.bankAccount')} | ||
icon={Expensicons.Bank} | ||
onPress={() => props.onItemSelected(CONST.PAYMENT_METHODS.BANK_ACCOUNT)} | ||
wrapperStyle={styles.pr15} | ||
/> | ||
<MenuItem | ||
title={props.translate('common.debitCard')} | ||
icon={Expensicons.CreditCard} | ||
onPress={() => props.onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD)} | ||
wrapperStyle={styles.pr15} | ||
/> | ||
{!props.payPalMeUsername && ( | ||
<MenuItem | ||
title={props.translate('common.payPalMe')} | ||
icon={Expensicons.PayPal} | ||
onPress={() => props.onItemSelected(CONST.PAYMENT_METHODS.PAYPAL)} | ||
wrapperStyle={styles.pr15} | ||
/> | ||
)} | ||
</Popover> | ||
); | ||
|
||
AddPaymentMethodMenu.propTypes = propTypes; | ||
AddPaymentMethodMenu.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withLocalize, | ||
withOnyx({ | ||
payPalMeUsername: { | ||
key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, | ||
}, | ||
}), | ||
)(AddPaymentMethodMenu); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import _ from 'underscore'; | ||
import Onyx from 'react-native-onyx'; | ||
import CONST from '../../CONST'; | ||
import * as API from '../API'; | ||
import * as Plaid from './Plaid'; | ||
import * as ReimbursementAccount from './ReimbursementAccount'; | ||
import Navigation from '../Navigation/Navigation'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import * as PaymentMethods from './PaymentMethods'; | ||
|
||
export { | ||
setupWithdrawalAccount, | ||
|
@@ -41,6 +46,7 @@ export { | |
* @param {String} plaidLinkToken | ||
*/ | ||
function addPersonalBankAccount(account, password, plaidLinkToken) { | ||
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: true}); | ||
const unmaskedAccount = _.find(Plaid.getPlaidBankAccounts(), bankAccount => ( | ||
bankAccount.plaidAccountID === account.plaidAccountID | ||
)); | ||
|
@@ -71,12 +77,22 @@ function addPersonalBankAccount(account, password, plaidLinkToken) { | |
}), | ||
}) | ||
.then((response) => { | ||
if (response.jsonCode !== 200) { | ||
alert('There was a problem adding this bank account.'); | ||
if (response.jsonCode === 200) { | ||
PaymentMethods.getPaymentMethods() | ||
.then(() => { | ||
Navigation.goBack(); | ||
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want success growls here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dang yea that would probably be a nice touch. It's pretty strange that we just kick you back to the payments page now that I think about it. But it works for now. |
||
}); | ||
return; | ||
} | ||
|
||
alert('Bank account added successfully.'); | ||
if (response.message === 'Incorrect Expensify password entered') { | ||
ReimbursementAccount.setBankAccountFormValidationErrors({password: true}); | ||
} | ||
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false}); | ||
}) | ||
.catch(() => { | ||
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {loading: false}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failure growl here |
||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nab: prop-type doc