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

fixing EU Country data #363

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 44 additions & 4 deletions _base/src/pages/api/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
SupportedCountry,
} from "src/utils/account-management-helpers";
import { handlerMapping } from "src/utils/api-helpers";
import { isDemoMode, TOS_ACCEPTANCE } from "src/utils/demo-helpers";
import {
getFakeAddressByCountry,
isDemoMode,
TOS_ACCEPTANCE,
} from "src/utils/demo-helpers";
import { createAccountOnboardingUrl } from "src/utils/onboarding-helpers";
import { getSessionForServerSide } from "src/utils/session-helpers";
import stripeClient from "src/utils/stripe-loader";
Expand All @@ -31,6 +35,8 @@ const onboard = async (req: NextApiRequest, res: NextApiResponse) => {
} = session;
const { accountId, platform } = stripeAccount;

const countryData = getFakeAddressByCountry(country);

const {
businessName,
skipOnboarding,
Expand Down Expand Up @@ -82,11 +88,16 @@ const onboard = async (req: NextApiRequest, res: NextApiResponse) => {
name: businessName,
// Fake business TIN: https://stripe.com/docs/connect/testing#test-business-tax-ids
tax_id: "000000000",
...(country === SupportedCountry.DE && {
tax_id: "HRA000000000",
}),
},
individual: {
address: {
// This value causes the address to be verified in testmode: https://stripe.com/docs/connect/testing#test-verification-addresses
line1: "address_full_match",
city: countryData.city,
postal_code: countryData.postalCode,
// @if financialProduct==embedded-finance
...(country === SupportedCountry.US && {
city: "South San Francisco",
Expand All @@ -95,9 +106,38 @@ const onboard = async (req: NextApiRequest, res: NextApiResponse) => {
}),
// @endif
// @if financialProduct==expense-management
...(country === SupportedCountry.UK && {
city: "London",
postal_code: "WC32 4AP",
//OVERRIDDING faker generates invalid country data
...(country === SupportedCountry.BE && {
city: "Brussel",
postal_code: "1000",
}),
...(country === SupportedCountry.FI && {
city: "Helsinki",
postal_code: "00100",
}),
...(country === SupportedCountry.FR && {
city: "Paris",
postal_code: "75001",
}),
...(country === SupportedCountry.DE && {
city: "Berlin",
postal_code: "10115",
}),
...(country === SupportedCountry.LU && {
city: "Luxemburg",
postal_code: "1111",
}),
...(country === SupportedCountry.NL && {
city: "Amsterdam",
postal_code: "1008 DG",
}),
...(country === SupportedCountry.PT && {
city: "Lisbon",
postal_code: "1000",
}),
...(country === SupportedCountry.ES && {
city: "Madrid",
postal_code: "28001",
}),
// @endif
country: country.toString(),
Expand Down
83 changes: 80 additions & 3 deletions _base/src/utils/demo-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,46 @@ export const getFakePhoneByCountry = (country: SupportedCountry): string => {

switch (country) {
// @if financialProduct==expense-management
case SupportedCountry.AT:
return faker.phone.number("+43(#)### ####"); //Austria
case SupportedCountry.BE:
return faker.phone.number("+32(#)## ## ## ##"); //Belgium
case SupportedCountry.CY:
return faker.phone.number("+357(9)# ### ###"); //Cyprus
case SupportedCountry.DE:
return faker.phone.number("+49(#)#### #####"); //Germany
case SupportedCountry.EE:
return faker.phone.number("+372 ### ####"); //Estonia
case SupportedCountry.ES:
return faker.phone.number("+34(91)### ####"); //Spain
case SupportedCountry.FI:
return faker.phone.number("+358(#)## ### ####"); //Finland
case SupportedCountry.FR:
return faker.phone.number("+33(#)## ## ## ##"); //France
case SupportedCountry.GR:
return faker.phone.number("+30(#)### #### ###"); //Greece
case SupportedCountry.HR:
return faker.phone.number("+385 43 ### ###"); //Croatia
case SupportedCountry.IE:
return faker.phone.number("+353(#)## ### ####"); //Ireland
case SupportedCountry.IT:
return faker.phone.number("+39(###) ### ####"); //Italy
case SupportedCountry.LT:
return faker.phone.number("+370(#)## ######"); //Lithuania
case SupportedCountry.LU:
return faker.phone.number("+352 ### ###"); //Luxeumburg
case SupportedCountry.LV:
return faker.phone.number("+371(2) ### ####"); //Latvia
case SupportedCountry.MT:
return faker.phone.number("+356 #### ####"); //Malta
case SupportedCountry.NL:
return faker.phone.number("+31 (06) #### ####"); //Netherland
case SupportedCountry.PT:
return faker.phone.number("+351 2## ### ###"); //Portugal
case SupportedCountry.SI:
return faker.phone.number("+386(#)### ## ##"); //Slovenia
case SupportedCountry.SK:
return faker.phone.number("+386(#)### ## ##"); //Slovakia
case SupportedCountry.UK:
return faker.phone.number("07#########"); // UK phone number format
// @endif
Expand All @@ -91,14 +131,51 @@ export const getFakePhoneByCountry = (country: SupportedCountry): string => {
}
};

const euCountriesList = [
"AT",
"BE",
"CY",
"DE",
"EE",
"ES",
"FI",
"FR",
"GR",
"HR",
"IE",
"IT",
"LT",
"LU",
"LV",
"MT",
"NL",
"PT",
"SI",
"SK",
];

export const getFakeAddressByCountry = (
country: SupportedCountry,
): FakeAddress => {
const faker = LocalizedFakerMap[country] as Faker;

switch (country) {
let region = "US";
if (euCountriesList.includes(country)) {
region = "EU";
} else if (country === "GB") {
region = "UK";
}

switch (region) {
// @if financialProduct==expense-management
case SupportedCountry.UK:
case "EU":
return {
address1: faker.location.streetAddress(),
city: faker.location.city(),
state: faker.location.county(),
postalCode: faker.location.zipCode(),
};
case "UK": //SupportedCountry.UK:
return {
address1: faker.location.streetAddress(),
city: faker.location.city(),
Expand All @@ -107,7 +184,7 @@ export const getFakeAddressByCountry = (
};
// @endif
// @if financialProduct==embedded-finance
case SupportedCountry.US:
case "US": //SupportedCountry.US:
return {
address1: faker.location.streetAddress(),
city: faker.location.city(),
Expand Down