diff --git a/_base/src/pages/api/onboard.ts b/_base/src/pages/api/onboard.ts index 1e4899e6..884a59a8 100644 --- a/_base/src/pages/api/onboard.ts +++ b/_base/src/pages/api/onboard.ts @@ -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"; @@ -31,6 +35,8 @@ const onboard = async (req: NextApiRequest, res: NextApiResponse) => { } = session; const { accountId, platform } = stripeAccount; + const countryData = getFakeAddressByCountry(country); + const { businessName, skipOnboarding, @@ -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", @@ -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(), diff --git a/_base/src/utils/demo-helpers.ts b/_base/src/utils/demo-helpers.ts index 17ab8ea4..7dfcd5fb 100644 --- a/_base/src/utils/demo-helpers.ts +++ b/_base/src/utils/demo-helpers.ts @@ -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 @@ -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(), @@ -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(),