Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions apps/worker/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,22 @@ export async function processAutoTopUp(): Promise<void> {
.where(eq(tables.transaction.id, pendingTransaction.id));
}
} catch (stripeError) {
logger.error(
`Stripe error for organization ${org.id}`,
const errObj =
stripeError instanceof Error
? stripeError
: new Error(String(stripeError)),
);
: new Error(String(stripeError));
// Card declines (insufficient funds, generic_decline, expired
// cards, etc.) are an expected outcome of an off-session auto
// top-up, not a server error, so log them at warn level to avoid
// noisy error alerts.
if (stripeError instanceof Stripe.errors.StripeCardError) {
logger.warn(
`Auto top-up card declined for organization ${org.id}`,
errObj,
);
} else {
logger.error(`Stripe error for organization ${org.id}`, errObj);
}
// Mark transaction as failed
await db
.update(tables.transaction)
Expand Down
Loading