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.

Keep payouts disabled for partners banned from the network

Rafi3e3f229cf221
diff --git a/apps/web/app/(ee)/api/embed/referrals/tremendous/verify-otp/route.ts b/apps/web/app/(ee)/api/embed/referrals/tremendous/verify-otp/route.ts
index b07f3c2e35..fd9aadbae0 100644
--- a/apps/web/app/(ee)/api/embed/referrals/tremendous/verify-otp/route.ts
+++ b/apps/web/app/(ee)/api/embed/referrals/tremendous/verify-otp/route.ts
@@ -76,9 +76,18 @@ export const POST = withReferralsEmbedToken(
id: true,
country: true,
defaultPayoutMethod: true,
+ networkStatus: true,
},
});
+ if (partner.networkStatus === "banned") {
+ throw new DubApiError({
+ code: "forbidden",
+ message:
+ "Your account is banned from the Dub Partner Network, so you can't connect a payout method.",
+ });
+ }
+
if (
partner.country &&
!TREMENDOUS_SUPPORTED_COUNTRIES.includes(partner.country)
diff --git a/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-account-closed.ts b/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-account-closed.ts
index d95fab567b..673fb484ca 100644
--- a/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-account-closed.ts
+++ b/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-account-closed.ts
@@ -25,6 +25,7 @@ export async function recipientAccountClosed(event: Stripe.ThinEvent) {
payoutsEnabledAt: true,
defaultPayoutMethod: true,
tremendousEmail: true,
+ networkStatus: true,
},
});
diff --git a/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-configuration-updated.ts b/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-configuration-updated.ts
index 9ac9af9207..05576153c2 100644
--- a/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-configuration-updated.ts
+++ b/apps/web/app/(ee)/api/stripe/connect/v2/webhook/recipient-configuration-updated.ts
@@ -28,6 +28,7 @@ export async function recipientConfigurationUpdated(event: Stripe.ThinEvent) {
defaultPayoutMethod: true,
cryptoWalletAddress: true,
tremendousEmail: true,
+ networkStatus: true,
},
});
diff --git a/apps/web/app/(ee)/api/stripe/connect/webhook/account-application-deauthorized.ts b/apps/web/app/(ee)/api/stripe/connect/webhook/account-application-deauthorized.ts
index c4fce3b7ca..6c5020cddd 100644
--- a/apps/web/app/(ee)/api/stripe/connect/webhook/account-application-deauthorized.ts
+++ b/apps/web/app/(ee)/api/stripe/connect/webhook/account-application-deauthorized.ts
@@ -24,6 +24,7 @@ export async function accountApplicationDeauthorized(
payoutsEnabledAt: true,
defaultPayoutMethod: true,
tremendousEmail: true,
+ networkStatus: true,
},
});
diff --git a/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts b/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts
index 0ec807262d..cbe3392de0 100644
--- a/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts
+++ b/apps/web/app/(ee)/api/stripe/connect/webhook/account-updated.ts
@@ -41,6 +41,7 @@ export async function accountUpdated(event: Stripe.AccountUpdatedEvent) {
defaultPayoutMethod: true,
payoutMethodHash: true,
tremendousEmail: true,
+ networkStatus: true,
},
});
@@ -117,7 +118,8 @@ export async function accountUpdated(event: Stripe.AccountUpdatedEvent) {
return `No change in payout state for partner ${partner.email} (${partner.stripeConnectId}), skipping...`;
}
- if (partner.payoutsEnabledAt && !payoutsEnabledAt) {
+ // Also covers banned partners, where payoutsEnabledAt stays null
+ if (!payoutsEnabledAt) {
return `Payouts disabled, updated partner ${partner.email} (${partner.stripeConnectId}) with payoutsEnabledAt null`;
}
diff --git a/apps/web/lib/payouts/recompute-partner-payout-state.ts b/apps/web/lib/payouts/recompute-partner-payout-state.ts
index 1af08a24f8..b5b960cd71 100644
--- a/apps/web/lib/payouts/recompute-partner-payout-state.ts
+++ b/apps/web/lib/payouts/recompute-partner-payout-state.ts
@@ -16,6 +16,7 @@ const PAYOUT_METHOD_PRIORITY: PartnerPayoutMethod[] = [
* Computes payoutsEnabledAt and defaultPayoutMethod based on currently active
* payout methods. Preserves the partner's existing default when it is still
* active; otherwise falls back to priority order: stablecoin > connect > paypal.
+ * Keeps payoutsEnabledAt null for partners banned from the network.
*/
export async function recomputePartnerPayoutState(
partner: Pick<
@@ -26,6 +27,7 @@ export async function recomputePartnerPayoutState(
| "payoutsEnabledAt"
| "defaultPayoutMethod"
| "tremendousEmail"
+ | "networkStatus"
> & {
cryptoWalletAddress?: string | null;
},
@@ -124,7 +126,8 @@ export async function recomputePartnerPayoutState(
let payoutsEnabledAt: Date | null = null;
- if (defaultPayoutMethod) {
+ // Partners banned from the network must not get payouts enabled again
+ if (defaultPayoutMethod && partner.networkStatus !== "banned") {
// if default payout method has changed, set payoutsEnabledAt to today
// otherwise, use the existing payoutsEnabledAt (or today if null)
if (defaultPayoutMethod !== partner.defaultPayoutMethod) {