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
4 changes: 3 additions & 1 deletion lib/coinpay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const SETUP_AMOUNT_RE = /^(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d{1,2})?$/;
export function setupAmountUsd(value: unknown = SETUP_FEE_USD): number {
if (typeof value === "number") {
if (!Number.isFinite(value) || value <= 0) throw new Error("setup payment amount must be positive");
return Math.round(value * 100) / 100;
const rounded = Math.round(value * 100) / 100;
if (Math.abs(value - rounded) > Number.EPSILON) throw new Error("setup payment amount must not have fractional cents");
return rounded;
}

const text = String(value ?? "").trim().replace(/\s+/g, "");
Expand Down
Loading