The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
limit SEPA to Enterprise
Steven Tey0cdafc7b26a3
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.tsindex 0e96a9c645..6943a9fd96 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts@@ -65,6 +65,13 @@ export const POST = withWorkspace(async ({ workspace, req }) => {return NextResponse.json({ url });}+ if (method === "sepa_debit" && workspace.plan !== "enterprise") {+ throw new DubApiError({+ code: "forbidden",+ message: "SEPA Debit is only available on the Enterprise plan.",+ });+ }+const paymentMethodOption = DIRECT_DEBIT_PAYMENT_TYPES_INFO.find((type) => type.type === method,)?.option;diff --git a/apps/web/lib/partners/constants.ts b/apps/web/lib/partners/constants.tsindex da5458ec43..b92d795733 100644--- a/apps/web/lib/partners/constants.ts+++ b/apps/web/lib/partners/constants.ts@@ -15,6 +15,8 @@ export const DIRECT_DEBIT_PAYMENT_TYPES_INFO: {title: string;icon: string;option: PaymentMethodOption;+ recommended?: boolean;+ enterpriseOnly?: boolean;}[] = [{type: "us_bank_account",@@ -22,6 +24,7 @@ export const DIRECT_DEBIT_PAYMENT_TYPES_INFO: {title: "ACH",icon: "https://hatscripts.github.io/circle-flags/flags/us.svg",option: {},+ recommended: true,},{type: "acss_debit",@@ -42,6 +45,7 @@ export const DIRECT_DEBIT_PAYMENT_TYPES_INFO: {title: "SEPA Debit",icon: "https://hatscripts.github.io/circle-flags/flags/eu.svg",option: {},+ enterpriseOnly: true,},];diff --git a/apps/web/ui/modals/add-payment-method-modal.tsx b/apps/web/ui/modals/add-payment-method-modal.tsxindex f353cc3ba8..9232bf53d7 100644--- a/apps/web/ui/modals/add-payment-method-modal.tsx+++ b/apps/web/ui/modals/add-payment-method-modal.tsx@@ -4,6 +4,7 @@ import { DIRECT_DEBIT_PAYMENT_TYPES_INFO } from "@/lib/partners/constants";import useWorkspace from "@/lib/swr/use-workspace";import { X } from "@/ui/shared/icons";import { AnimatedSizeContainer, GreekTemple, Modal } from "@dub/ui";+import { cn, COUNTRIES } from "@dub/utils";import { useRouter } from "next/navigation";import { CSSProperties, Dispatch, SetStateAction, useState } from "react";import { toast } from "sonner";@@ -35,7 +36,7 @@ function AddPaymentMethodModalInner({setShowAddPaymentMethodModal: Dispatch<SetStateAction<boolean>>;}) {const router = useRouter();- const { slug } = useWorkspace();+ const { slug, plan } = useWorkspace();const [isLoading, setIsLoading] = useState(false);const addPaymentMethod = async (type: Stripe.PaymentMethod.Type) => {@@ -86,7 +87,7 @@ function AddPaymentMethodModalInner({Connect your bank account</h3><p className="mt-1 text-base text-neutral-500">- Select your bank’s location to connect your bank account.+ Select your bank's location to connect your bank account.</p></div>@@ -99,14 +100,39 @@ function AddPaymentMethodModalInner({}>{DIRECT_DEBIT_PAYMENT_TYPES_INFO.map(- ({ type, location, title, icon: Icon }, index) => (+ (+ {+ type,+ location,+ title,+ icon: Icon,+ recommended,+ enterpriseOnly,+ },+ index,+ ) => (<buttonkey={index}type="button"- className="group flex flex-col items-center gap-4 rounded-lg bg-neutral-200/40 p-8 px-2 py-4 transition-colors duration-100 hover:bg-neutral-200/60"+ className="group flex flex-col items-center justify-end gap-4 rounded-lg bg-neutral-200/40 p-8 px-2 py-4 transition-colors duration-100 hover:bg-neutral-200/60 disabled:cursor-not-allowed disabled:opacity-50"onClick={() => addPaymentMethod(type)}- disabled={isLoading}+ disabled={+ isLoading || (enterpriseOnly && plan !== "enterprise")+ }>+ <span+ className={cn(+ "rounded-full bg-neutral-200 px-2 py-0.5 text-xs font-semibold text-neutral-600",+ recommended && "bg-blue-100 text-blue-700",+ enterpriseOnly && "bg-violet-100 text-violet-700",+ )}+ >+ {recommended+ ? "Recommended"+ : enterpriseOnly+ ? "Enterprise only"+ : `${COUNTRIES[location]} only`}+ </span><imgsrc={Icon}alt={location}