Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/app/(ee)/api/cron/payouts/create-payout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const createPayout = async ({
status: true,
program: {
select: {
name: true,
holdingPeriodDays: true,
},
},
Expand Down Expand Up @@ -153,7 +154,7 @@ export const createPayout = async ({
partnerId,
periodStart,
periodEnd,
description: "Dub Partners payout",
description: `Dub Partners payout (${programEnrollment.program.name})`,
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function splitPayouts({
cutoffPeriod,
excludedPayoutIds,
}: {
program: Pick<Program, "id" | "minPayoutAmount">;
program: Pick<Program, "id" | "name" | "minPayoutAmount">;
cutoffPeriod: CUTOFF_PERIOD_TYPES;
excludedPayoutIds?: string[];
}) {
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function splitPayouts({
(total, commission) => total + commission.earnings,
0,
),
description: "Dub Partners payout",
description: `Dub Partners payout (${program.name})`,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stripe } from "@/lib/stripe";
import { sendEmail } from "@dub/email";
import PartnerPayoutWithdrawalInitiated from "@dub/email/templates/partner-payout-withdrawal-initiated";
import { prisma } from "@dub/prisma";
import { currencyFormatter } from "@dub/utils";
import { currencyFormatter, formatDate } from "@dub/utils";
import Stripe from "stripe";

export async function balanceAvailable(event: Stripe.Event) {
Expand Down Expand Up @@ -84,7 +84,8 @@ export async function balanceAvailable(event: Stripe.Event) {
{
amount: availableBalance,
currency,
description: "Dub Partners payout",
// example: "Dub Partners auto-withdrawal (Aug 1, 2025)"
description: `Dub Partners auto-withdrawal (${formatDate(new Date(), { month: "short" })})`,
method: "standard",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export const updatePartnerPayoutSettingsAction = authPartnerActionClient
status: "processed",
stripeTransferId: null,
},
include: {
program: {
select: {
name: true,
},
},
},
});

if (previouslyProcessedPayouts.length > 0) {
Expand Down
12 changes: 9 additions & 3 deletions apps/web/lib/partners/create-stripe-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ import {
MIN_WITHDRAWAL_AMOUNT_CENTS,
} from "./constants";

type PayoutWithProgramName = Pick<Payout, "id" | "amount" | "invoiceId"> & {
program: {
name: string;
};
};

export const createStripeTransfer = async ({
partner,
previouslyProcessedPayouts,
currentInvoicePayouts,
}: {
partner: Pick<Partner, "id" | "minWithdrawalAmount" | "stripeConnectId">;
previouslyProcessedPayouts: Pick<Payout, "id" | "amount" | "invoiceId">[];
currentInvoicePayouts?: Pick<Payout, "id" | "amount" | "invoiceId">[];
previouslyProcessedPayouts: PayoutWithProgramName[];
currentInvoicePayouts?: PayoutWithProgramName[];
}) => {
// this should never happen since we guard for it outside, but just in case
if (!partner.stripeConnectId) {
Expand Down Expand Up @@ -92,7 +98,7 @@ export const createStripeTransfer = async ({
// (even though the transfer could technically include payouts from multiple invoices)
transfer_group: finalPayoutInvoiceId!,
destination: partner.stripeConnectId,
description: `Dub Partners payout for ${allPayouts.map((p) => p.id).join(", ")}`,
description: `Dub Partners payout ${pluralize("transfer", allPayouts.length)} (${allPayouts.map((p) => p.program.name).join(", ")})`,
},
{
idempotencyKey: `${finalPayoutInvoiceId}-${partner.id}`,
Expand Down