Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

use group name in discount name

Steven Teyf5083cf51c69
diff --git a/apps/web/lib/actions/partners/create-discount.ts b/apps/web/lib/actions/partners/create-discount.ts
index 7dacfd7181..d32e65bd28 100644
--- a/apps/web/lib/actions/partners/create-discount.ts
+++ b/apps/web/lib/actions/partners/create-discount.ts
@@ -8,7 +8,7 @@ import { qstash } from "@/lib/cron";
import { createStripeCoupon } from "@/lib/stripe/create-stripe-coupon";
import { createDiscountSchema } from "@/lib/zod/schemas/discount";
import { prisma } from "@dub/prisma";
-import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
+import { APP_DOMAIN_WITH_NGROK, truncate } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { authActionClient } from "../safe-action";
@@ -49,6 +49,7 @@ export const createDiscountAction = authActionClient
stripeConnectId: workspace.stripeConnectId,
},
discount: {
+ name: `Dub Discount (${truncate(group.name, 25)})`,
amount,
type,
maxDuration: maxDuration ?? null,
diff --git a/apps/web/lib/stripe/create-stripe-coupon.ts b/apps/web/lib/stripe/create-stripe-coupon.ts
index ab7b887793..7f31edabe9 100644
--- a/apps/web/lib/stripe/create-stripe-coupon.ts
+++ b/apps/web/lib/stripe/create-stripe-coupon.ts
@@ -12,7 +12,9 @@ export async function createStripeCoupon({
discount,
}: {
workspace: Pick<WorkspaceProps, "id" | "stripeConnectId">;
- discount: Pick<Discount, "amount" | "type" | "maxDuration">;
+ discount: Pick<Discount, "amount" | "type" | "maxDuration"> & {
+ name: string;
+ };
}) {
if (!workspace.stripeConnectId) {
console.error(
@@ -47,6 +49,7 @@ export async function createStripeCoupon({
...(discount.type === "percentage"
? { percent_off: discount.amount }
: { amount_off: discount.amount }),
+ ...(discount.name && { name: discount.name }),
},
{
stripeAccount: workspace.stripeConnectId,