Skip to main content

NativeRevenueEstimator

\Benecaster\Membership\NativeRevenueEstimator

Class Premium

Resolves the dashboard’s “This Month (est.)” revenue estimate for a Built-in Membership show, reading SubscriptionRepository::find_billing_for_show() as its candidate pool. Returns null (rendered as “—” by the admin) rather than a partial figure when a subscriber’s price can’t be resolved or when the candidate pool spans more than one currency.

Methods

Method Visibility Since Description
estimate( int $show_id ): ?float Public — Sums each billed subscriber's monthly-equivalent price for the show. Active or past_due only; trials, paused subscriptions, subscriptions set to cancel, and manually-comped (is_manual_grant = 1) subscribers are excluded. A subscriber grandfathered on an older price counts at the tier's current price, not the older rate they are actually billed. Returns null on an unresolvable price or a mixed-currency pool.
resolve_price( array $subscription ): ?array Public — Static. Resolves one subscription row to its {amount_cents, currency, interval_unit, interval_count} via price_id when present, falling back to a billing-interval match against the tier's price rows. Returns null when no match is found.
monthly_equivalent( int $amount_cents, string $interval_unit, int $interval_count ): float Public — Static. Normalises any cadence to a monthly figure — an annual price is divided by 12; any other interval_unit × interval_count Stripe accepts is normalised the same way.
currency_prefix( string $currency ): string Public — Static. $ for usd; otherwise the uppercased ISO currency code plus a trailing space (EUR , GBP ). Used for the dashboard's currency_symbol field, which is not hard-coded to $.