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.

skip commission creation if firstCommission is fraud/canceled (#3046)

Steven Tey587ae85b7c09
diff --git a/apps/web/lib/partners/create-partner-commission.ts b/apps/web/lib/partners/create-partner-commission.ts
index 705638079c..9c8b2d63b8 100644
--- a/apps/web/lib/partners/create-partner-commission.ts
+++ b/apps/web/lib/partners/create-partner-commission.ts
@@ -136,6 +136,17 @@ export const createPartnerCommission = async ({
});
if (firstCommission) {
+ // if first commission is fraud or canceled, skip commission creation
+ if (["fraud", "canceled"].includes(firstCommission.status)) {
+ console.log(
+ `Partner ${partnerId} has a first commission that is ${firstCommission.status}, skipping commission creation...`,
+ );
+ return {
+ commission: null,
+ webhookPartner: constructWebhookPartner(programEnrollment),
+ };
+ }
+
// for lead events, we need to check if the partner has already been issued a lead reward for this customer
if (event === "lead") {
console.log(
@@ -210,14 +221,6 @@ export const createPartnerCommission = async ({
}
}
}
-
- // if first commission is fraud or canceled, the commission will be set to fraud or canceled as well
- if (
- firstCommission.status === "fraud" ||
- firstCommission.status === "canceled"
- ) {
- status = firstCommission.status;
- }
}
}