diff --git a/docs/swagger.json b/docs/swagger.json index 56db9edef3..1786780062 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -12032,6 +12032,11 @@ "properties": { "coupon": { "properties": { + "amount_off": { + "type": "number", + "format": "double", + "nullable": true + }, "percent_off": { "type": "number", "format": "double", @@ -12043,6 +12048,7 @@ } }, "required": [ + "amount_off", "percent_off", "name" ], diff --git a/helicone-node/api/generatedTypes/public.ts b/helicone-node/api/generatedTypes/public.ts index 22c19d42a4..30a18e67e5 100644 --- a/helicone-node/api/generatedTypes/public.ts +++ b/helicone-node/api/generatedTypes/public.ts @@ -4344,6 +4344,8 @@ export interface operations { subtotal: number; discount: ({ coupon: { + /** Format: double */ + amount_off: number | null; /** Format: double */ percent_off: number | null; name: string | null; diff --git a/valhalla/jawn/src/controllers/public/stripeController.ts b/valhalla/jawn/src/controllers/public/stripeController.ts index 0a6b7a869d..969b8ca6fc 100644 --- a/valhalla/jawn/src/controllers/public/stripeController.ts +++ b/valhalla/jawn/src/controllers/public/stripeController.ts @@ -1,19 +1,17 @@ import { - Controller, - Route, - Tags, - Security, - Post, Body, - Request, - Get, + Controller, Delete, + Get, Path, + Post, + Request, + Route, + Security, + Tags, } from "tsoa"; -import Stripe from "stripe"; -import { JawnAuthenticatedRequest } from "../../types/request"; import { StripeManager } from "../../managers/stripe/StripeManager"; -import { Result } from "../../lib/shared/result"; +import { JawnAuthenticatedRequest } from "../../types/request"; export interface UpgradeToProRequest { addons?: { @@ -163,6 +161,7 @@ export class StripeController extends Controller { coupon: { name: string | null; percent_off: number | null; + amount_off: number | null; }; } | null; subtotal: number; diff --git a/valhalla/jawn/src/managers/organization/OrganizationManager.ts b/valhalla/jawn/src/managers/organization/OrganizationManager.ts index c4e37a4f44..1bf0bb951e 100644 --- a/valhalla/jawn/src/managers/organization/OrganizationManager.ts +++ b/valhalla/jawn/src/managers/organization/OrganizationManager.ts @@ -1,3 +1,4 @@ +import { ENVIRONMENT } from "../.."; import { Database } from "../../lib/db/database.types"; import { AuthParams, supabaseServer } from "../../lib/db/supabase"; import { ok, err, Result } from "../../lib/shared/result"; @@ -369,12 +370,14 @@ export class OrganizationManager extends BaseManager { if (membersError !== null) { return err(membersError); } - return ok( - members.filter( - (member) => - !filterHeliconeEmails || !member.email.endsWith("@helicone.ai") - ).length - ); + if (filterHeliconeEmails && ENVIRONMENT === "production") { + return ok( + members.filter((member) => !member.email.endsWith("@helicone.ai")) + .length + ); + } else { + return ok(members.length); + } } async getOrganizationMembers( diff --git a/valhalla/jawn/src/managers/stripe/StripeManager.ts b/valhalla/jawn/src/managers/stripe/StripeManager.ts index 7655541b54..f7c5302c59 100644 --- a/valhalla/jawn/src/managers/stripe/StripeManager.ts +++ b/valhalla/jawn/src/managers/stripe/StripeManager.ts @@ -258,14 +258,9 @@ WHERE (${builtFilter.filter})`, tier: "pro-20240913", }, }, + allow_promotion_codes: true, }; - if (this.shouldApplyCoupon()) { - sessionParams.discounts = [{ coupon: EARLY_ADOPTER_COUPON }]; - } else { - sessionParams.allow_promotion_codes = true; - } - const session = await this.stripe.checkout.sessions.create(sessionParams); return ok(session.url!); diff --git a/valhalla/jawn/src/tsoa-build/private/swagger.json b/valhalla/jawn/src/tsoa-build/private/swagger.json index 8958c0ed31..98a6f3f465 100644 --- a/valhalla/jawn/src/tsoa-build/private/swagger.json +++ b/valhalla/jawn/src/tsoa-build/private/swagger.json @@ -11468,6 +11468,11 @@ "properties": { "coupon": { "properties": { + "amount_off": { + "type": "number", + "format": "double", + "nullable": true + }, "percent_off": { "type": "number", "format": "double", @@ -11479,6 +11484,7 @@ } }, "required": [ + "amount_off", "percent_off", "name" ], diff --git a/valhalla/jawn/src/tsoa-build/public/swagger.json b/valhalla/jawn/src/tsoa-build/public/swagger.json index 56db9edef3..1786780062 100644 --- a/valhalla/jawn/src/tsoa-build/public/swagger.json +++ b/valhalla/jawn/src/tsoa-build/public/swagger.json @@ -12032,6 +12032,11 @@ "properties": { "coupon": { "properties": { + "amount_off": { + "type": "number", + "format": "double", + "nullable": true + }, "percent_off": { "type": "number", "format": "double", @@ -12043,6 +12048,7 @@ } }, "required": [ + "amount_off", "percent_off", "name" ], diff --git a/web/components/templates/organization/plan/InvoiceSheet.tsx b/web/components/templates/organization/plan/InvoiceSheet.tsx index ef19eb06e0..8e86928160 100644 --- a/web/components/templates/organization/plan/InvoiceSheet.tsx +++ b/web/components/templates/organization/plan/InvoiceSheet.tsx @@ -83,9 +83,18 @@ export const InvoiceSheet: React.FC = () => { {upcomingInvoice.data.data.discount && (

Discount:

-
- {upcomingInvoice.data.data.discount.coupon.name} - - {upcomingInvoice.data.data.discount.coupon.percent_off}% off +
+ + {upcomingInvoice.data.data.discount.coupon.name} + + + {upcomingInvoice.data.data.discount.coupon.amount_off + ? `$${ + upcomingInvoice.data.data.discount.coupon + .amount_off / 100 + } off` + : `${upcomingInvoice.data.data.discount.coupon.percent_off}% off`} +
)} diff --git a/web/lib/clients/jawnTypes/private.ts b/web/lib/clients/jawnTypes/private.ts index 318f07bc07..16935f5b4d 100644 --- a/web/lib/clients/jawnTypes/private.ts +++ b/web/lib/clients/jawnTypes/private.ts @@ -4115,6 +4115,8 @@ export interface operations { subtotal: number; discount: ({ coupon: { + /** Format: double */ + amount_off: number | null; /** Format: double */ percent_off: number | null; name: string | null; diff --git a/web/lib/clients/jawnTypes/public.ts b/web/lib/clients/jawnTypes/public.ts index 22c19d42a4..30a18e67e5 100644 --- a/web/lib/clients/jawnTypes/public.ts +++ b/web/lib/clients/jawnTypes/public.ts @@ -4344,6 +4344,8 @@ export interface operations { subtotal: number; discount: ({ coupon: { + /** Format: double */ + amount_off: number | null; /** Format: double */ percent_off: number | null; name: string | null;