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.

add payoutMethod distinction to PartnerPayoutConfirmed email

Steven Teyc2b7d0ff9e89
diff --git a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts
index 189b4551dc..51614c9961 100644
--- a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts
@@ -138,6 +138,7 @@ export async function queueExternalPayouts(
endDate: payout.periodEnd,
mode: "external",
paymentMethod: invoice.paymentMethod ?? "ach",
+ payoutMethod: payout.partner.paypalEmail ? "paypal" : "stripe",
},
},
})),
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts b/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
index 4091407443..5753d59d24 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
@@ -21,24 +21,18 @@ const BATCH_SIZE = 100;
// POST /api/cron/payouts/process/updates
// Recursive cron job to handle side effects of the `cron/payouts/process` job (recordAuditLog, sendBatchEmails)
export async function POST(req: Request) {
- const startTime = performance.now();
- const timings: Record<string, number> = {};
-
try {
const rawBody = await req.text();
- const t0 = performance.now();
await verifyQstashSignature({
req,
rawBody,
});
- timings.qstashVerification = performance.now() - t0;
const { invoiceId, startingAfter } = payloadSchema.parse(
JSON.parse(rawBody),
);
- const t1 = performance.now();
const payouts = await prisma.payout.findMany({
where: {
invoiceId,
@@ -59,7 +53,6 @@ export async function POST(req: Request) {
id: "asc",
},
});
- timings.prismaQuery = performance.now() - t1;
if (payouts.length === 0) {
return logAndRespond(
@@ -67,7 +60,6 @@ export async function POST(req: Request) {
);
}
- const t2 = performance.now();
const auditLogResponse = await recordAuditLog(
payouts.map((p) => {
const { program, partner, invoice, ...payout } = p;
@@ -89,7 +81,6 @@ export async function POST(req: Request) {
};
}),
);
- timings.auditLog = performance.now() - t2;
console.log(JSON.stringify({ auditLogResponse }, null, 2));
const invoice = payouts[0].invoice;
@@ -101,7 +92,6 @@ export async function POST(req: Request) {
invoice.paymentMethod !== "card" &&
internalPayouts.length > 0
) {
- const t3 = performance.now();
const batchEmailResponse = await sendBatchEmail(
internalPayouts.map((payout) => ({
to: payout.partner.email!,
@@ -123,32 +113,14 @@ export async function POST(req: Request) {
endDate: payout.periodEnd,
mode: payout.mode,
paymentMethod: invoice.paymentMethod ?? "ach",
+ payoutMethod: payout.partner.paypalEmail ? "paypal" : "stripe",
},
}),
})),
);
- timings.resendBatchApi = performance.now() - t3;
console.log(JSON.stringify({ batchEmailResponse }, null, 2));
}
- console.log(
- JSON.stringify(
- {
- timings: {
- totalMs: Math.round((performance.now() - startTime) * 100) / 100,
- qstashVerificationMs:
- Math.round(timings.qstashVerification * 100) / 100,
- auditLogMs: Math.round(timings.auditLog * 100) / 100,
- resendBatchApiMs: timings.resendBatchApi
- ? Math.round(timings.resendBatchApi * 100) / 100
- : null,
- },
- },
- null,
- 2,
- ),
- );
-
if (payouts.length === BATCH_SIZE) {
const nextStartingAfter = payouts[payouts.length - 1].id;
diff --git a/packages/email/src/templates/partner-payout-confirmed.tsx b/packages/email/src/templates/partner-payout-confirmed.tsx
index c5d6dac8e3..7df774c323 100644
--- a/packages/email/src/templates/partner-payout-confirmed.tsx
+++ b/packages/email/src/templates/partner-payout-confirmed.tsx
@@ -29,8 +29,9 @@ export default function PartnerPayoutConfirmed({
initiatedAt: new Date("2024-11-22"),
startDate: new Date("2024-11-01"),
endDate: new Date("2024-11-30"),
- paymentMethod: "ach",
mode: "internal",
+ paymentMethod: "ach",
+ payoutMethod: "stripe",
},
}: {
email: string;
@@ -45,8 +46,9 @@ export default function PartnerPayoutConfirmed({
initiatedAt: Date | null;
startDate?: Date | null;
endDate?: Date | null;
- paymentMethod: string;
mode: "internal" | "external" | null;
+ paymentMethod: string;
+ payoutMethod: "stripe" | "paypal";
};
}) {
const payoutAmountInDollars = currencyFormatter(payout.amount);
@@ -117,7 +119,11 @@ export default function PartnerPayoutConfirmed({
The payout is currently being processed and is expected to be
transferred to your{" "}
<strong className="text-black">
- {payout.mode === "external" ? program.name : "Stripe Express"}
+ {payout.mode === "external"
+ ? program.name
+ : payout.payoutMethod === "paypal"
+ ? "PayPal"
+ : "Stripe Express"}
</strong>{" "}
account in{" "}
<strong className="text-black">{etaDays} business days</strong>{" "}