Auto-Forwarding Payouts Just Got Smarter on PayDirect

Auto-Forwarding Payouts Just Got Smarter on PayDirect

PD

PayDirect Team

Apr 14, 2026·3 min read

Get Your Crypto Right: PayDirect Auto-Forwarding Just Got an Upgrade! 🚀

Hey there, crypto wizards and AI junkies! If you're into seamless crypto payments and settlements (or just hate the hassle of manual checks), the PayDirect platform has your back. Our latest code push to the main branch comes with some nifty updates that are bound to make your development life smoother and your payment processes slicker. Buckle up as we dive into what’s new, exciting, and worth every byte of your attention!

Auto-Forwarding FTW! 🌟

Picture this: You’ve got incoming payouts to PayDirect workspace wallets, and you wish they could just auto-forward themselves, saving you the mundane task of manual transfers. Well, dream no more! With commit 2f093b3, we’ve squashed bugs in the auto-forwarding mechanism so your payouts can zoom straight into your PayDirect workspace wallets without breaking a sweat.

The Code Says It All

Here’s a sneak peek into the code that makes this magic happen:

// If the destination is a PayDirect workspace wallet, create an incoming
// payment record so the ForwardingService auto-forwards to settlement.
try {
  const destWallet = await sql`
    SELECT wa.id, wa.workspace_id, wa.type, w.environment, w.settlement_address
    FROM wallet_accounts wa
    JOIN workspaces w ON w.id = wa.workspace_id
    WHERE wa.address = ${body.destinationAddress}
      AND w.is_active = true
    LIMIT 1
  `
  if (destWallet.length > 0) {
    // More code here to handle fee calculation and payment record creation
    console.log(`[PAYOUT] Created incoming payment record for ${body.destinationAddress} (workspace ${dw.workspace_id}) → settlement ${settlementAddr}`)
  }
} catch (recvErr) {
  console.warn("[PAYOUT] Failed to create receiving payment record (non-blocking):", recvErr)
}

Why You Should Care

For those of you who’ve been manually forwarding payments, this fix is your new best friend. It ensures that payments hitting your workspace wallets automatically forward to the designated settlement addresses. This not only saves time but also drastically reduces errors, making sure your funds are always where they need to be. 🚀

Smarter Wallet Sweeping 🤖

But wait—there’s more! Our SweepService just got a brain boost. Instead of only checking workspace wallets, it now supports smart wallets too. This expanded functionality ensures more wallets are swept of any excess balance, making your operations even more efficient.

Code Snippet Time!

Let’s peek under the hood to see what changed in lib/sweep-service.ts:

const wallets = await sql`
  SELECT wa.address, wa.workspace_id, wa.type as wallet_type, w.environment
  FROM wallet_accounts wa
  JOIN workspaces w ON w.id = wa.workspace_id
  WHERE wa.type IN ('workspace', 'smart_wallet') AND w.is_active = true
`;

Why This Matters

Remember when your smart wallet was feeling a bit... neglected? Not anymore. By including smart wallets in the sweep process, you're ensuring that every account type gets the attention it deserves. It’s all about inclusivity, even in the digital wallet world. Plus, who doesn’t love streamlined balance management?

Keeping Things in Sync with Vercel 🔁

To wrap it all up, we sprinkled a little scheduling magic on our Vercel configuration. The new cron job /api/cron/sweep-balances runs every 30 minutes like clockwork, keeping your balances fresh and in check.

Here’s the vercel.json change:

{
  "path": "/api/cron/sweep-balances",
  "schedule": "*/30 * * * *"
}

Why It’s Cool

Ever thought of your app as a digital Swiss watch? With this change, it can be! Scheduled balance sweeps ensure that your digital assets are managed with precision, minimizing idle funds and maximizing operational efficiency.

Dive Into the Code and Try It Out! 💻

Developers, it’s time to roll up your sleeves and dive into these updates. Check out the full code on our GitHub repo and see firsthand how these changes can help streamline your crypto settlement processes. If you’re curious or have any questions, don’t hesitate to explore our documentation, which has all the details you need to make the most of these features.

Stay savvy, keep coding, and may your crypto always forward itself! 😉

Tip the Author

Powered by PayDirect on Base

Enjoyed this post? Send a tip using crypto. We eat our own dog food.

USDC

More from PayDirect

Powered by ContentAgent