Skip to content

Commit

Permalink
Add Singapore to supported Stripe countries
Browse files Browse the repository at this point in the history
  • Loading branch information
OtterleyW committed Jul 3, 2019
1 parent 18492a2 commit 0fd8e7d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export const mapInputsToStripeAccountKeys = (country, values) => {
routing_number: cleanedString(values[ROUTING_NUMBER]),
account_number: cleanedString(values[ACCOUNT_NUMBER]),
};
case 'SG':
return {
routing_number: cleanedString(values[ROUTING_NUMBER]),
account_number: cleanedString(values[ACCOUNT_NUMBER]),
};
case 'HK':
return {
routing_number: cleanedString(values[CLEARING_CODE]).concat(
Expand Down
4 changes: 3 additions & 1 deletion src/ducks/stripe.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ const personTokenParams = (personData, country) => {
const idNumberMaybe =
country === 'US'
? { ssn_last_4: personalIdNumber }
: country === 'SG'
? { id_number: personalIdNumber }
: personalIdNumber
? { personal_id_number: personalIdNumber }
: {};
Expand Down Expand Up @@ -476,7 +478,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
21 changes: 21 additions & 0 deletions src/stripe-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,25 @@ export const stripeSupportedCountries = [
personalPhone: true,
},
},
{
// Singapore
code: 'SG',
currency: 'SGD',
addressConfig: {
addressLine: true,
postalCode: true,
},
accountConfig: {
routingNumber: true,
accountNumber: true,
},
companyConfig: {
personalAddress: true,
owners: true,
personalIdNumberRequired: true,
},
individualConfig: {
personalIdNumberRequired: true,
},
},
];
4 changes: 4 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
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);

0 comments on commit 0fd8e7d

Please sign in to comment.