#7454·nango

更新条带 18.2.1 → 22.6.1

作者: ibadia创建于 2026年9月9日更新于 2026年9月9日

import { z } from 'zod';

import { billing } from '@nangohq/billing'; import { plansList } from '@nangohq/shared'; import { getLogger, report, requireEmptyQuery, zodErrorToHTTP } from '@nangohq/utils';

import { disableGrowthAddon, downgradePlan, enableGrowthAddon, getPlanChangeContext, resolvePlanChange, trackPlanChange, upgradePlan } from '../../../../services/planChange.service.js'; import { asyncWrapper } from '../../../../utils/asyncWrapper.js';

import type { PlanChangeContext, PlanChangeError, PlanChanges } from '../../../../services/planChange.service.js'; import type { RequestLocals } from '../../../../utils/express.js'; import type { BillingSubscription, PostPlanChange } from '@nangohq/types'; import type { Response } from 'express'; import type Stripe from 'stripe';

const logger = getLogger('Server.PostChange');

type PlanChangeResponse = Response<PostPlanChange['Reply'], RequestLocals>;

function logContext(context: PlanChangeContext, subscription: BillingSubscription, changes: PlanChanges) { return { accountId: context.team.id, currentPlan: context.currentPlan.name, requestedPlan: context.requested.newPlanCode, …