The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add dynamic Fast ACH fee handling for partner payouts
Kiran Kfa017e792da2
diff --git a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsxindex df26790db2..e49a9a316a 100644--- a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx+++ b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx@@ -1,3 +1,4 @@+import { FAST_ACH_FEE_CENTS } from "@/lib/partners/constants";import { stripe } from "@/lib/stripe";import { prisma } from "@dub/prisma";import {@@ -146,8 +147,8 @@ export async function PartnerPayoutInvoice({...(invoice.paymentMethod === "ach_fast"? [{- label: "Fast ACH fees",- value: "$25.00",+ label: "Fast ACH fee",+ value: currencyFormatter(FAST_ACH_FEE_CENTS / 100),},]: []),diff --git a/apps/web/lib/cron/verify-vercel.ts b/apps/web/lib/cron/verify-vercel.tsindex e5417837b5..d74d7bd9f5 100644--- a/apps/web/lib/cron/verify-vercel.ts+++ b/apps/web/lib/cron/verify-vercel.ts@@ -2,9 +2,10 @@ 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");if (diff --git a/apps/web/lib/partners/constants.ts b/apps/web/lib/partners/constants.tsindex 78403d115b..a6f752894d 100644--- a/apps/web/lib/partners/constants.ts+++ b/apps/web/lib/partners/constants.ts@@ -9,6 +9,7 @@ export const PAYOUT_FAILURE_FEE_CENTS = 1000; // 10 USDexport const FOREX_MARKUP_RATE = 0.005; // 0.5%export const MIN_WITHDRAWAL_AMOUNT_CENTS = 10000; // $100export const BELOW_MIN_WITHDRAWAL_FEE_CENTS = 200; // $2+export const FAST_ACH_FEE_CENTS = 2500; // $25export const ALLOWED_MIN_WITHDRAWAL_AMOUNTS = [1000, 2500, 5000, 7500, 10000];export const ALLOWED_MIN_PAYOUT_AMOUNTS = [0, 2000, 5000, 10000];diff --git a/apps/web/ui/partners/payout-invoice-sheet.tsx b/apps/web/ui/partners/payout-invoice-sheet.tsxindex 9e72e21872..1238582a59 100644--- a/apps/web/ui/partners/payout-invoice-sheet.tsx+++ b/apps/web/ui/partners/payout-invoice-sheet.tsx@@ -1,7 +1,10 @@import { confirmPayoutsAction } from "@/lib/actions/partners/confirm-payouts";import { exceededLimitError } from "@/lib/api/errors";import { clientAccessCheck } from "@/lib/api/tokens/permissions";-import { DIRECT_DEBIT_PAYMENT_METHOD_TYPES } from "@/lib/partners/constants";+import {+ DIRECT_DEBIT_PAYMENT_METHOD_TYPES,+ FAST_ACH_FEE_CENTS,+} from "@/lib/partners/constants";import {CUTOFF_PERIOD,CUTOFF_PERIOD_TYPES,@@ -171,7 +174,9 @@ function PayoutInvoiceSheetContent() {value: method.id,label: method.title,icon: method.icon,- ...(method.fastSettlement && { meta: "+$25" }),+ ...(method.fastSettlement && {+ meta: `+ ${currencyFormatter(FAST_ACH_FEE_CENTS / 100)}`,+ }),}));}, [finalPaymentMethods]);@@ -214,14 +219,25 @@ function PayoutInvoiceSheetContent() {return acc + payout.amount;}, 0);- const fee =- amount === undefined- ? undefined- : amount * (selectedPaymentMethod?.fee ?? 0);- const total =- amount !== undefined && fee !== undefined ? amount + fee : undefined;+ if (amount === undefined || selectedPaymentMethod === null) {+ return {+ amount: undefined,+ fee: undefined,+ total: undefined,+ };+ }- return { amount, fee, total };+ const fee = amount * selectedPaymentMethod.fee;+ const fastAchFee = selectedPaymentMethod.fastSettlement+ ? FAST_ACH_FEE_CENTS+ : 0;+ const total = amount + fee + fastAchFee;++ return {+ amount,+ fee,+ total,+ };}, [includedPayouts, selectedPaymentMethod]);const invoiceData = useMemo(() => {@@ -335,7 +351,7 @@ function PayoutInvoiceSheetContent() {),},{- key: "Fee",+ key: "Platform Fee",value:selectedPaymentMethod && fee !== undefined ? (currencyFormatter(fee / 100)@@ -350,6 +366,16 @@ function PayoutInvoiceSheetContent() {/>) : undefined,},++ ...(selectedPaymentMethod?.fastSettlement+ ? [+ {+ key: "Fast ACH Fee",+ value: currencyFormatter(FAST_ACH_FEE_CENTS / 100),+ },+ ]+ : []),+{key: "Transfer Time",value: selectedPaymentMethod ? (@@ -522,7 +548,7 @@ function PayoutInvoiceSheetContent() {<FastAchPayoutToggle /></div>- <div className="p-6">+ <div className="px-6 py-3"><Table {...table} /></div></div>