mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
feat: sync organization name with stripe (#1974)
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
|
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
|
||||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
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 { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ export const updateOrganisationRoute = authenticatedProcedure
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.organisation.update({
|
const updatedOrganisation = await prisma.organisation.update({
|
||||||
where: {
|
where: {
|
||||||
id: organisationId,
|
id: organisationId,
|
||||||
},
|
},
|
||||||
@ -47,4 +48,12 @@ export const updateOrganisationRoute = authenticatedProcedure
|
|||||||
url: data.url,
|
url: data.url,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (updatedOrganisation.customerId) {
|
||||||
|
await stripe.customers.update(updatedOrganisation.customerId, {
|
||||||
|
metadata: {
|
||||||
|
organisationName: data.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user