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.

Enhance payout processing logic and update UI tooltips for clarity

Kiran K3f2f18b257b9
diff --git a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-stripe-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-stripe-payouts.ts
index cef8ddce75..f852f8fc36 100644
--- a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-stripe-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-stripe-payouts.ts
@@ -6,6 +6,7 @@ import { stripe } from "@/lib/stripe";
import { sendEmail } from "@dub/email";
import PartnerPayoutSent from "@dub/email/templates/partner-payout-sent";
import { prisma } from "@dub/prisma";
+import { currencyFormatter } from "@dub/utils";
import { Payload } from "./utils";
export async function sendStripePayouts({ payload }: { payload: Payload }) {
@@ -13,7 +14,10 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
const payouts = await prisma.payout.findMany({
where: {
- status: "processing",
+ status: {
+ in: ["processing", "processed"],
+ },
+ stripeTransferId: null,
partner: {
payoutsEnabledAt: {
not: null,
@@ -26,8 +30,6 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
select: {
id: true,
amount: true,
- periodStart: true,
- periodEnd: true,
partner: {
select: {
id: true,
@@ -38,7 +40,6 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
},
program: {
select: {
- id: true,
name: true,
logo: true,
},
@@ -64,8 +65,6 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
return map;
}, new Map<string, typeof payouts>());
- console.log("payoutsByPartner", payoutsByPartner);
-
// Process payouts for each partner
for (const [_, payouts] of payoutsByPartner) {
let withdrawalFee = 0;
@@ -86,6 +85,10 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
},
});
+ console.log(
+ `Payouts amount (${currencyFormatter(totalAmount / 100)}) for partner ${partner.id} are below the minWithdrawalAmount (${currencyFormatter(partner.minWithdrawalAmount / 100)})`,
+ );
+
continue;
}
@@ -109,11 +112,6 @@ export async function sendStripePayouts({ payload }: { payload: Payload }) {
transfer_group: invoiceId,
destination: partner.stripeConnectId!,
description: "You’ve been paid!",
- ...(!achCreditTransfer
- ? {
- source_transaction: chargeId,
- }
- : {}),
},
{
idempotencyKey: `${invoiceId}-${partner.id}`,
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
index 6e948b4ffa..94463870ca 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx
@@ -23,16 +23,20 @@ const tooltips = {
pending:
"Payouts that have passed the program’s holding period and are waiting to be processed.",
processing:
- "Payouts that have been processed by the program and are on their way to your Stripe Express account.",
- sent: "Payouts that have been sent to your Stripe Express account and will be automatically paid out once they reach your minimum withdrawal balance.",
+ " Payouts that are being processed by the program – this can take up to 5 business days.",
+ processed:
+ "Payouts that have been processed by the program and will be paid out to your connected bank account once they reach your minimum withdrawal balance.",
+ sent: "Payouts that are on their way to your connected bank account – this can take anywhere from 1 to 14 business days depending on your bank location.",
completed:
"Payouts that have been paid out from Stripe to your connected bank account.",
},
+
paypal: {
pending:
"Payouts that have passed the program’s holding period and are waiting to be processed.",
processing:
- "Payouts that have been processed by the program and are on their way to your PayPal account.",
+ "Payouts that have been processed by the program and are on their way to your PayPal account - this can take up to 5 business days.",
+ processed: "",
sent: "",
completed: "Payouts that have been paid out to your PayPal account",
},
@@ -169,7 +173,7 @@ export function PayoutStats() {
label: "Pending",
amount: payoutStatusMap?.pending?.amount,
icon: PayoutStatusBadges.pending.icon,
- iconClassName: "bg-orange-100 text-orange-500",
+ iconClassName: PayoutStatusBadges.pending.className,
tooltip: tooltip?.pending,
error: !!error,
showConnectButton: partner && !partner.payoutsEnabledAt,
@@ -179,7 +183,7 @@ export function PayoutStats() {
label: "Processing",
amount: payoutStatusMap?.processing?.amount,
icon: PayoutStatusBadges.processing.icon,
- iconClassName: "bg-blue-100 text-blue-500",
+ iconClassName: PayoutStatusBadges.processing.className,
tooltip: tooltip?.processing,
error: !!error,
},
@@ -187,11 +191,11 @@ export function PayoutStats() {
...(payoutMethod === "stripe"
? [
{
- label: "Sent",
- amount: payoutStatusMap?.sent?.amount,
- icon: PayoutStatusBadges.sent.icon,
- iconClassName: "bg-indigo-100 text-indigo-500",
- tooltip: tooltip?.sent,
+ label: "Processed",
+ amount: payoutStatusMap?.processed?.amount,
+ icon: PayoutStatusBadges.processed.icon,
+ iconClassName: PayoutStatusBadges.processed.className,
+ tooltip: tooltip?.processing,
error: !!error,
sublabel: () => {
if (!partner || !payoutsCount || error) {
@@ -215,6 +219,15 @@ export function PayoutStats() {
return "Est: 4 business days";
},
},
+
+ // {
+ // label: "Sent",
+ // amount: payoutStatusMap?.sent?.amount,
+ // icon: PayoutStatusBadges.sent.icon,
+ // iconClassName: PayoutStatusBadges.sent.className,
+ // tooltip: tooltip?.sent,
+ // error: !!error,
+ // },
]
: []),
@@ -222,7 +235,7 @@ export function PayoutStats() {
label: "Completed",
amount: payoutStatusMap?.completed?.amount,
icon: PayoutStatusBadges.completed.icon,
- iconClassName: "bg-green-100 text-green-500",
+ iconClassName: PayoutStatusBadges.completed.className,
tooltip: tooltip?.completed,
error: !!error,
},
@@ -234,9 +247,7 @@ export function PayoutStats() {
<div
className={cn(
"grid divide-y divide-neutral-200 overflow-hidden rounded-lg border border-neutral-200",
- payoutMethod === "stripe"
- ? "grid-cols-1 sm:grid-cols-2 sm:divide-x sm:divide-y-0 lg:grid-cols-4"
- : "grid-cols-1 sm:grid-cols-3 sm:divide-x sm:divide-y-0",
+ "grid-cols-1 sm:grid-cols-2 sm:divide-x sm:divide-y-0 lg:grid-cols-4",
)}
>
{payoutStats.map((stat) => (
diff --git a/apps/web/ui/partners/payout-status-badges.tsx b/apps/web/ui/partners/payout-status-badges.tsx
index 4c41ad3132..509cad530f 100644
--- a/apps/web/ui/partners/payout-status-badges.tsx
+++ b/apps/web/ui/partners/payout-status-badges.tsx
@@ -19,6 +19,12 @@ export const PayoutStatusBadges = {
icon: CircleHalfDottedClock,
className: "text-blue-600 bg-blue-100",
},
+ processed: {
+ label: "Processed",
+ variant: "new",
+ icon: CircleHalfDottedClock,
+ className: "text-indigo-600 bg-indigo-100",
+ },
sent: {
label: "Sent",
variant: "new",