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.

payout_fee_party

Steven Teyff55f97b4d31
diff --git a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
index cd8ef7330e..4851ad1a96 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/settings/payouts/page-client.tsx
@@ -216,6 +216,9 @@ export function PayoutsSettingsPageClient() {
</div>
<ComplianceButton setModalState={setModalState} />
</div>
+ <div className="my-8">
+ <PartnerWithdrawalsActivity />
+ </div>
</div>
) : !isLoading ? (
<AnimatedEmptyState
@@ -240,9 +243,6 @@ export function PayoutsSettingsPageClient() {
) : (
<LayoutLoader />
)}
- <div className="my-8">
- <PartnerWithdrawalsActivity />
- </div>
</div>
</>
);
diff --git a/apps/web/lib/actions/partners/create-dots-withdrawal.ts b/apps/web/lib/actions/partners/create-dots-withdrawal.ts
index cab61b9c09..005eb418cc 100644
--- a/apps/web/lib/actions/partners/create-dots-withdrawal.ts
+++ b/apps/web/lib/actions/partners/create-dots-withdrawal.ts
@@ -25,12 +25,23 @@ export const createDotsWithdrawalAction = authPartnerActionClient
dotsUserId: partner.dotsUserId,
partner,
});
- console.log({ dotsUser });
+
+ const amountToWithdraw = dotsUser.wallet.withdrawable_amount;
+
+ console.log({
+ country: partner.country,
+ amount: amountToWithdraw,
+ });
const response = await createWithdrawal({
dotsUserId: partner.dotsUserId,
- amount: dotsUser.wallet.withdrawable_amount,
+ amount: amountToWithdraw,
platform,
+ // for US-based withdrawals over $1,000, we pay the fee
+ payoutFeeParty:
+ partner.country === "US" && amountToWithdraw > 100000
+ ? "platform"
+ : "user",
});
return response;
diff --git a/apps/web/lib/dots/create-withdrawal.ts b/apps/web/lib/dots/create-withdrawal.ts
index 2b541606bf..65e6ffd2e4 100644
--- a/apps/web/lib/dots/create-withdrawal.ts
+++ b/apps/web/lib/dots/create-withdrawal.ts
@@ -7,10 +7,12 @@ export const createWithdrawal = async ({
dotsUserId,
amount,
platform,
+ payoutFeeParty,
}: {
dotsUserId: string;
amount: number;
platform: DotsPayoutPlatform;
+ payoutFeeParty?: "platform" | "user";
}) => {
const response = await fetch(`${DOTS_API_URL}/payouts`, {
method: "POST",
@@ -19,6 +21,7 @@ export const createWithdrawal = async ({
user_id: dotsUserId,
amount,
platform,
+ payout_fee_party: payoutFeeParty,
}),
});
diff --git a/apps/web/lib/dots/schemas.ts b/apps/web/lib/dots/schemas.ts
index f9409455a3..6b7e93d084 100644
--- a/apps/web/lib/dots/schemas.ts
+++ b/apps/web/lib/dots/schemas.ts
@@ -86,7 +86,7 @@ export const dotsUserSchema = z.object({
withdrawable_amount: z.number(),
pending_amount: z.number(),
}),
- default_payout_method: dotsPayoutPlatforms,
+ default_payout_method: dotsPayoutPlatforms.nullable(),
payout_methods: z.array(payoutMethodSchema),
compliance: z.any(),
});
diff --git a/apps/web/scripts/create-payouts.ts b/apps/web/scripts/create-payouts.ts
index 32a4ff4b0e..9e69bcddc4 100644
--- a/apps/web/scripts/create-payouts.ts
+++ b/apps/web/scripts/create-payouts.ts
@@ -31,8 +31,8 @@ async function main() {
programId,
partnerId,
amount: 150000,
- fee: 3100,
- total: 153100,
+ fee: 3000,
+ total: 153000,
periodStart: new Date("2024-01-01"),
periodEnd: new Date("2024-01-31"),
},
@@ -41,8 +41,8 @@ async function main() {
programId,
partnerId,
amount: 2000,
- fee: 140,
- total: 2140,
+ fee: 40,
+ total: 2040,
periodStart: new Date("2024-02-01"),
periodEnd: new Date("2024-02-28"),
},
@@ -51,8 +51,8 @@ async function main() {
programId,
partnerId,
amount: 3000,
- fee: 160,
- total: 3160,
+ fee: 60,
+ total: 3060,
periodStart: new Date("2024-03-01"),
periodEnd: new Date("2024-03-31"),
},