feat: allow custom SMS templates for free users (#21469)
* charge free users for SMS to CA an US * allow custom template for free users * fix backend + some UI fixes * make text editable * rename back to needsTeamsUpgrade * add twilio webhook handler tests --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
1 parent
357c82129c
commit
8c8ae127fe
4 files changed
+193
-24
No files matched your search
@@ -76,7 +76,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const creditService = new CreditService();
|
||||
|
||||
if (countryCode === "US" || countryCode === "CA") {
|
||||
// SMS to US and CA are free
|
||||
// SMS to US and CA are free for teams
|
||||
let teamIdToCharge = parsedTeamId;
|
||||
|
||||
if (!teamIdToCharge && parsedUserId) {
|
||||
@@ -92,15 +92,16 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
teamIdToCharge = teamMembership?.teamId;
|
||||
}
|
||||
|
||||
await creditService.chargeCredits({
|
||||
teamId: teamIdToCharge,
|
||||
userId: !teamIdToCharge ? parsedUserId : undefined,
|
||||
bookingUid: parsedBookingUid,
|
||||
smsSid,
|
||||
credits: 0,
|
||||
});
|
||||
if (teamIdToCharge) {
|
||||
await creditService.chargeCredits({
|
||||
teamId: teamIdToCharge,
|
||||
bookingUid: parsedBookingUid,
|
||||
smsSid,
|
||||
credits: 0,
|
||||
});
|
||||
|
||||
return res.status(200).send(`SMS to US and CA are free. Credits set to 0`);
|
||||
return res.status(200).send(`SMS to US and CA are free for teams. Credits set to 0`);
|
||||
}
|
||||
}
|
||||
|
||||
let orgId;
|
||||
|
||||
Reference in new issue
Block a user