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.

finalize enums / types

Steven Teya17710d1cea2
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
index e0ff4d37e8..ca8e3751cf 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
@@ -9,9 +9,9 @@ import {
CUTOFF_PERIOD,
CUTOFF_PERIOD_TYPES,
} from "@/lib/partners/cutoff-period";
-import { calculatePayoutFeeForMethod } from "@/lib/payment-methods";
import { stripe } from "@/lib/stripe";
import { createFxQuote } from "@/lib/stripe/create-fx-quote";
+import { calculatePayoutFeeForMethod } from "@/lib/stripe/payment-methods";
import { PlanProps } from "@/lib/types";
import { sendBatchEmail } from "@dub/email";
import { resend } from "@dub/email/resend";
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
index c6a2161a6d..db70327659 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
@@ -1,6 +1,6 @@
"use client";
-import { PAYMENT_METHODS } from "@/lib/payment-methods";
+import { INVOICE_PAYMENT_METHODS } from "@/lib/partners/constants";
import useWorkspace from "@/lib/swr/use-workspace";
import { InvoiceProps } from "@/lib/types";
import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
@@ -108,11 +108,11 @@ const InvoiceCard = ({
invoice: InvoiceProps;
displayPaymentMethod: boolean;
}) => {
- const paymentMethod =
- PAYMENT_METHODS[invoice.paymentMethod ?? "us_bank_account"];
+ const invoicePaymentMethod =
+ INVOICE_PAYMENT_METHODS[invoice.invoicePaymentMethod ?? "ach"];
return (
- <div className="px-4 py-6 sm:px-12">
+ <div className="px-3 py-4 sm:px-12">
{/* Mobile layout */}
<div className="block sm:hidden">
<div className="mb-4 flex items-start justify-between">
@@ -179,17 +179,17 @@ const InvoiceCard = ({
{displayPaymentMethod && (
<div className="text-left text-sm">
<div className="font-medium">Method</div>
- {paymentMethod ? (
+ {invoicePaymentMethod ? (
<div className="flex items-center gap-1.5 text-neutral-500">
<div className="text-content-subtle text-sm font-medium">
- {paymentMethod.label}
+ {invoicePaymentMethod.label}
</div>
<StatusBadge
icon={null}
variant="neutral"
className="rounded-md py-0.5 text-xs font-semibold text-neutral-700"
>
- {paymentMethod.duration}
+ {invoicePaymentMethod.duration}
</StatusBadge>
</div>
) : (
@@ -238,17 +238,17 @@ const InvoiceCard = ({
{displayPaymentMethod && (
<div className="text-left text-sm sm:col-span-1 lg:block">
<div className="font-medium">Method</div>
- {paymentMethod ? (
+ {invoicePaymentMethod ? (
<div className="flex items-center gap-1.5 text-neutral-500">
<div className="text-content-subtle text-sm font-medium">
- {paymentMethod.label}
+ {invoicePaymentMethod.label}
</div>
<StatusBadge
icon={null}
variant="neutral"
className="rounded-md py-0.5 text-xs font-semibold text-neutral-700"
>
- {paymentMethod.duration}
+ {invoicePaymentMethod.duration}
</StatusBadge>
</div>
) : (
diff --git a/apps/web/lib/cron/verify-vercel.ts b/apps/web/lib/cron/verify-vercel.ts
index d74d7bd9f5..c5bc130aeb 100644
--- a/apps/web/lib/cron/verify-vercel.ts
+++ b/apps/web/lib/cron/verify-vercel.ts
@@ -2,9 +2,9 @@ import { DubApiError } from "../api/errors";
export const verifyVercelSignature = async (req: Request) => {
// skip verification in local development
- if (process.env.VERCEL !== "1") {
- return;
- }
+ // if (process.env.VERCEL !== "1") {
+ // return;
+ // }
const authHeader = req.headers.get("authorization");
diff --git a/apps/web/lib/partners/constants.ts b/apps/web/lib/partners/constants.ts
index a6f752894d..c2e32847f3 100644
--- a/apps/web/lib/partners/constants.ts
+++ b/apps/web/lib/partners/constants.ts
@@ -67,6 +67,29 @@ export const PAYMENT_METHOD_TYPES: Stripe.PaymentMethod.Type[] = [
...DIRECT_DEBIT_PAYMENT_METHOD_TYPES,
];
+export const INVOICE_PAYMENT_METHODS = Object.freeze({
+ card: {
+ label: "Card",
+ duration: "Instantly",
+ },
+ ach: {
+ label: "ACH",
+ duration: "4 business days",
+ },
+ ach_fast: {
+ label: "Fast ACH",
+ duration: "2 business days",
+ },
+ sepa: {
+ label: "SEPA Debit",
+ duration: "5 business days",
+ },
+ acss: {
+ label: "ACSS Debit",
+ duration: "5 business days",
+ },
+});
+
export const PROGRAM_IMPORT_SOURCES = [
{
id: "rewardful",
diff --git a/apps/web/lib/payment-methods.ts b/apps/web/lib/stripe/payment-methods.ts
similarity index 83%
rename from apps/web/lib/payment-methods.ts
rename to apps/web/lib/stripe/payment-methods.ts
index 7d2a52d14f..d3354325d6 100644
--- a/apps/web/lib/payment-methods.ts
+++ b/apps/web/lib/stripe/payment-methods.ts
@@ -1,6 +1,6 @@
import { CreditCard, GreekTemple } from "@dub/ui";
import Stripe from "stripe";
-import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "./partners/constants";
+import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "../partners/constants";
export const calculatePayoutFeeForMethod = ({
paymentMethod,
@@ -24,7 +24,7 @@ export const calculatePayoutFeeForMethod = ({
throw new Error(`Unsupported payment method ${paymentMethod}.`);
};
-export const PAYMENT_METHODS = Object.freeze({
+export const STRIPE_PAYMENT_METHODS = Object.freeze({
link: {
label: "Link",
type: "link",
@@ -55,10 +55,4 @@ export const PAYMENT_METHODS = Object.freeze({
icon: GreekTemple,
duration: "5 business days",
},
- ach_fast: {
- label: "Fast ACH",
- type: "ach",
- icon: GreekTemple,
- duration: "2 business days",
- },
});
diff --git a/apps/web/ui/partners/payout-invoice-sheet.tsx b/apps/web/ui/partners/payout-invoice-sheet.tsx
index a321c368ea..6fce34697c 100644
--- a/apps/web/ui/partners/payout-invoice-sheet.tsx
+++ b/apps/web/ui/partners/payout-invoice-sheet.tsx
@@ -11,8 +11,8 @@ import {
} from "@/lib/partners/cutoff-period";
import {
calculatePayoutFeeForMethod,
- PAYMENT_METHODS,
-} from "@/lib/payment-methods";
+ STRIPE_PAYMENT_METHODS,
+} from "@/lib/stripe/payment-methods";
import usePaymentMethods from "@/lib/swr/use-payment-methods";
import useWorkspace from "@/lib/swr/use-workspace";
import { PayoutResponse, PlanProps } from "@/lib/types";
@@ -52,7 +52,7 @@ import Stripe from "stripe";
import useSWR from "swr";
type SelectPaymentMethod =
- (typeof PAYMENT_METHODS)[keyof typeof PAYMENT_METHODS] & {
+ (typeof STRIPE_PAYMENT_METHODS)[keyof typeof STRIPE_PAYMENT_METHODS] & {
id: string;
fee: number;
fastSettlement: boolean;
@@ -113,7 +113,7 @@ function PayoutInvoiceSheetContent() {
if (!paymentMethods) return undefined;
const methods = paymentMethods.flatMap((pm) => {
- const paymentMethod = PAYMENT_METHODS[pm.type];
+ const paymentMethod = STRIPE_PAYMENT_METHODS[pm.type];
const base = {
...paymentMethod,
@@ -128,7 +128,7 @@ function PayoutInvoiceSheetContent() {
if (pm.link) {
return {
...base,
- title: `Link – ${truncate(pm.link.email, 16)}`,
+ title: `Link – ${truncate(pm.link.email, 24)}`,
};
}
@@ -639,14 +639,14 @@ function FastAchPayoutToggle() {
{!fastDirectDebitPayouts && (
<div className="flex items-center gap-0.5">
- <Button
- variant="secondary"
- text="Contact sales to enable"
- className="border-border-subtle h-7 w-fit whitespace-nowrap rounded-lg bg-white px-2.5 py-2 text-sm"
- onClick={() => {
- window.open("https://dub.co/enterprise", "_blank");
- }}
- />
+ <a href="https://dub.co/contact/sales" target="_blank">
+ <Button
+ variant="secondary"
+ text="Contact sales to enable"
+ className="border-border-subtle h-7 w-fit whitespace-nowrap rounded-lg bg-white px-2.5 py-2 text-sm"
+ />
+ </a>
+
<button
onClick={() => setIsVisible(false)}
className="text-content-emphasis p-1"
diff --git a/packages/email/src/templates/partner-payout-confirmed.tsx b/packages/email/src/templates/partner-payout-confirmed.tsx
index 35621bd11f..6bf9201e67 100644
--- a/packages/email/src/templates/partner-payout-confirmed.tsx
+++ b/packages/email/src/templates/partner-payout-confirmed.tsx
@@ -13,7 +13,6 @@ import {
Text,
} from "@react-email/components";
import { Footer } from "../components/footer";
-import { PaymentMethod } from "../types";
// Send this email when the payout is confirmed when payment is send using ACH
export default function PartnerPayoutConfirmed({
@@ -42,7 +41,7 @@ export default function PartnerPayoutConfirmed({
amount: number;
startDate?: Date | null;
endDate?: Date | null;
- paymentMethod: PaymentMethod;
+ paymentMethod: string;
};
}) {
const saleAmountInDollars = currencyFormatter(payout.amount / 100);
diff --git a/packages/email/src/types.ts b/packages/email/src/types.ts
index 0c17ed27d8..e9992822fd 100644
--- a/packages/email/src/types.ts
+++ b/packages/email/src/types.ts
@@ -6,5 +6,3 @@ export type WorkspaceProps = {
usageLimit: number;
plan: string;
};
-
-export type PaymentMethod = "card" | "ach" | "ach_fast" | "sepa" | "acss";