The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update to use direct_debit
Kiran Kc3a6af324673
diff --git a/apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.tsindex 80caf8e342..a3f202c48a 100644--- a/apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts+++ b/apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts@@ -1,9 +1,13 @@import { createId } from "@/lib/api/create-id";-import { PAYMENT_METHOD_TYPES, PAYOUT_FEES } from "@/lib/partners/constants";+import {+ DIRECT_DEBIT_PAYMENT_METHOD_TYPES,+ PAYMENT_METHOD_TYPES,+} from "@/lib/partners/constants";import {CUTOFF_PERIOD,CUTOFF_PERIOD_TYPES,} from "@/lib/partners/cutoff-period";+import { calculatePayoutFee } from "@/lib/payment-methods";import { stripe } from "@/lib/stripe";import { sendEmail } from "@dub/email";import PartnerPayoutConfirmed from "@dub/email/templates/partner-payout-confirmed";@@ -80,9 +84,10 @@ export async function confirmPayouts({const fee =amount *- PAYOUT_FEES[workspace.plan?.split(" ")[0] ?? "business"][- paymentMethod.type === "us_bank_account" ? "ach" : "card"- ];+ calculatePayoutFee({+ paymentMethod: paymentMethod.type,+ plan: workspace.plan,+ });const total = amount + fee;@@ -142,9 +147,12 @@ export async function confirmPayouts({waitUntil((async () => {- // Send emails to all the partners involved in the payouts if the payout method is ACH- // ACH takes 4 business days to process- if (newInvoice && paymentMethod.type === "us_bank_account") {+ // Send emails to all the partners involved in the payouts if the payout method is Direct Debit+ // Direct Debit takes 4 business days to process+ if (+ newInvoice &&+ DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(paymentMethod.type)+ ) {await Promise.all(payouts.filter((payout) => payout.partner.email)diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsxindex 7aa340aeaa..710ec07e37 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx@@ -59,7 +59,9 @@ export default function PlanUsage() {status: "approved",});- const payoutFees = plan ? PAYOUT_FEES[plan.toLowerCase()]?.ach : null;+ const payoutFees = plan+ ? PAYOUT_FEES[plan.toLowerCase()]?.direct_debit+ : null;const { data: tags } = useTagsCount();const { users } = useUsers();diff --git a/apps/web/lib/partners/constants.ts b/apps/web/lib/partners/constants.tsindex 9eba8ad6a6..ae0d051b5f 100644--- a/apps/web/lib/partners/constants.ts+++ b/apps/web/lib/partners/constants.ts@@ -6,18 +6,18 @@ export const CUSTOMER_PAGE_EVENTS_LIMIT = 8;export const PAYOUT_FEES = {business: {- ach: 0.07,+ direct_debit: 0.07,card: 0.1,},advanced: {- ach: 0.05,+ direct_debit: 0.05,card: 0.08,},enterprise: {- ach: 0.03,+ direct_debit: 0.03,card: 0.06,},-};+} as const;export const DUB_MIN_PAYOUT_AMOUNT_CENTS = 10000;diff --git a/apps/web/lib/payment-methods.ts b/apps/web/lib/payment-methods.tsindex cdb307aed0..d8fff13667 100644--- a/apps/web/lib/payment-methods.ts+++ b/apps/web/lib/payment-methods.ts@@ -4,10 +4,13 @@ import {PAYOUT_FEES,} from "./partners/constants";-export const calculatePayoutFee = (- paymentMethod: Stripe.PaymentMethod.Type,- plan: string | undefined,-) => {+export const calculatePayoutFee = ({+ paymentMethod,+ plan,+}: {+ paymentMethod: Stripe.PaymentMethod.Type;+ plan: string | undefined;+}) => {if (!paymentMethod) {return null;}@@ -19,6 +22,6 @@ export const calculatePayoutFee = (}if (DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(paymentMethod)) {- return PAYOUT_FEES[planType].ach;+ return PAYOUT_FEES[planType].direct_debit;}};diff --git a/apps/web/ui/partners/payout-invoice-sheet.tsx b/apps/web/ui/partners/payout-invoice-sheet.tsxindex e891bbe4cb..35d9aae845 100644--- a/apps/web/ui/partners/payout-invoice-sheet.tsx+++ b/apps/web/ui/partners/payout-invoice-sheet.tsx@@ -125,7 +125,10 @@ function PayoutInvoiceSheetContent() {const base = {...paymentMethod,id: pm.id,- fee: calculatePayoutFee(pm.type, plan),+ fee: calculatePayoutFee({+ paymentMethod: pm.type,+ plan,+ }),};if (pm.link) {