Skip to content

Commit

Permalink
Add field for personal id number to PayoutDetailsForm
Browse files Browse the repository at this point in the history
  • Loading branch information
OtterleyW committed Dec 5, 2018
1 parent 401ed97 commit 4194e5e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ducks/user.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ export const createStripeAccount = payoutDetails => (dispatch, getState, sdk) =>
state,
province,
bankAccountToken,
personalIdNumber,
} = payoutDetails;

const hasProvince = province && !state;
Expand All @@ -419,6 +420,7 @@ export const createStripeAccount = payoutDetails => (dispatch, getState, sdk) =>
address: omitBy(address, isUndefined),
dob: birthDate,
type: 'individual',
personal_id_number: personalIdNumber,
},
tos_shown_and_accepted: true,
};
Expand Down
41 changes: 40 additions & 1 deletion src/forms/PayoutDetailsForm/PayoutDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ const PayoutDetailsFormComponent = props => (
// out of the field. Therefore the empty validation message.
const bankAccountRequired = validators.required(' ');

const showPersonalIdNumber =
country && stripeCountryConfigs(country).personalIdNumberRequired;

const personalIdNumberLabel = showPersonalIdNumber
? intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberLabel.${country}`,
})
: null;
const personalIdNumberPlaceholder = showPersonalIdNumber
? intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberPlaceholder.${country}`,
})
: null;
const personalIdNumberRequired = showPersonalIdNumber
? validators.required(
intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberRequired`,
})
)
: null;

const classes = classNames(css.root, className, {
[css.disabled]: disabled,
});
Expand Down Expand Up @@ -142,7 +163,6 @@ const PayoutDetailsFormComponent = props => (
<FormattedMessage id="PayoutDetailsForm.stripeConnectedAccountTermsLink" />
</ExternalLink>
);

return (
<Form className={classes} onSubmit={handleSubmit}>
<div className={css.sectionContainer}>
Expand Down Expand Up @@ -228,6 +248,25 @@ const PayoutDetailsFormComponent = props => (
</div>
) : null}
{error}

{showPersonalIdNumber ? (
<div className={css.sectionContainer}>
<h3 className={css.subTitle}>
<FormattedMessage id="PayoutDetailsForm.personalIdNumberTitle" />
</h3>
<FieldTextInput
id="personalIdNumber"
name="personalIdNumber"
disabled={disabled}
className={css.personalIdNumber}
type="text"
label={personalIdNumberLabel}
placeholder={personalIdNumberPlaceholder}
validate={personalIdNumberRequired}
/>
</div>
) : null}

<p className={css.termsText}>
<FormattedMessage
id="PayoutDetailsForm.stripeToSText"
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@
"PayoutDetailsForm.lastNamePlaceholder": "Doe",
"PayoutDetailsForm.lastNameRequired": "This field is required",
"PayoutDetailsForm.personalDetailsTitle": "Personal details",
"PayoutDetailsForm.personalIdNumberTitle": "Personal id number",
"PayoutDetailsForm.personalIdNumberRequired": "This field is required",
"PayoutDetailsForm.postalCodeLabel": "Postal code",
"PayoutDetailsForm.postalCodePlaceholder": "00100",
"PayoutDetailsForm.postalCodeRequired": "This field is required",
Expand Down

0 comments on commit 4194e5e

Please sign in to comment.