Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(billing): disable Max plan purchases (#7008)

Will Hutchinson2333154901f5
diff --git a/apps/docs/account/billing.mdx b/apps/docs/account/billing.mdx
index 183ed67936..033e04348e 100644
--- a/apps/docs/account/billing.mdx
+++ b/apps/docs/account/billing.mdx
@@ -1,24 +1,24 @@
---
title: "Billing & Plans"
icon: "credit-card"
-description: "Macro's free, Premium, and Max plans, how AI usage is included, and how to manage your subscription."
+description: "Macro's free and Premium plans, how AI usage is included, and how to manage your subscription."
---
-Macro has two paid plans, priced per person. The price is the same whether you're solo or on a team.
+Macro offers one paid plan for new subscriptions, priced per person. The price is the same whether you're solo or on a team.
-| | Free | Premium | Max |
-| --- | --- | --- | --- |
-| Price | \$0 | \$40 / month | \$200 / month |
-| AI agent | Fast model only | All models | All models |
-| AI usage included each month | Limited | \$40 | \$200 |
-| Beyond included AI | — | Credits or usage billing | Credits or usage billing |
-| Storage | 5 GB | 1 TB | 1 TB |
+| | Free | Premium |
+| --- | --- | --- |
+| Price | \$0 | \$40 / month |
+| AI agent | Fast model only | All models |
+| AI usage included each month | Limited | \$40 |
+| Beyond included AI | — | Credits or usage billing |
+| Storage | 5 GB | 1 TB |
-Teams require a paid seat for every member; there's no free plan for teams. Each seat has its own plan: a team can mix Premium and Max seats, and team admins choose the plan for every member from the **Plan** menu next to their name in **Settings → Team**. Moving a seat is prorated for the rest of the billing period. Your current plan is shown in **Settings → Billing**, with **Upgrade** buttons if you're on the free plan and an **Upgrade to Max** button on Premium (on a team, that moves only your own seat).
+Paid teams require a paid seat for every member. Free teams can include unpaid members. New paid seats use Premium. Max is unavailable for new purchases and upgrades. Existing Max seats keep their plan and can move to Premium from **Settings → Team**. Moving a seat is prorated for the rest of the billing period. Your current plan is shown in **Settings → Billing**, with an **Upgrade** button if you're on the free plan and a **Switch to Premium** option if you're on Max.
## AI usage
-Every paid plan includes a monthly amount of AI usage worth the plan's price, measured at Macro's usage rates: Premium includes \$40 of AI each month and Max includes \$200. Each AI request draws on that amount based on the model and the tokens it used, so the heavy models go further into it: Opus 5 uses about 2.5×, and Fable 5.1 and GPT-6 Astra about 5×, what Sonnet 5 does for the same conversation (the model picker shows the multiplier). On a team, every seat keeps its own allowance: unused usage on one seat doesn't move to another. Prepaid credits and usage billing are shared across the team and managed by the team owner.
+Premium includes \$40 of AI each month, measured at Macro's usage rates. Existing Max seats keep their \$200 allowance. Each AI request draws on that amount based on the model and the tokens it used, so the heavy models go further into it: Opus 5 uses about 2.5×, and Fable 5.1 and GPT-6 Astra about 5×, what Sonnet 5 does for the same conversation (the model picker shows the multiplier). On a team, every seat keeps its own allowance: unused usage on one seat doesn't move to another. Prepaid credits and usage billing are shared across the team and managed by the team owner.
**Settings → Billing** shows how much of this period's included AI you've used, when it resets, your credit balance, and your usage billing settings. Included usage resets at the start of each billing period; it doesn't roll over.
@@ -26,7 +26,6 @@ When the included amount is used up, AI requests pause until one of these applie
- **Credits** — prepaid AI usage you buy in \$10, \$25, \$50, or \$100 packs. Credits are applied after your included amount, never expire, and carry over between periods.
- **Usage billing** — turn it on to bill AI beyond your included amount and credits to your card in \$10 increments, up to a monthly limit you choose. If a charge fails, usage billing pauses until you update your payment method and turn it back on.
-- **Upgrading to Max** — five times the included usage for that seat. Upgrades take effect immediately and are prorated for the rest of the period. On a team, move the heavy users' seats to Max from **Settings → Team** and leave the rest on Premium.
On a team, the team owner buys credits and controls usage billing for everyone; members see the team's position but not the controls.
diff --git a/apps/docs/product/agents.mdx b/apps/docs/product/agents.mdx
index 87d246229e..0da43c30eb 100644
--- a/apps/docs/product/agents.mdx
+++ b/apps/docs/product/agents.mdx
@@ -77,7 +77,7 @@ Agents can run on a schedule. An automation is a saved prompt that runs on its o
A model picker sits in the chat input. You can choose a model per chat depending on how difficult you deem the question. Your choice is remembered for that chat and carried forward when you start a new one from the composer.
-On the free plan you can only use Haiku, the fast model. Every paid plan (Premium and Max) unlocks the rest, including Opus 5, Fable 5.1 (Anthropic's most capable model), and GPT-6 Astra (OpenAI's). Heavier models draw down your included AI faster, and the picker shows by how much: Opus uses about 2.5×, and Fable and Astra about 5×, what Sonnet does for the same conversation.
+On the free plan you can only use Haiku, the fast model. Premium and existing Max subscriptions unlock the rest, including Opus 5, Fable 5.1 (Anthropic's most capable model), and GPT-6 Astra (OpenAI's). Heavier models draw down your included AI faster, and the picker shows by how much: Opus uses about 2.5×, and Fable and Astra about 5×, what Sonnet does for the same conversation.
<Frame>
![The model picker, showing the available models](/images/model_options.png)
diff --git a/apps/web/src/features/paywall/AiUsageLimitDialog.tsx b/apps/web/src/features/paywall/AiUsageLimitDialog.tsx
index 04882f2cfa..962daae2d6 100644
--- a/apps/web/src/features/paywall/AiUsageLimitDialog.tsx
+++ b/apps/web/src/features/paywall/AiUsageLimitDialog.tsx
@@ -1,8 +1,9 @@
import { AiUsageControls, AiUsageMeter } from '@app/features/settings/AiUsage';
-import { useAnalytics } from '@app/lib/analytics/analytics-context';
-import { toast } from '@core/component/Toast/Toast';
+// import { useAnalytics } from '@app/lib/analytics/analytics-context';
+// import { toast } from '@core/component/Toast/Toast';
import { useAiUsageLimitState } from '@core/constant/AiUsageLimitState';
-import { useAiBillingSummaryQuery, useChangePlanMutation } from '@queries/auth';
+import { useAiBillingSummaryQuery } from '@queries/auth';
+// import { useChangePlanMutation } from '@queries/auth';
import type { AiDenyCode } from '@service-auth/ai-billing-types';
import { useNavigate } from '@solidjs/router';
import { Button, Dialog, Surface } from '@ui';
@@ -21,14 +22,15 @@ const TITLES: Record<AiDenyCode, string> = {
export function AiUsageLimitDialog() {
const { usageLimitOpen, usageLimitCode, hideUsageLimit } =
useAiUsageLimitState();
- const analytics = useAnalytics();
+ // const analytics = useAnalytics();
const navigate = useNavigate();
const summary = useAiBillingSummaryQuery({ enabled: usageLimitOpen });
- const changePlan = useChangePlanMutation();
+ // const changePlan = useChangePlanMutation();
const title = () => TITLES[usageLimitCode() ?? 'ai_allowance_exhausted'];
const returnUrl = () => `${window.location.origin}/app/settings/billing`;
+ /*
const upgradeToMax = async () => {
try {
await changePlan.mutateAsync({ plan: 'max' });
@@ -40,6 +42,7 @@ export function AiUsageLimitDialog() {
toast.failure("Couldn't upgrade. Please try again from Billing.");
}
};
+ */
return (
<Dialog
@@ -54,8 +57,7 @@ export function AiUsageLimitDialog() {
<h2 class="text-xl font-semibold text-ink">{title()}</h2>
<p class="text-sm text-ink-extra-muted">
Your plan includes AI each month at Macro's usage rates. Add
- credits or turn on usage billing to keep going now, or move to Max
- for five times the included usage.
+ credits or turn on usage billing to keep going.
</p>
</div>
@@ -98,6 +100,7 @@ export function AiUsageLimitDialog() {
>
Dismiss
</Button>
+ {/*
<Suspense fallback={null}>
<Show
when={
@@ -116,6 +119,7 @@ export function AiUsageLimitDialog() {
</Button>
</Show>
</Suspense>
+ */}
</div>
</div>
</section>
diff --git a/apps/web/src/features/paywall/plans.test.ts b/apps/web/src/features/paywall/plans.test.ts
new file mode 100644
index 0000000000..b568bfd493
--- /dev/null
+++ b/apps/web/src/features/paywall/plans.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from 'vitest';
+import { PLAN_BY_TIER, PLANS } from './plans';
+
+describe('plan catalogs', () => {
+ it('offers only Free and Premium during onboarding', () => {
+ expect(PLANS.map((plan) => plan.tier)).toEqual(['free', 'premium']);
+ });
+
+ it('retains Max for current-plan display', () => {
+ expect(PLAN_BY_TIER.max).toEqual({
+ tier: 'max',
+ name: 'Max',
+ price: 200,
+ highlighted: false,
+ aiIncluded: 200,
+ });
+ });
+});
diff --git a/apps/web/src/features/paywall/plans.ts b/apps/web/src/features/paywall/plans.ts
index 0752f406bd..7e43afa519 100644
--- a/apps/web/src/features/paywall/plans.ts
+++ b/apps/web/src/features/paywall/plans.ts
@@ -15,34 +15,40 @@ export type Plan = {
/** Tiers that correspond to real Stripe products. Excludes 'free'. */
export type PaidPlanTier = Exclude<PlanTier, 'free'>;
+const FREE_PLAN = {
+ tier: 'free',
+ name: 'Free',
+ price: 0,
+ highlighted: false,
+ aiIncluded: 0,
+} as const satisfies Plan;
+
+const PREMIUM_PLAN = {
+ tier: 'premium',
+ name: 'Premium',
+ price: 40,
+ highlighted: true,
+ aiIncluded: 40,
+} as const satisfies Plan;
+
+const MAX_PLAN = {
+ tier: 'max',
+ name: 'Max',
+ price: 200,
+ highlighted: false,
+ aiIncluded: 200,
+} as const satisfies Plan;
+
export const PLANS = [
- {
- tier: 'free' as const,
- name: 'Free',
- price: 0,
- highlighted: false,
- aiIncluded: 0,
- },
- {
- tier: 'premium' as const,
- name: 'Premium',
- price: 40,
- highlighted: true,
- aiIncluded: 40,
- },
- {
- tier: 'max' as const,
- name: 'Max',
- price: 200,
- highlighted: false,
- aiIncluded: 200,
- },
+ FREE_PLAN,
+ PREMIUM_PLAN,
+ // MAX_PLAN,
] as const satisfies Plan[];
export const PLAN_BY_TIER: Record<PlanTier, Plan> = {
- free: PLANS[0],
- premium: PLANS[1],
- max: PLANS[2],
+ free: FREE_PLAN,
+ premium: PREMIUM_PLAN,
+ max: MAX_PLAN,
};
interface PlanFeature {
diff --git a/apps/web/src/features/settings/AiUsage.tsx b/apps/web/src/features/settings/AiUsage.tsx
index 8104b4663d..4b331d29ed 100644
--- a/apps/web/src/features/settings/AiUsage.tsx
+++ b/apps/web/src/features/settings/AiUsage.tsx
@@ -31,7 +31,7 @@ function formatPeriodEnd(iso: string): string {
const BLOCKED_COPY: Record<AiDenyReason, string> = {
allowance_exhausted:
- "You've used this period's included AI. Add credits, turn on usage billing, or upgrade to keep going.",
+ "You've used this period's included AI. Add credits or turn on usage billing to keep going.",
overage_limit_reached:
"You've reached your usage billing limit for this period. Raise the limit or add credits to keep going.",
overage_payment_failed:
@@ -192,8 +192,7 @@ export function AiUsageControls(props: {
fallback={
<p class="text-xs text-ink-extra-muted">
AI usage for your team is managed by the team owner. Ask them to add
- credits or turn on usage billing, or ask a team admin to move your
- seat to Max.
+ credits or turn on usage billing.
</p>
}
>
diff --git a/apps/web/src/features/settings/Billing.test.tsx b/apps/web/src/features/settings/Billing.test.tsx
index eccf416477..d8a1c70948 100644
--- a/apps/web/src/features/settings/Billing.test.tsx
+++ b/apps/web/src/features/settings/Billing.test.tsx
@@ -24,6 +24,7 @@ const state = vi.hoisted(() => ({
summarySuccess: true,
unlimited: false,
toastSuccess: vi.fn(),
+ changePlan: vi.fn(),
}));
vi.mock('@core/constant/featureFlags', () => ({
@@ -63,7 +64,10 @@ vi.mock('@queries/auth', () => ({
};
},
}),
- useChangePlanMutation: () => ({ isPending: false, mutateAsync: vi.fn() }),
+ useChangePlanMutation: () => ({
+ isPending: false,
+ mutateAsync: state.changePlan,
+ }),
useCreateCheckoutSessionMutation: () => ({ mutateAsync: vi.fn() }),
}));
vi.mock('@service-stripe/client', () => ({
@@ -101,6 +105,7 @@ describe.each([false, true])('Billing with DEV_MODE_ENV=%s', (dev) => {
state.summarySuccess = true;
state.unlimited = false;
state.toastSuccess.mockClear();
+ state.changePlan.mockClear();
});
it.each<PlanTier>(['free', 'premium', 'max'])(
@@ -127,11 +132,6 @@ describe.each([false, true])('Billing with DEV_MODE_ENV=%s', (dev) => {
name: tier === 'free' ? 'Upgrade now' : 'Manage',
})
).toBeTruthy();
- if (tier === 'premium') {
- expect(
- screen.getByText(dev ? 'Need more AI?' : 'Upgrade')
- ).toBeTruthy();
- }
}
);
@@ -161,15 +161,30 @@ describe.each([false, true])('Billing with DEV_MODE_ENV=%s', (dev) => {
).toBe(dev);
});
- it('only advertises an increased allowance in the dev upgrade toast', async () => {
+ it.each<PlanTier>(['free', 'premium'])(
+ 'does not offer Max purchases from the %s plan',
+ (tier) => {
+ state.tier = tier;
+ render(() => <Billing />);
+
+ expect(screen.queryByRole('button', { name: 'Get Max' })).toBeNull();
+ expect(
+ screen.queryByRole('button', { name: 'Upgrade to Max' })
+ ).toBeNull();
+ }
+ );
+
+ it('keeps the current Max plan visible and allows a Premium downgrade', async () => {
+ state.tier = 'max';
render(() => <Billing />);
- fireEvent.click(screen.getByRole('button', { name: 'Upgrade to Max' }));
+
+ expect(screen.getByRole('heading', { name: 'Max plan' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Get Max' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Upgrade to Max' })).toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Switch to Premium' }));
await waitFor(() =>
- expect(state.toastSuccess).toHaveBeenCalledWith(
- dev
- ? 'Upgraded to Max. Your larger AI allowance applies right away.'
- : 'Upgraded to Max.'
- )
+ expect(state.changePlan).toHaveBeenCalledWith({ plan: 'premium' })
);
});
});
diff --git a/apps/web/src/features/settings/Billing.tsx b/apps/web/src/features/settings/Billing.tsx
index c94780e106..cfea265afa 100644
--- a/apps/web/src/features/settings/Billing.tsx
+++ b/apps/web/src/features/settings/Billing.tsx
@@ -310,6 +310,7 @@ export const Billing = () => {
</ul>
</section>
</SettingsCard>
+ {/*
<SettingsCard>
<section class="flex flex-col gap-4 p-4">
<header class="flex items-center gap-2">
@@ -331,8 +332,10 @@ export const Billing = () => {
</ul>
</section>
</SettingsCard>
+ */}
</SettingsSection>
</Match>
+ {/*
<Match when={tier() === 'premium'}>
<SettingsSection title={DEV_MODE_ENV ? 'Need more AI?' : 'Upgrade'}>
<SettingsCard>
@@ -367,6 +370,7 @@ export const Billing = () => {
</SettingsCard>
</SettingsSection>
</Match>
+ */}
<Match when={tier() === 'max'}>
<SettingsSection>
<p class="px-6 text-xs text-ink-extra-muted">
diff --git a/apps/web/src/features/settings/Team.tsx b/apps/web/src/features/settings/Team.tsx
index 4b4130c045..df38d86496 100644
--- a/apps/web/src/features/settings/Team.tsx
+++ b/apps/web/src/features/settings/Team.tsx
@@ -1,3 +1,4 @@
+import { PLAN_BY_TIER, PLANS } from '@app/features/paywall/plans';
import { toast } from '@core/component/Toast/Toast';
import {
getLinkShareScope,
@@ -163,11 +164,32 @@ function RoleSelect(props: {
type PlanOption = { value: PaidPlan; label: string; description: string };
-const planOptions: PlanOption[] = [
- { value: 'premium', label: 'Premium', description: '$40 · $40 of AI' },
- { value: 'max', label: 'Max', description: '$200 · $200 of AI' },
+const maxPlan = PLAN_BY_TIER.max;
+const MAX_PLAN_OPTION: PlanOption = {
+ value: 'max',
+ label: maxPlan.name,
+ description: `$${maxPlan.price} · $${maxPlan.aiIncluded} of AI`,
+};
+const purchasablePlanOptions: PlanOption[] = [
+ ...PLANS.flatMap((plan) =>
+ plan.tier === 'free'
+ ? []
+ : [
+ {
+ value: plan.tier,
+ label: plan.name,
+ description: `$${plan.price} · $${plan.aiIncluded} of AI`,
+ },
+ ]
+ ),
];
+function planOptionsFor(currentPlan: PaidPlan): PlanOption[] {
+ return currentPlan === 'max'
+ ? [...purchasablePlanOptions, MAX_PLAN_OPTION]
+ : purchasablePlanOptions;
+}
+
/**
* The plan a member's seat is billed at. Until the generated `TeamMember`
* schema carries `plan`, read it defensively; every seat starts on Premium.
@@ -182,12 +204,13 @@ function PlanSelect(props: {
onChange: (plan: PaidPlan) => void;
disabled?: boolean;
}) {
+ const options = () => planOptionsFor(props.value);
const selectedOption = () =>
- planOptions.find((o) => o.value === props.value) ?? planOptions[0];
+ options().find((option) => option.value === props.value) ?? options()[0];
return (
<Select<PlanOption>
- options={planOptions}
+ options={options()}
value={selectedOption()}
onChange={(opt) => opt && props.onChange(opt.value)}
optionValue="value"
diff --git a/apps/web/src/features/setup/flow/PlanStep.tsx b/apps/web/src/features/setup/flow/PlanStep.tsx
index f72fedcbd6..f28de7522f 100644
--- a/apps/web/src/features/setup/flow/PlanStep.tsx
+++ b/apps/web/src/features/setup/flow/PlanStep.tsx
@@ -138,7 +138,6 @@ export function PlanStep(props: {
);
}
-/** The regular free/premium/max picker. */
function PlanPicker(props: {
finishing: boolean;
selected: PlanTier;
@@ -149,7 +148,7 @@ function PlanPicker(props: {
const selected = () => props.selected;
return (
<div class="flex flex-col gap-6">
- <div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<Index each={PLANS}>
{(plan) => (
<button
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/planCatalogResponse.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/planCatalogResponse.ts
index 373aaf0003..57cee420b9 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/schemas/planCatalogResponse.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/planCatalogResponse.ts
@@ -16,6 +16,6 @@ export interface PlanCatalogResponse {
overage_limit_max_cents: number;
/** Smallest allowed overage cap, cents. */
overage_limit_min_cents: number;
- /** Every plan, cheapest first. */
+ /** Free and every purchasable paid plan, cheapest first. */
plans: PlanCatalogEntry[];
}
diff --git a/apps/web/src/lib/service-clients/service-auth/openapi.json b/apps/web/src/lib/service-clients/service-auth/openapi.json
index 5daf18f3bc..2e198b17a5 100644
--- a/apps/web/src/lib/service-clients/service-auth/openapi.json
+++ b/apps/web/src/lib/service-clients/service-auth/openapi.json
@@ -6105,7 +6105,7 @@
"items": {
"$ref": "#/components/schemas/PlanCatalogEntry"
},
- "description": "Every plan, cheapest first."
+ "description": "Free and every purchasable paid plan, cheapest first."
}
}
},
diff --git a/crates/ai_billing/src/domain/models.rs b/crates/ai_billing/src/domain/models.rs
index 161f932b28..7bf80f4b53 100644
--- a/crates/ai_billing/src/domain/models.rs
+++ b/crates/ai_billing/src/domain/models.rs
@@ -429,7 +429,7 @@ impl DenyReason {
pub fn message(self) -> &'static str {
match self {
DenyReason::AllowanceExhausted => {
- "You've used this period's included AI. Add credits, turn on usage billing, or upgrade to keep going."
+ "You've used this period's included AI. Add credits or turn on usage billing to keep going."
}
DenyReason::OverageLimitReached => {
"You've reached your AI spending limit for this period. Raise the limit or add credits to keep going."
diff --git a/crates/ai_billing/src/inbound/axum_router.rs b/crates/ai_billing/src/inbound/axum_router.rs
index 18d591e986..af20100258 100644
--- a/crates/ai_billing/src/inbound/axum_router.rs
+++ b/crates/ai_billing/src/inbound/axum_router.rs
@@ -19,6 +19,7 @@ use macro_authorization::{
use macro_user_id::user_id::MacroUserIdStr;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
+use teams::domain::model::SeatPlan;
use utoipa::ToSchema;
/// Error response body.
@@ -42,7 +43,7 @@ pub struct PlanCatalogEntry {
/// The plan catalog and the knobs the billing UI offers.
#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct PlanCatalogResponse {
- /// Every plan, cheapest first.
+ /// Free and every purchasable paid plan, cheapest first.
pub plans: Vec<PlanCatalogEntry>,
/// Credit packs a payer may buy, cents.
pub credit_packs_cents: Vec<i64>,
@@ -281,8 +282,8 @@ pub async fn get_summary_handler<B: BillingService, Auth: MacroAuthorizationServ
)]
pub async fn get_plans_handler() -> Json<PlanCatalogResponse> {
Json(PlanCatalogResponse {
- plans: [PlanTier::Free, PlanTier::Premium, PlanTier::Max]
- .into_iter()
+ plans: std::iter::once(PlanTier::Free)
+ .chain(SeatPlan::PURCHASABLE.into_iter().map(PlanTier::from))
.map(|tier| PlanCatalogEntry {
tier,
monthly_price_cents: tier.monthly_price_cents(),
@@ -415,52 +416,4 @@ pub async fn settle_handler<B: BillingService, Auth: MacroAuthorizationService>(
}
#[cfg(test)]
-mod test {
- use super::{ReturnUrlError, validate_return_url};
-
- #[test]
- fn return_urls_must_be_https_on_the_calling_origin() {
- let origin = Some("https://macro.com");
- assert_eq!(
- validate_return_url("https://macro.com/app/settings/billing?x=1", origin),
- Ok(())
- );
- // Without an Origin header any https URL without credentials passes.
- assert_eq!(
- validate_return_url("https://preview.macro.com/app", None),
- Ok(())
- );
- assert_eq!(
- validate_return_url("http://localhost:3000/app", Some("http://localhost:3000")),
- Ok(())
- );
- assert_eq!(
- validate_return_url("https://macro.com:443/app", origin),
- Ok(())
- );
- assert_eq!(
- validate_return_url("https://macro.com:8443/app", origin),
- Err(ReturnUrlError::Origin)
- );
- assert_eq!(
- validate_return_url("https://evil.example/app", origin),
- Err(ReturnUrlError::Origin)
- );
- assert_eq!(
- validate_return_url("http://macro.com/app", None),
- Err(ReturnUrlError::Scheme)
- );
- assert_eq!(
- validate_return_url("javascript:alert(1)", None),
- Err(ReturnUrlError::Unparseable)
- );
- assert_eq!(
- validate_return_url("/app/settings/billing", None),
- Err(ReturnUrlError::Unparseable)
- );
- assert_eq!(
- validate_return_url("https://user:[email protected]/app", None),
- Err(ReturnUrlError::Credentials)
- );
- }
-}
+mod test;
diff --git a/crates/ai_billing/src/inbound/axum_router/test.rs b/crates/ai_billing/src/inbound/axum_router/test.rs
new file mode 100644
index 0000000000..f71dac8656
--- /dev/null
+++ b/crates/ai_billing/src/inbound/axum_router/test.rs
@@ -0,0 +1,61 @@
+use super::{ReturnUrlError, get_plans_handler, validate_return_url};
+use crate::domain::PlanTier;
+
+#[test]
+fn return_urls_must_be_https_on_the_calling_origin() {
+ let origin = Some("https://macro.com");
+ assert_eq!(
+ validate_return_url("https://macro.com/app/settings/billing?x=1", origin),
+ Ok(())
+ );
+ // Without an Origin header any https URL without credentials passes.
+ assert_eq!(
+ validate_return_url("https://preview.macro.com/app", None),
+ Ok(())
+ );
+ assert_eq!(
+ validate_return_url("http://localhost:3000/app", Some("http://localhost:3000")),
+ Ok(())
+ );
+ assert_eq!(
+ validate_return_url("https://macro.com:443/app", origin),
+ Ok(())
+ );
+ assert_eq!(
+ validate_return_url("https://macro.com:8443/app", origin),
+ Err(ReturnUrlError::Origin)
+ );
+ assert_eq!(
+ validate_return_url("https://evil.example/app", origin),
+ Err(ReturnUrlError::Origin)
+ );
+ assert_eq!(
+ validate_return_url("http://macro.com/app", None),
+ Err(ReturnUrlError::Scheme)
+ );
+ assert_eq!(
+ validate_return_url("javascript:alert(1)", None),
+ Err(ReturnUrlError::Unparseable)
+ );
+ assert_eq!(
+ validate_return_url("/app/settings/billing", None),
+ Err(ReturnUrlError::Unparseable)
+ );
+ assert_eq!(
+ validate_return_url("https://user:[email protected]/app", None),
+ Err(ReturnUrlError::Credentials)
+ );
+}
+
+#[tokio::test]
+async fn plan_catalog_contains_only_free_and_purchasable_paid_plans() {
+ let tiers = get_plans_handler()
+ .await
+ .0
+ .plans
+ .into_iter()
+ .map(|plan| plan.tier)
+ .collect::<Vec<_>>();
+
+ assert_eq!(tiers, vec![PlanTier::Free, PlanTier::Premium]);
+}
diff --git a/crates/teams/src/domain/model.rs b/crates/teams/src/domain/model.rs
index c160aa197e..e5520e5819 100644
--- a/crates/teams/src/domain/model.rs
+++ b/crates/teams/src/domain/model.rs
@@ -156,6 +156,12 @@ impl SeatPlan {
/// Every plan.
pub const ALL: [SeatPlan; 2] = [SeatPlan::Premium, SeatPlan::Max];
+ /// Plans available for a new purchase or plan move.
+ pub const PURCHASABLE: [SeatPlan; 1] = [
+ SeatPlan::Premium,
+ // SeatPlan::Max,
+ ];
+
/// The role tier recorded on a user holding this seat.
pub fn product_tier(self) -> ProductTier {
match self {
diff --git a/crates/teams/src/domain/team_service.rs b/crates/teams/src/domain/team_service.rs
index 47b4cd0702..1641601e0b 100644
--- a/crates/teams/src/domain/team_service.rs
+++ b/crates/teams/src/domain/team_service.rs
@@ -1671,6 +1671,9 @@ where
if member.plan == plan {
return Ok(member);
}
+ if !SeatPlan::PURCHASABLE.contains(&plan) {
+ return Err(CustomerError::PlanUnavailable(plan).into());
+ }
// Seat plans only mean something on a team that is billed per seat:
// paying teams move the seat on Stripe, enterprise teams (billed out
diff --git a/crates/teams/src/domain/team_service/test.rs b/crates/teams/src/domain/team_service/test.rs
index d6e7207e3f..9cd799aba6 100644
--- a/crates/teams/src/domain/team_service/test.rs
+++ b/crates/teams/src/domain/team_service/test.rs
@@ -2158,13 +2158,17 @@ fn build_member_plan_service(
}
#[tokio::test]
-async fn set_team_member_plan_moves_seat_records_plan_and_swaps_tier_role() {
+async fn set_team_member_plan_downgrades_max_seat_and_swaps_tier_role() {
let team_id = uuid::Uuid::from_u128(5100);
let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
let member_id = "macro|[email protected]";
let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let member = TeamMember {
+ plan: SeatPlan::Max,
+ ..make_team_member(team_id, member_id, TeamRole::Member)
+ };
let mut team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
- .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ .with_team_members(vec![member]);
team_repo.team_subscription_id = Some("sub_team".parse().unwrap());
let plan_calls = team_repo.patch_team_member_plan_calls.clone();
let customer_repo = MockCustomerRepository::default();
@@ -2178,33 +2182,33 @@ async fn set_team_member_plan_moves_seat_records_plan_and_swaps_tier_role() {
.set_team_member_plan(
test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
&MacroUserIdStr::parse_from_str(member_id).unwrap(),
- SeatPlan::Max,
+ SeatPlan::Premium,
)
.await
.unwrap();
- assert_eq!(member.plan, SeatPlan::Max);
+ assert_eq!(member.plan, SeatPlan::Premium);
assert_eq!(member.role, TeamRole::Member);
assert_eq!(
*move_calls.lock().unwrap(),
- vec![("sub_team".to_string(), SeatPlan::Premium, SeatPlan::Max)]
+ vec![("sub_team".to_string(), SeatPlan::Max, SeatPlan::Premium)]
);
assert_eq!(
*plan_calls.lock().unwrap(),
- vec![(team_id, member_id.to_string(), SeatPlan::Max)]
+ vec![(team_id, member_id.to_string(), SeatPlan::Premium)]
);
assert_eq!(
*upsert_calls.lock().unwrap(),
vec![(
member_id.to_string(),
- vec![RoleId::TeamSubscriber, RoleId::SubMax]
+ vec![RoleId::TeamSubscriber, RoleId::SubOpus]
)]
);
assert_eq!(
*remove_calls.lock().unwrap(),
vec![(
member_id.to_string(),
- vec![RoleId::SubHaiku, RoleId::SubSonnet, RoleId::SubOpus]
+ vec![RoleId::SubHaiku, RoleId::SubSonnet, RoleId::SubMax]
)]
);
}
@@ -2215,8 +2219,12 @@ async fn set_team_member_plan_is_a_no_op_when_already_on_plan() {
let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
let member_id = "macro|[email protected]";
let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let member = TeamMember {
+ plan: SeatPlan::Max,
+ ..make_team_member(team_id, member_id, TeamRole::Member)
+ };
let mut team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
- .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ .with_team_members(vec![member]);
team_repo.team_subscription_id = Some("sub_team".parse().unwrap());
let plan_calls = team_repo.patch_team_member_plan_calls.clone();
let customer_repo = MockCustomerRepository::default();
@@ -2231,24 +2239,64 @@ async fn set_team_member_plan_is_a_no_op_when_already_on_plan() {
.set_team_member_plan(
test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
&MacroUserIdStr::parse_from_str(member_id).unwrap(),
- SeatPlan::Premium,
+ SeatPlan::Max,
)
.await
.unwrap();
- assert_eq!(member.plan, SeatPlan::Premium);
+ assert_eq!(member.plan, SeatPlan::Max);
assert!(move_calls.lock().unwrap().is_empty());
assert!(plan_calls.lock().unwrap().is_empty());
}
+#[tokio::test]
+async fn set_team_member_plan_rejects_premium_to_max_without_side_effects() {
+ let team_id = uuid::Uuid::from_u128(5105);
+ let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+ let member_id = "macro|[email protected]";
+ let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let mut team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
+ .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ team_repo.team_subscription_id = Some("sub_team".parse().unwrap());
+ let plan_calls = team_repo.patch_team_member_plan_calls.clone();
+ let customer_repo = MockCustomerRepository::default();
+ let move_calls = customer_repo.move_seat_calls.clone();
+ let roles_service = MockUserRolesAndPermissionsService::default();
+ let upsert_calls = roles_service.upsert_calls.clone();
+ let remove_calls = roles_service.remove_calls.clone();
+ let service = build_member_plan_service(team_repo, customer_repo, roles_service);
+
+ let error = service
+ .set_team_member_plan(
+ test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
+ &MacroUserIdStr::parse_from_str(member_id).unwrap(),
+ SeatPlan::Max,
+ )
+ .await
+ .unwrap_err();
+
+ assert!(matches!(
+ error,
+ SetTeamMemberPlanError::CustomerError(CustomerError::PlanUnavailable(SeatPlan::Max))
+ ));
+ assert!(move_calls.lock().unwrap().is_empty());
+ assert!(plan_calls.lock().unwrap().is_empty());
+ assert!(upsert_calls.lock().unwrap().is_empty());
+ assert!(remove_calls.lock().unwrap().is_empty());
+}
+
#[tokio::test]
async fn set_team_member_plan_rejects_free_teams() {
let team_id = uuid::Uuid::from_u128(5102);
let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
let member_id = "macro|[email protected]";
let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let member = TeamMember {
+ plan: SeatPlan::Max,
+ ..make_team_member(team_id, member_id, TeamRole::Member)
+ };
let team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
- .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ .with_team_members(vec![member]);
let plan_calls = team_repo.patch_team_member_plan_calls.clone();
let customer_repo = MockCustomerRepository::default();
let move_calls = customer_repo.move_seat_calls.clone();
@@ -2262,7 +2310,7 @@ async fn set_team_member_plan_rejects_free_teams() {
.set_team_member_plan(
test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
&MacroUserIdStr::parse_from_str(member_id).unwrap(),
- SeatPlan::Max,
+ SeatPlan::Premium,
)
.await
.unwrap_err();
@@ -2273,13 +2321,17 @@ async fn set_team_member_plan_rejects_free_teams() {
}
#[tokio::test]
-async fn set_team_member_plan_enterprise_skips_stripe_but_records_plan_and_roles() {
+async fn set_team_member_plan_enterprise_downgrade_skips_stripe_but_records_plan_and_roles() {
let team_id = uuid::Uuid::from_u128(5103);
let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
let member_id = "macro|[email protected]";
let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let member = TeamMember {
+ plan: SeatPlan::Max,
+ ..make_team_member(team_id, member_id, TeamRole::Member)
+ };
let mut team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
- .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ .with_team_members(vec![member]);
team_repo.enterprise = true;
let plan_calls = team_repo.patch_team_member_plan_calls.clone();
let customer_repo = MockCustomerRepository::default();
@@ -2292,7 +2344,7 @@ async fn set_team_member_plan_enterprise_skips_stripe_but_records_plan_and_roles
.set_team_member_plan(
test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
&MacroUserIdStr::parse_from_str(member_id).unwrap(),
- SeatPlan::Max,
+ SeatPlan::Premium,
)
.await
.unwrap();
@@ -2300,7 +2352,7 @@ async fn set_team_member_plan_enterprise_skips_stripe_but_records_plan_and_roles
assert!(move_calls.lock().unwrap().is_empty());
assert_eq!(
*plan_calls.lock().unwrap(),
- vec![(team_id, member_id.to_string(), SeatPlan::Max)]
+ vec![(team_id, member_id.to_string(), SeatPlan::Premium)]
);
assert_eq!(upsert_calls.lock().unwrap().len(), 1);
}
@@ -2311,8 +2363,12 @@ async fn set_team_member_plan_rolls_back_seat_move_when_recording_plan_fails() {
let admin_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
let member_id = "macro|[email protected]";
let mark_sent_calls: Arc<Mutex<Vec<Vec<uuid::Uuid>>>> = Arc::new(Mutex::new(Vec::new()));
+ let member = TeamMember {
+ plan: SeatPlan::Max,
+ ..make_team_member(team_id, member_id, TeamRole::Member)
+ };
let mut team_repo = MockTeamRepository::new(Vec::new(), "Test Team", mark_sent_calls)
- .with_team_members(vec![make_team_member(team_id, member_id, TeamRole::Member)]);
+ .with_team_members(vec![member]);
team_repo.team_subscription_id = Some("sub_team".parse().unwrap());
team_repo.fail_patch_team_member_plan = true;
let customer_repo = MockCustomerRepository::default();
@@ -2325,7 +2381,7 @@ async fn set_team_member_plan_rolls_back_seat_move_when_recording_plan_fails() {
.set_team_member_plan(
test_team_receipt::<AdminTeamRole>(team_id, &admin_id),
&MacroUserIdStr::parse_from_str(member_id).unwrap(),
- SeatPlan::Max,
+ SeatPlan::Premium,
)
.await
.unwrap_err();
@@ -2334,8 +2390,8 @@ async fn set_team_member_plan_rolls_back_seat_move_when_recording_plan_fails() {
assert_eq!(
*move_calls.lock().unwrap(),
vec![
- ("sub_team".to_string(), SeatPlan::Premium, SeatPlan::Max),
("sub_team".to_string(), SeatPlan::Max, SeatPlan::Premium),
+ ("sub_team".to_string(), SeatPlan::Premium, SeatPlan::Max),
]
);
assert!(upsert_calls.lock().unwrap().is_empty());
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index d366a5a280..760b8a9833 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -304,9 +304,9 @@ request, sending a message answers HTTP 402 and the app opens the
**AI usage limit** dialog (title `You've used this month's included AI`, or the
spending-limit / failed-charge variants). It shows the same meter and controls
as Settings → Billing: credit-pack buttons, the `Usage billing` toggle, an
-`Open billing settings` button, and `Upgrade to Max` for Premium payers (on a
-team this moves only the payer's own seat). Team members who are not the payer
-see a note to ask the team owner, or a team admin to move their seat to Max.
+`Open billing settings` button, and no Max purchase or upgrade control. Team
+members who are not the payer see a note to ask the team owner to add credits
+or turn on usage billing.
Each team seat has its own allowance; unused allowance never moves between
members. The team owner's prepaid credits and usage-billing cap are shared.
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 3bcd78cb87..3044f2e8a6 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1255,6 +1255,12 @@ use a glass sheet with a title, description, Close confirmation button, and
side-by-side cancel and confirm actions. Pending actions disable both buttons
and prevent dismissal; canceling leaves the underlying data unchanged.
+## Setup plan step — `/app/onboarding`
+
+The plan step shows two cards: Free and Premium. Premium starts Stripe Checkout.
+The step has no Max card or Max checkout path. A returning account that already
+has Max still sees Max named as its active plan.
+
## Settings — `/app/settings/<section>`
### Email signatures
@@ -1351,13 +1357,14 @@ list / delete personal keys; the secret is shown only once and is sent as
backend), paid plans show an **AI usage** card with the period meter, credit
balance, credit-pack buttons `$10`/`$25`/`$50`/`$100` that redirect to Stripe
Checkout, and a `Usage billing` toggle with per-period limit pills; these
-controls and usage-billing promotional copy are hidden outside dev; an
-`Upgrade`/`Upgrade to Max` card, or a `Switch to Premium` link on Max; on a team
-the plan change moves only the viewer's own seat),
+controls and usage-billing promotional copy are hidden outside dev; an `Upgrade`
+card for Free users to buy Premium, no Max purchase or upgrade control, and a
+`Switch to Premium` link on Max; on a team the downgrade moves only the viewer's
+own seat),
`Appearance`, `Agents`, `Mobile App`, `Shortcuts` (interactive keyboard visualization, not a list);
Workspace → `Team` (members list; on a paid team each row shows the seat's plan,
-and admins/owners change it with the `Seat plan` menu: `Premium` or `Max`,
-prorated at once), `Tags`, `CRM` (enable/disable; once enabled, a `Deal stages` section
+and admins/owners can move an existing Max seat to Premium with the `Seat plan`
+menu; Premium seats have no Max option; moves are prorated at once), `Tags`, `CRM` (enable/disable; once enabled, a `Deal stages` section
with `Customize stages`, inline rename, reorder by drag handle or arrow keys (up/down
buttons on touch), delete, `Add stage`, `Reset to defaults`, and `Closed stages`
checkboxes, editable by the role set as `edit_stages_role`),
diff --git a/packages/sdk/generated/auth/types.gen.ts b/packages/sdk/generated/auth/types.gen.ts
index a80ceb20f6..0c1b8ca252 100644
--- a/packages/sdk/generated/auth/types.gen.ts
+++ b/packages/sdk/generated/auth/types.gen.ts
@@ -1093,7 +1093,7 @@ export type PlanCatalogResponse = {
*/
overage_limit_min_cents: number;
/**
- * Every plan, cheapest first.
+ * Free and every purchasable paid plan, cheapest first.
*/
plans: Array<PlanCatalogEntry>;
};
diff --git a/packages/sdk/specs/auth.json b/packages/sdk/specs/auth.json
index 5daf18f3bc..2e198b17a5 100644
--- a/packages/sdk/specs/auth.json
+++ b/packages/sdk/specs/auth.json
@@ -6105,7 +6105,7 @@
"items": {
"$ref": "#/components/schemas/PlanCatalogEntry"
},
- "description": "Every plan, cheapest first."
+ "description": "Free and every purchasable paid plan, cheapest first."
}
}
},
diff --git a/services/authentication_service/src/api/user/stripe/change_plan.rs b/services/authentication_service/src/api/user/stripe/change_plan.rs
index 27912e05f3..f9e09cc4de 100644
--- a/services/authentication_service/src/api/user/stripe/change_plan.rs
+++ b/services/authentication_service/src/api/user/stripe/change_plan.rs
@@ -59,7 +59,6 @@ pub async fn change_plan(
user: MacroAuthorizationExtractor<AuthorizationService, UserOrInternal>,
Json(req): Json<ChangePlanRequest>,
) -> Result<Json<ChangePlanResponse>, StripeOperationError> {
- let target_price = ctx.stripe_prices.price_id(req.plan)?.to_string();
let user_id = &user.authorization.user.macro_user_id;
// A member of a team billed per seat is billed through the team: move
@@ -138,14 +137,16 @@ pub async fn change_plan(
})
.ok_or(StripeOperationError::NoSubscription)?;
- if seat_item
+ let current_plan = seat_item
.price
.as_ref()
- .is_some_and(|price| price.id.as_str() == target_price)
- {
+ .and_then(|price| ctx.stripe_prices.plan_for_price(price.id.as_str()))
+ .ok_or(StripeOperationError::NoSubscription)?;
+ if current_plan == req.plan {
return Err(StripeOperationError::AlreadyOnPlan);
}
+ let target_price = ctx.stripe_prices.price_id(req.plan)?.to_string();
let params = stripe::UpdateSubscription {
items: Some(vec![stripe::UpdateSubscriptionItems {
id: Some(seat_item.id.to_string()),
diff --git a/services/authentication_service/src/api/user/stripe/create_checkout_session_v2.rs b/services/authentication_service/src/api/user/stripe/create_checkout_session_v2.rs
index 52a1de2ae8..a5f65f6c01 100644
--- a/services/authentication_service/src/api/user/stripe/create_checkout_session_v2.rs
+++ b/services/authentication_service/src/api/user/stripe/create_checkout_session_v2.rs
@@ -63,6 +63,9 @@ pub async fn create_checkout_session<Eas: EntityAccessService>(
optional_team: OptionalMacroUserTeamExtractorV2<OwnerTeamRole, Eas, AuthorizationService>,
Json(req): Json<CreateCheckoutSessionV2Request>,
) -> Result<Json<StripeSessionResponse>, StripeOperationError> {
+ let plan = req.plan.unwrap_or(PaidPlan::Premium);
+ let price_id = ctx.stripe_prices.price_id(plan)?.to_string();
+
// Get the stripe customer ID from the database
let stripe_customer_id = macro_db_client::user::get::get_stripe_customer_id_by_user_id(
&ctx.db,
@@ -162,9 +165,6 @@ pub async fn create_checkout_session<Eas: EntityAccessService>(
..Default::default()
});
- let plan = req.plan.unwrap_or(PaidPlan::Premium);
- let price_id = ctx.stripe_prices.price_id(plan)?.to_string();
-
// Create the checkout session
let params = stripe::CreateCheckoutSession {
customer: Some(customer_id),
diff --git a/services/authentication_service/src/api/user/stripe/shared.rs b/services/authentication_service/src/api/user/stripe/shared.rs
index 10bd6fdf54..4d5005da7f 100644
--- a/services/authentication_service/src/api/user/stripe/shared.rs
+++ b/services/authentication_service/src/api/user/stripe/shared.rs
@@ -27,6 +27,9 @@ pub struct StripePrices {
impl StripePrices {
/// The price to sell `plan` at.
pub fn price_id(&self, plan: PaidPlan) -> Result<&str, StripeOperationError> {
+ if !PaidPlan::PURCHASABLE.contains(&plan) {
+ return Err(StripeOperationError::PlanUnavailable);
+ }
match plan {
PaidPlan::Premium => Ok(&self.premium),
PaidPlan::Max => self
@@ -146,3 +149,6 @@ pub struct StripeSessionResponse {
/// The URL to redirect the user to
pub url: String,
}
+
+#[cfg(test)]
+mod test;
diff --git a/services/authentication_service/src/api/user/stripe/shared/test.rs b/services/authentication_service/src/api/user/stripe/shared/test.rs
new file mode 100644
index 0000000000..7727efd65b
--- /dev/null
+++ b/services/authentication_service/src/api/user/stripe/shared/test.rs
@@ -0,0 +1,29 @@
+use super::{PaidPlan, StripeOperationError, StripePrices};
+
+fn prices() -> StripePrices {
+ StripePrices {
+ premium: "price_premium".to_string(),
+ max: Some("price_max".to_string()),
+ }
+}
+
+#[test]
+fn premium_remains_available_for_purchase() {
+ assert_eq!(
+ prices().price_id(PaidPlan::Premium).unwrap(),
+ "price_premium"
+ );
+}
+
+#[test]
+fn max_is_rejected_as_a_purchase_target() {
+ assert!(matches!(
+ prices().price_id(PaidPlan::Max),
+ Err(StripeOperationError::PlanUnavailable)
+ ));
+}
+
+#[test]
+fn configured_max_prices_are_still_recognized() {
+ assert_eq!(prices().plan_for_price("price_max"), Some(PaidPlan::Max));
+}