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 instead of throwing when transferable amount is below min withdrawal amount (#4012)

Kiran Kd9b59631d5fb
diff --git a/apps/web/lib/partners/create-stablecoin-payout.ts b/apps/web/lib/partners/create-stablecoin-payout.ts
index 54bf78d980..e2aacde8ed 100644
--- a/apps/web/lib/partners/create-stablecoin-payout.ts
+++ b/apps/web/lib/partners/create-stablecoin-payout.ts
@@ -131,9 +131,16 @@ export const createStablecoinPayout = async ({
);
if (totalTransferableAmount < MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS) {
- throw new Error(
- `Total transferable amount (${currencyFormatter(totalTransferableAmount)}) for partner ${partner.email} is less than the minimum amount required for withdrawal (${currencyFormatter(MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS)}). Skipping...`,
- );
+ const message = `Total transferable amount (${currencyFormatter(totalTransferableAmount)}) is less than the minimum amount required for withdrawal (${currencyFormatter(MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS)}).`;
+
+ // For force-withdrawal action, throw so the error surfaces back to partners.
+ // Otherwise (e.g. cron-driven payouts) just log and skip silently.
+ if (forceWithdrawal) {
+ throw new Error(message);
+ } else {
+ console.warn(message);
+ return;
+ }
}
let withdrawalFee = 0;
diff --git a/apps/web/lib/partners/create-stripe-transfer.ts b/apps/web/lib/partners/create-stripe-transfer.ts
index bbb02d7c5d..ec042d801a 100644
--- a/apps/web/lib/partners/create-stripe-transfer.ts
+++ b/apps/web/lib/partners/create-stripe-transfer.ts
@@ -109,9 +109,16 @@ export const createStripeTransfer = async ({
);
if (totalTransferableAmount < MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS) {
- throw new Error(
- `Total transferable amount (${currencyFormatter(totalTransferableAmount)}) for partner ${partner.email} is less than the minimum amount required for withdrawal (${currencyFormatter(MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS)}). Skipping...`,
- );
+ const message = `Total transferable amount (${currencyFormatter(totalTransferableAmount)}) is less than the minimum amount required for withdrawal (${currencyFormatter(MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS)}).`;
+
+ // For force-withdrawal action, throw so the error surfaces back to partners.
+ // Otherwise (e.g. cron-driven payouts) just log and skip silently.
+ if (forceWithdrawal) {
+ throw new Error(message);
+ } else {
+ console.warn(message);
+ return;
+ }
}
let withdrawalFee = 0;