File tree Expand file tree Collapse file tree
apps/backend/src/lib/payments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,18 @@ export function computeApplicationFeeAmount(options: { amountStripeUnits: number
3636 return Math . round ( options . amountStripeUnits * bps / 10000 ) ;
3737}
3838
39+ /**
40+ * Returns the fee as a decimal percent for Stripe's `application_fee_percent`
41+ * (subscription) parameter, or `undefined` for projects that aren't billed.
42+ *
43+ * `bps / 100` is intentional float division — the rest of the module uses
44+ * integer arithmetic to avoid IEEE-754 noise on charge-amount math, but the
45+ * subscription path requires a decimal because that's the shape Stripe's API
46+ * accepts. This is safe for the current 90 bps (→ 0.9, which serialises
47+ * cleanly), and any future bps value must produce a number with at most 4
48+ * decimal places after IEEE-754 rounding — that's the maximum precision
49+ * Stripe documents for `application_fee_percent`.
50+ */
3951export function getApplicationFeePercentOrUndefined ( projectId : string ) : number | undefined {
4052 const bps = getApplicationFeeBps ( projectId ) ;
4153 if ( bps === 0 ) return undefined ;
You can’t perform that action at this time.
0 commit comments