diff --git a/packages/trpc/server/organisation-router/update-organisation.ts b/packages/trpc/server/organisation-router/update-organisation.ts index bc71b9de0..73f2445c8 100644 --- a/packages/trpc/server/organisation-router/update-organisation.ts +++ b/packages/trpc/server/organisation-router/update-organisation.ts @@ -1,5 +1,6 @@ import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations'; import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error'; +import { stripe } from '@documenso/lib/server-only/stripe'; import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations'; import { prisma } from '@documenso/prisma'; @@ -38,7 +39,7 @@ export const updateOrganisationRoute = authenticatedProcedure }); } - await prisma.organisation.update({ + const updatedOrganisation = await prisma.organisation.update({ where: { id: organisationId, }, @@ -47,4 +48,12 @@ export const updateOrganisationRoute = authenticatedProcedure url: data.url, }, }); + + if (updatedOrganisation.customerId) { + await stripe.customers.update(updatedOrganisation.customerId, { + metadata: { + organisationName: data.name, + }, + }); + } });