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

Add Singapore to supported Stripe countries #1122

Merged
merged 3 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2019-XX-XX

- [add] Add support for Singapore as the payout country of a provider. Also fix a bug in passing the
personal ID number to Stripe. [#1122](https://github.com/sharetribe/flex-template-web/pull/1122)
- [add] Add events.mapbox.com to `connect-src` in `csp.js` file.
[#1123](https://github.com/sharetribe/flex-template-web/pull/1123)
- [change] Verify email automatically once the verification link is clicked. Redirect the user to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const INSTITUTION_NUMBER = 'institutionNumber';
export const TRANSIT_NUMBER = 'transitNumber';
// Needed for creating full routing number in Hong Kong
export const CLEARING_CODE = 'clearingCode';
// Needed for creating full routing number in Hong Kong
// Needed for creating full routing number in Hong Kong and Singapore
export const BRANCH_CODE = 'branchCode';
// Needed for creating full routing number in Singapore
export const BANK_CODE = 'bankCode';
// International bank account number (e.g. EU countries use this)
export const IBAN = 'iban';
// Routing number to separate bank account in different areas
Expand All @@ -29,6 +31,7 @@ export const BANK_ACCOUNT_INPUTS = [
INSTITUTION_NUMBER,
CLEARING_CODE,
BRANCH_CODE,
BANK_CODE,
SORT_CODE,
ROUTING_NUMBER,
ACCOUNT_NUMBER,
Expand Down Expand Up @@ -190,6 +193,14 @@ export const mapInputsToStripeAccountKeys = (country, values) => {
routing_number: cleanedString(values[ROUTING_NUMBER]),
account_number: cleanedString(values[ACCOUNT_NUMBER]),
};
case 'SG':
return {
routing_number: cleanedString(values[BANK_CODE]).concat(
'-',
cleanedString(values[BRANCH_CODE])
),
account_number: cleanedString(values[ACCOUNT_NUMBER]),
};
case 'HK':
return {
routing_number: cleanedString(values[CLEARING_CODE]).concat(
Expand Down
4 changes: 2 additions & 2 deletions src/ducks/stripe.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const personTokenParams = (personData, country) => {
country === 'US'
? { ssn_last_4: personalIdNumber }
: personalIdNumber
? { personal_id_number: personalIdNumber }
? { id_number: personalIdNumber }
: {};

const accountOpenerMaybe = isAccountOpener ? { account_opener: true } : {};
Expand Down Expand Up @@ -476,7 +476,7 @@ const accountTokenParamsForIndividual = (individual, country) => {
country === 'US'
? { ssn_last_4: personalIdNumber }
: personalIdNumber
? { personal_id_number: personalIdNumber }
? { id_number: personalIdNumber }
: {};

return {
Expand Down
13 changes: 13 additions & 0 deletions src/forms/PayoutDetailsForm/PayoutDetailsPersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ const PayoutDetailsPersonalDetails = props => {
})
);
personalIdNumberValid = validators.composeValidators(personalIdNumberRequired, validHKID);
} else if (country === 'SG') {
personalIdNumberLabel = intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberLabel.SG`,
});
personalIdNumberPlaceholder = intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberPlaceholder.SG`,
});
const validSGID = validators.validSGID(
intl.formatMessage({
id: `PayoutDetailsForm.personalIdNumberValid`,
})
);
personalIdNumberValid = validators.composeValidators(personalIdNumberRequired, validSGID);
}

const phoneLabel = intl.formatMessage({ id: 'PayoutDetailsForm.personalPhoneLabel' });
Expand Down
22 changes: 22 additions & 0 deletions src/stripe-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,28 @@ export const stripeSupportedCountries = [
owners: true,
},
},
{
// Singapore
code: 'SG',
currency: 'SGD',
addressConfig: {
addressLine: true,
postalCode: true,
},
accountConfig: {
bankCode: true,
branchCode: true,
accountNumber: true,
},
companyConfig: {
personalAddress: true,
owners: true,
personalIdNumberRequired: true,
},
individualConfig: {
personalIdNumberRequired: true,
},
},
{
// Spain
code: 'ES',
Expand Down
8 changes: 8 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@
"PayoutDetailsForm.companyTaxIdLabel.NZ": "NZBN",
"PayoutDetailsForm.companyTaxIdLabel.PT": "N.º Contribuinte",
"PayoutDetailsForm.companyTaxIdLabel.SE": "Organisationsnummer",
"PayoutDetailsForm.companyTaxIdLabel.SG": "Unique Entity Number (UEN)",
"PayoutDetailsForm.companyTaxIdLabel.US": "Tax ID",
"PayoutDetailsForm.companyTaxIdPlaceholder": "Enter {idName}…",
"PayoutDetailsForm.companyTaxIdRequired": "{idName} is required",
Expand All @@ -557,6 +558,7 @@
"PayoutDetailsForm.countryNames.NZ": "New Zealand",
"PayoutDetailsForm.countryNames.PT": "Portugal",
"PayoutDetailsForm.countryNames.SE": "Sweden",
"PayoutDetailsForm.countryNames.SG": "Singapore",
"PayoutDetailsForm.countryNames.US": "United States",
"PayoutDetailsForm.countryPlaceholder": "Select your country…",
"PayoutDetailsForm.countryRequired": "This field is required",
Expand All @@ -583,8 +585,10 @@
"PayoutDetailsForm.personalEmailPlaceholder": "Email address",
"PayoutDetailsForm.personalEmailRequired": "This field is required",
"PayoutDetailsForm.personalIdNumberLabel.HK": "Hong Kong Identity Card Number (HKID)",
"PayoutDetailsForm.personalIdNumberLabel.SG": "National Registration Identity Card (NRIC) or Foreign Identification Number (FIN)",
"PayoutDetailsForm.personalIdNumberLabel.US": "Last 4 digits of social security number (SSN)",
"PayoutDetailsForm.personalIdNumberPlaceholder.HK": "XY123456",
"PayoutDetailsForm.personalIdNumberPlaceholder.SG": "S8888888A",
"PayoutDetailsForm.personalIdNumberPlaceholder.US": "1234",
"PayoutDetailsForm.personalIdNumberRequired": "This field is required",
"PayoutDetailsForm.personalIdNumberTitle": "Personal id number",
Expand Down Expand Up @@ -743,6 +747,10 @@
"StripeBankAccountTokenInputField.accountNumber.placeholder": "Type in bank account number…",
"StripeBankAccountTokenInputField.accountNumber.required": "Bank account number is required",
"StripeBankAccountTokenInputField.andBeforeLastItemInAList": " and",
"StripeBankAccountTokenInputField.bankCode.inline": "bank code",
"StripeBankAccountTokenInputField.bankCode.label": "Bank code",
"StripeBankAccountTokenInputField.bankCode.placeholder": "Type in bank code…",
"StripeBankAccountTokenInputField.bankCode.required": "Bank code is required",
"StripeBankAccountTokenInputField.branchCode.inline": "branch code",
"StripeBankAccountTokenInputField.branchCode.label": "Branch code",
"StripeBankAccountTokenInputField.branchCode.placeholder": "Type in branch code…",
Expand Down
4 changes: 4 additions & 0 deletions src/util/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,9 @@ export const validHKID = message => value => {
return isValid ? VALID : message;
};

export const validSGID = message => value => {
return value.length === 9 ? VALID : message;
};

export const composeValidators = (...validators) => value =>
validators.reduce((error, validator) => error || validator(value), VALID);