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.

filter for USD balance in trigger-withdrawal

Steven Teyf9b9e5039162
diff --git a/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts b/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
index eb66a4789d..71911480ea 100644
--- a/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
+++ b/apps/web/app/(ee)/api/cron/trigger-withdrawal/route.ts
@@ -1,5 +1,5 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
-import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
+import { verifyVercelSignature } from "@/lib/cron/verify-vercel";
import { stripe } from "@/lib/stripe";
import { prisma } from "@dub/prisma";
import { currencyFormatter } from "@dub/utils";
@@ -9,14 +9,9 @@ export const dynamic = "force-dynamic";
// This route is used to trigger withdrawal from Stripe (since we're using manual payouts)
// Runs twice a day at midnight and noon UTC (0 0 * * * and 0 12 * * *)
-export async function POST(req: Request) {
+export async function GET(req: Request) {
try {
- const rawBody = await req.text();
-
- await verifyQstashSignature({
- req,
- rawBody,
- });
+ await verifyVercelSignature(req);
const [stripeBalanceData, payoutsToBeSentData] = await Promise.all([
stripe.balance.retrieve(),
@@ -32,8 +27,14 @@ export async function POST(req: Request) {
}),
]);
- const currentAvailableBalance = stripeBalanceData.available[0].amount; // available to withdraw
- const currentPendingBalance = stripeBalanceData.pending[0].amount; // balance waiting to settle
+ // available to withdraw (USD)
+ const currentAvailableBalance =
+ stripeBalanceData.available.find((b) => b.currency === "usd")?.amount ??
+ 0;
+ // balance waiting to settle (USD)
+ const currentPendingBalance =
+ stripeBalanceData.pending.find((b) => b.currency === "usd")?.amount ?? 0;
+
// x-slack-ref: https://dub.slack.com/archives/C074P7LMV9C/p1750185638973479
const currentNetBalance =
currentPendingBalance < 0
diff --git a/apps/web/vercel.json b/apps/web/vercel.json
index 29850ca966..6898c24d6b 100644
--- a/apps/web/vercel.json
+++ b/apps/web/vercel.json
@@ -24,14 +24,6 @@
"path": "/api/cron/streams/update-partner-stats",
"schedule": "*/2 * * * *"
},
- {
- "path": "/api/cron/usage",
- "schedule": "0 12 * * *"
- },
- {
- "path": "/api/cron/aggregate-clicks",
- "schedule": "0 0 * * *"
- },
{
"path": "/api/cron/partner-program-summary",
"schedule": "0 13 1 * *"
@@ -44,6 +36,10 @@
"path": "/api/cron/payouts/aggregate-due-commissions",
"schedule": "0 * * * *"
},
+ {
+ "path": "/api/cron/trigger-withdrawal",
+ "schedule": "0 0,12 * * *"
+ },
{
"path": "/api/cron/payouts/force-withdrawals",
"schedule": "0 12 * * *"
@@ -59,10 +55,6 @@
{
"path": "/api/cron/bounties/queue-sync-social-metrics",
"schedule": "0 * * * *"
- },
- {
- "path": "/api/cron/fraud/summary",
- "schedule": "0 16 * * *"
}
],
"functions": {