Skip to content

Commit

Permalink
ZD6038173 Make URL lowercase when sending to Stripe (#1876)
Browse files Browse the repository at this point in the history
- Stripe doesn't allow upper case (HTTPS://)in URLs. So change the scheme & host to lowercase before sending it to Stripe
  • Loading branch information
kbottla authored Feb 13, 2025
1 parent 381ff10 commit 7f7b2e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/web/modules/stripe/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ interface TOSAcceptance {
agreement_time: string | number
}

function normalizeUrl(urlString: string): string {
const url = new URL(urlString)

url.protocol = url.protocol.toLowerCase()
url.host = url.host.toLowerCase()

return url.toString()
}


export async function setupProductionStripeAccount(serviceExternalId: string, stripeAccountDetails: AccountDetails, tosAcceptance: TOSAcceptance): Promise<Stripe.Account> {
if (!STRIPE_ACCOUNT_API_KEY) {
throw new CustomValidationError('Stripe API Key was not configured for this Toolbox instance')
Expand Down Expand Up @@ -50,7 +60,7 @@ export async function setupProductionStripeAccount(serviceExternalId: string, st
},
business_profile: {
mcc: 9399,
url: service.merchant_details.url,
url: normalizeUrl(service.merchant_details.url),
product_description: `Payments for public sector services for organisation ${service.merchant_details.name}`
},
capabilities: {
Expand Down

0 comments on commit 7f7b2e4

Please sign in to comment.