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.

Merge branch 'main' into bank-debits

Steven Tey7269da3733cd
diff --cc apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts
index a3f202c48a,9e175ba510..5ab9cb8851
--- 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,8 -1,6 +1,9 @@@
import { createId } from "@/lib/api/create-id";
+ import { limiter } from "@/lib/cron/limiter";
-import { 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,
@@@ -13,8 -10,9 +14,7 @@@ import { sendEmail } from "@dub/email"
import PartnerPayoutConfirmed from "@dub/email/templates/partner-payout-confirmed";
import { prisma } from "@dub/prisma";
import { Program, Project } from "@prisma/client";
- import { waitUntil } from "@vercel/functions";
-const allowedPaymentMethods = ["us_bank_account", "card", "link"];
-
export async function confirmPayouts({
workspace,
program,
@@@ -145,36 -153,31 +156,34 @@@
return invoice;
});
- waitUntil(
- (async () => {
- // 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)
- .map((payout) =>
- sendEmail({
- subject: "You've got money coming your way!",
- // Send emails to all the partners involved in the payouts if the payout method is ACH
- // This is because ACH takes 4 business days to process, so we want to give partners a heads up
- if (newInvoice && paymentMethod.type === "us_bank_account") {
++ // Send emails to all the partners involved in the payouts if the payout method is Direct Debit
++ // This is because Direct Debit takes 4 business days to process, so we want to give partners a heads up
++ if (
++ newInvoice &&
++ DIRECT_DEBIT_PAYMENT_METHOD_TYPES.includes(paymentMethod.type)
++ ) {
+ await Promise.allSettled(
+ payouts
+ .filter((payout) => payout.partner.email)
+ .map((payout) =>
+ limiter.schedule(() =>
+ sendEmail({
+ subject: "You've got money coming your way!",
+ email: payout.partner.email!,
+ react: PartnerPayoutConfirmed({
email: payout.partner.email!,
- react: PartnerPayoutConfirmed({
- email: payout.partner.email!,
- program,
- payout: {
- id: payout.id,
- amount: payout.amount,
- startDate: payout.periodStart,
- endDate: payout.periodEnd,
- },
- }),
- variant: "notifications",
+ program,
+ payout: {
+ id: payout.id,
+ amount: payout.amount,
+ startDate: payout.periodStart,
+ endDate: payout.periodEnd,
+ },
}),
- ),
- );
- }
- })(),
- );
+ variant: "notifications",
+ }),
+ ),
+ ),
+ );
+ }
}
diff --cc apps/web/lib/actions/partners/confirm-payouts.ts
index 28c459bc55,871e1cedc8..69893fd39c
--- a/apps/web/lib/actions/partners/confirm-payouts.ts
+++ b/apps/web/lib/actions/partners/confirm-payouts.ts
@@@ -1,8 -1,6 +1,7 @@@
"use server";
- import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { qstash } from "@/lib/cron";
+import { PAYMENT_METHOD_TYPES } from "@/lib/partners/constants";
import { CUTOFF_PERIOD_ENUM } from "@/lib/partners/cutoff-period";
import { stripe } from "@/lib/stripe";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
diff --cc apps/web/lib/partners/constants.ts
index 5795b6a860,36aea2c043..4be33a1ffc
--- a/apps/web/lib/partners/constants.ts
+++ b/apps/web/lib/partners/constants.ts
@@@ -7,11 -4,11 +7,11 @@@ export const CUSTOMER_PAGE_EVENTS_LIMI
export const PAYOUT_FEES = {
business: {
- direct_debit: 0.07,
- ach: 0.05,
- card: 0.08,
++ direct_debit: 0.05,
+ card: 0.1,
},
advanced: {
- ach: 0.05,
+ direct_debit: 0.05,
card: 0.08,
},
enterprise: {