The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Improve `fundFinancialAccount` for `forceWithdrawal`
Steven Tey9decf5aa6712
diff --git a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.tsindex 965173ada8..0d939de351 100644--- a/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts+++ b/apps/web/app/(ee)/api/cron/payouts/charge-succeeded/queue-external-payouts.ts@@ -14,13 +14,17 @@ export async function queueExternalPayouts() {// All payouts are processed internally, hence no need to queue external payoutsif (invoice.payoutMode === "internal") {- console.log(`Invoice ${invoice.id} is paid internally. Skipping...`);+ console.log(+ `Invoice ${invoice.id} is paid internally. Skipping external payouts...`,+ );return;}// should never happen, but just in caseif (!invoice.programId) {- console.log(`Invoice ${invoice.id} has no program ID. Skipping...`);+ console.log(+ `Invoice ${invoice.id} has no program ID. Skipping external payouts...`,+ );return;}diff --git a/apps/web/lib/partners/create-stablecoin-payout.ts b/apps/web/lib/partners/create-stablecoin-payout.tsindex a8d7512321..851be1faff 100644--- a/apps/web/lib/partners/create-stablecoin-payout.ts+++ b/apps/web/lib/partners/create-stablecoin-payout.ts@@ -19,6 +19,7 @@ import {MIN_FORCE_WITHDRAWAL_AMOUNT_CENTS,MIN_WITHDRAWAL_AMOUNT_CENTS,STABLECOIN_PAYOUT_FEE_RATE,+ STABLECOIN_PAYOUT_FIXED_FEE_CENTS,} from "../constants/payouts";import { enqueueBatchJobs } from "../cron/enqueue-batch-jobs";import { createPayoutsIdempotencyKey } from "../payouts/create-payouts-idempotency-key";@@ -265,7 +266,13 @@ export const createStablecoinPayout = async ({if (amountToTransferToFA > 0) {await fundFinancialAccount({- amount: amountToTransferToFA,+ // if there are no current invoice payouts (meaning partner is running a forceWithdrawal for previously processed payouts)+ // we need to add the STABLECOIN_PAYOUT_FIXED_FEE_CENTS to the amount to transfer to the FA (to cover the Stablecoin payout fee)+ amount:+ amountToTransferToFA ++ (currentInvoicePayouts.length === 0+ ? STABLECOIN_PAYOUT_FIXED_FEE_CENTS+ : 0),idempotencyKey,});}