Skip to content

Commit

Permalink
🛂 (billing) Display branding when subscription…
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jun 23, 2023
1 parent c94cd1e commit de0b105
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion apps/builder/src/pages/api/stripe/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import prisma from '@/lib/prisma'
import { Plan } from '@typebot.io/prisma'
import { RequestHandler } from 'next/dist/server/next'
import { sendTelemetryEvents } from '@typebot.io/lib/telemetry/sendTelemetryEvent'
import { Typebot } from '@typebot.io/schemas'

if (!process.env.STRIPE_SECRET_KEY || !process.env.STRIPE_WEBHOOK_SECRET)
throw new Error('STRIPE_SECRET_KEY or STRIPE_WEBHOOK_SECRET missing')
Expand Down Expand Up @@ -126,7 +127,7 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
}
case 'customer.subscription.deleted': {
const subscription = event.data.object as Stripe.Subscription
await prisma.workspace.update({
const workspace = await prisma.workspace.update({
where: {
stripeId: subscription.customer as string,
},
Expand All @@ -139,6 +140,27 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
customSeatsLimit: null,
},
})
const typebots = (await prisma.typebot.findMany({
where: {
workspaceId: workspace.id,
isArchived: { not: true },
},
})) as Typebot[]
for (const typebot of typebots) {
if (typebot.settings.general.isBrandingEnabled) continue
await prisma.typebot.updateMany({
where: { id: typebot.id },
data: {
settings: {
...typebot.settings,
general: {
...typebot.settings.general,
isBrandingEnabled: true,
},
},
},
})
}
return res.send({ message: 'workspace downgraded in DB' })
}
default: {
Expand Down

4 comments on commit de0b105

@vercel
Copy link

@vercel vercel bot commented on de0b105 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs.typebot.io
docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on de0b105 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

chatbot.ownacademy.co
chats.maisefetivo.com
criar.somaperuzzo.com
homerun.wpwakanda.com
prenota.aldoemaria.it
revistasaudeemdia.com
sbutton.wpwakanda.com
talk.convobuilder.com
test.leadbooster.help
whats.laracardoso.com
zillabot.saaszilla.co
815639944.21000000.one
83720273.bouclidom.com
aplicacao.bmind.com.br
bbutton.wpwwakanda.com
healthandsafetycourses.uk
sellmyharleylouisiana.com
testbot.sharemyreview.net
typebot-viewer.vercel.app
verfica.botmachine.com.br
ap-help.algorithmpress.com
ap-main.algorithmpress.com
asking.aschenputtel.agency
bcorporate.carlosbusch.com
bot.adventureconsulting.hu
bot2.fusionstarreviews.com
casestudyemb.wpwakanda.com
chat.atlasoutfittersk9.com
configurator.bouclidom.com
demo.virtuesocialmedia.com
gabinete.baleia.formulario
help.atlasoutfittersk9.com
herbalife.barrettamario.it
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
newsletter.itshcormeos.com
prenotazione.aldoemaria.it
protocolosecabarriga.store
rsvp.virtuesocialmedia.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
baleia.eventos.progenbr.com
bot.desafioserrabarriga.fit
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
chat.semanalimpanome.com.br
designguide.techyscouts.com
liveconvert2.kandalearn.com
poll.mosaicohairboutique.it
presente.empresarias.com.mx
register.algorithmpress.com
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
open.campus.aalen.university
piazzatorre.barrettamario.it
poll.mosaicohairboutique.com
type.cookieacademyonline.com
upload.atlasoutfittersk9.com
bot.brigadeirosemdrama.com.br
tuttirecepcao.fratucci.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
recepcao.tutti.fratucci.com.br
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
baleia.testeeventos.progenbr.com
bot.cabin-rentals-of-georgia.net
chat.portaloficialautorizado.com
open.campus.bot.aalen.university
sondaggio.mosaicohairboutique.it
baleia.testegabinete.progenbr.com
chat.alfabetizacaobilingue.com.br
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
sondaggio.mosaicohairboutique.com
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
chrome-os-inquiry-system.itschromeos.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com

@vercel
Copy link

@vercel vercel bot commented on de0b105 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on de0b105 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.