2
0

🐛 (billing) Set invoicing behavior to "always invoice" to fix double payment issue

This commit is contained in:
Baptiste Arnaud
2023-11-14 16:00:10 +01:00
parent 6c0f28b3e4
commit a1d7415227
4 changed files with 73 additions and 2 deletions

View File

@@ -76,6 +76,7 @@ export const checkAndReportChatsUsage = async () => {
})
const quarantineEvents: TelemetryEvent[] = []
const autoUpgradeEvents: TelemetryEvent[] = []
for (const workspace of workspaces) {
if (workspace.isQuarantined) continue
@@ -136,6 +137,21 @@ export const checkAndReportChatsUsage = async () => {
stripe,
workspaceId: workspace.id,
})
autoUpgradeEvents.push(
...workspace.members
.filter((member) => member.role === WorkspaceRole.ADMIN)
.map(
(member) =>
({
name: 'Subscription automatically updated',
userId: member.user.id,
workspaceId: workspace.id,
data: {
plan: 'PRO',
},
} satisfies TelemetryEvent)
)
)
await reportUsageToStripe(totalChatsUsed, {
stripe,
subscription: newSubscription,