diff --git a/server/src/external/stripe/webhookHandlers/handleSubUpdated.ts b/server/src/external/stripe/webhookHandlers/handleSubUpdated.ts index 724e89db4..9e4499424 100644 --- a/server/src/external/stripe/webhookHandlers/handleSubUpdated.ts +++ b/server/src/external/stripe/webhookHandlers/handleSubUpdated.ts @@ -54,6 +54,7 @@ export const handleSubscriptionUpdated = async ({ trialing: CusProductStatus.Active, active: CusProductStatus.Active, past_due: CusProductStatus.PastDue, + incomplete: CusProductStatus.PastDue, // temporary status for incomplete subscription }; const updatedCusProducts = await CusProductService.updateByStripeSubId({ diff --git a/shared/api/_openapi/prevVersions/openapi1.2/openapi1.2.0.ts b/shared/api/_openapi/prevVersions/openapi1.2/openapi1.2.0.ts index a3ae2bfde..2951d3d24 100644 --- a/shared/api/_openapi/prevVersions/openapi1.2/openapi1.2.0.ts +++ b/shared/api/_openapi/prevVersions/openapi1.2/openapi1.2.0.ts @@ -27,7 +27,7 @@ const OPENAPI_1_2_0 = createDocument( servers: [ { - url: "https://api.useautumn.com", + url: "https://api.useautumn.com/v1", description: "Production server", }, ], diff --git a/shared/api/_openapi2.0_/coreOpenApi.ts b/shared/api/_openapi2.0_/coreOpenApi.ts index f248cedfc..cfcfa3062 100644 --- a/shared/api/_openapi2.0_/coreOpenApi.ts +++ b/shared/api/_openapi2.0_/coreOpenApi.ts @@ -1,11 +1,11 @@ import { - AttachResultSchema, + AttachBodyV0Schema, + AttachResponseV0Schema, CancelBodySchema, CancelResultSchema, - CheckoutResponseSchema, + CheckoutParamsV0Schema, + CheckoutResponseV0Schema, CheckResponseV2Schema, - ExtAttachBodySchema, - ExtCheckoutParamsSchema, ExtCheckParamsSchema, QueryParamsSchema, QueryResultSchema, @@ -40,7 +40,7 @@ export const coreOps: ZodOpenApiPathsObject = { requestBody: { content: { "application/json": { - schema: ExtAttachBodySchema, + schema: AttachBodyV0Schema, examples: { basic: { summary: "Attach a product immediately", @@ -60,7 +60,7 @@ export const coreOps: ZodOpenApiPathsObject = { description: "Product attached successfully", content: { "application/json": { - schema: AttachResultSchema, + schema: AttachResponseV0Schema, }, }, }, @@ -73,12 +73,12 @@ export const coreOps: ZodOpenApiPathsObject = { description: checkoutJsDoc, tags: ["core"], requestBody: { - content: { "application/json": { schema: ExtCheckoutParamsSchema } }, + content: { "application/json": { schema: CheckoutParamsV0Schema } }, }, responses: { "200": { description: "200 OK", - content: { "application/json": { schema: CheckoutResponseSchema } }, + content: { "application/json": { schema: CheckoutResponseV0Schema } }, }, }, }, diff --git a/shared/api/_prevVersions/openapi1.2.0.ts b/shared/api/_prevVersions/openapi1.2.0_old.ts similarity index 98% rename from shared/api/_prevVersions/openapi1.2.0.ts rename to shared/api/_prevVersions/openapi1.2.0_old.ts index e0f7274b1..9a1a259a3 100644 --- a/shared/api/_prevVersions/openapi1.2.0.ts +++ b/shared/api/_prevVersions/openapi1.2.0_old.ts @@ -61,7 +61,7 @@ const OPENAPI_1_2_0 = createDocument( servers: [ { - url: "https://api.useautumn.com", + url: "https://api.useautumn.com/v1", description: "Production server", }, ], diff --git a/shared/api/billing/checkout/checkoutParamsV1.ts b/shared/api/billing/checkout/checkoutParamsV1.ts index 0b54167e0..eeee2c77c 100644 --- a/shared/api/billing/checkout/checkoutParamsV1.ts +++ b/shared/api/billing/checkout/checkoutParamsV1.ts @@ -4,45 +4,6 @@ import { EntityDataSchema } from "../../common/entityData.js"; import { FeatureQuantitySchema } from "../common/featureQuantities.js"; import { PlanOverrideSchema } from "../common/planOverride.js"; -// product_ids: z -// .array(z.string()) -// .min(1) -// .nullish() -// .describe( -// "Can be used to attach multiple products to the customer at once. For example, attaching a main product and an add-on.", -// ), - -// Overrides: -// // free_trial: z -// .boolean() -// .optional() -// .describe( -// "If the product has a free trial, this field can be used to disable it when attaching (by passing in false)", -// ), - -// force_checkout: z -// .boolean() -// .optional() -// .describe( -// "Always return a Stripe Checkout URL, even if the customer's card is already on file", -// ), - -// products: z.array(ProductOptions).nullish(), [got rid of products lol] -// customer_data: CustomerDataSchema.nullish(), // For safety - -/* -Notes: -- free_trial: false -> plan_override.free_trial: false -- New behaviour for checkout -> Always force checkout (?) - -// Custom Product - // is_custom: z.boolean().optional(), - // items: z.array(ProductItemSchema).optional(), - - - // setup_payment: z.boolean().optional(), -*/ - export const ExtCheckoutParamsV1Schema = z .object({ // Customer / Entity Info @@ -78,15 +39,3 @@ export const CheckoutParamsV1Schema = ExtCheckoutParamsV1Schema.extend({ }); export type CheckoutParamsV1 = z.infer; - -// // Override free_trial to support CreateFreeTrialSchema -// free_trial: CreateFreeTrialSchema.or(z.boolean()).optional(), - -// // New Version -// version: z.number().optional(), - -// // Others -// metadata: z.any().optional(), -// billing_cycle_anchor: z.number().optional(), -// enable_product_immediately: z.boolean().optional(), -// finalize_invoice: z.boolean().optional(), diff --git a/shared/api/common/jsDocs.ts b/shared/api/common/jsDocs.ts index 3caeee90e..976327416 100644 --- a/shared/api/common/jsDocs.ts +++ b/shared/api/common/jsDocs.ts @@ -1,4 +1,3 @@ -import { ExtAttachBodySchema, ExtCheckoutParamsSchema } from "@api/models.js"; import { createJSDocDescription, docLink, @@ -13,6 +12,7 @@ import { QueryParamsSchema, SetupPaymentParamsSchema, } from "../core/coreOpModels.js"; +import { ExtAttachBodyV0Schema, ExtCheckoutParamsV0Schema } from "../models.js"; /** * Centralized JSDoc declarations for all core API methods. * These are used by the OpenAPI spec generator and propagate to SDK documentation. @@ -23,7 +23,7 @@ export const attachJsDoc = createJSDocDescription({ "Enables a product for a customer and processes payment if their payment method is already on file.", whenToUse: "Use this when the customer already has a payment method saved. For new customers without payment info, use `checkout` instead.", - body: ExtAttachBodySchema, + body: ExtAttachBodyV0Schema, examples: [ example({ values: { @@ -47,7 +47,7 @@ export const checkoutJsDoc = createJSDocDescription({ "Creates a checkout session for a customer to purchase a product with payment collection.", whenToUse: "Use this for new customers or when payment info is needed. For customers with existing payment methods, use `attach` instead.", - body: ExtCheckoutParamsSchema, + body: ExtCheckoutParamsV0Schema, examples: [ example({ values: { diff --git a/shared/api/core/checkoutModels.ts b/shared/api/core/checkoutModels.ts deleted file mode 100644 index 5c0742e0a..000000000 --- a/shared/api/core/checkoutModels.ts +++ /dev/null @@ -1,45 +0,0 @@ -// import { ApiProductItemSchema } from "@api/products/planFeature/previousVersions/apiProductItem.js"; -// import { ApiProductSchema } from "@api/products/previousVersions/apiProduct.js"; -// import { FeatureOptionsSchema } from "@models/cusProductModels/cusProductModels.js"; -// import { z } from "zod/v4"; -// import { AttachBodySchema, ExtAttachBodySchema } from "./attachModels.js"; - -// export const ExtCheckoutParamsSchema = ExtAttachBodySchema.extend({ -// setup_payment: z.boolean().optional(), -// }).meta({ -// description: -// "Returns a Stripe Checkout URL for the customer to make a payment, or returns payment confirmation information.", -// }); - -// export const CheckoutParamsSchema = AttachBodySchema.extend({ -// // skip_checkout: z.boolean().optional(), -// setup_payment: z.boolean().optional(), -// }); - -// // RESULT -// export const CheckoutLineSchema = z.object({ -// description: z.string(), -// amount: z.number(), -// item: ApiProductItemSchema.nullish(), -// }); - -// export const CheckoutResponseSchema = z.object({ -// url: z.string().nullish(), -// customer_id: z.string(), -// lines: z.array(CheckoutLineSchema), -// product: ApiProductSchema.nullish(), -// current_product: ApiProductSchema.nullish(), -// options: z.array(FeatureOptionsSchema).nullish(), -// total: z.number().nullish(), -// currency: z.string().nullish(), -// has_prorations: z.boolean().nullish(), -// next_cycle: z -// .object({ -// starts_at: z.number(), -// total: z.number(), -// }) -// .nullish(), -// }); - -// export type CheckoutLine = z.infer; -// export type CheckoutParams = z.infer; diff --git a/shared/api/core/coreOpenApi.ts b/shared/api/core/coreOpenApi.ts deleted file mode 100644 index 834d913e5..000000000 --- a/shared/api/core/coreOpenApi.ts +++ /dev/null @@ -1,213 +0,0 @@ -// import { -// AttachResultSchema, -// CheckoutResponseSchema, -// ExtAttachBodySchema, -// ExtCheckoutParamsSchema, -// } from "@api/models.js"; -// import type { ZodOpenApiPathsObject } from "zod-openapi"; -// import { SetUsageParamsSchema } from "../balances/usageModels.js"; -// import { SuccessResponseSchema } from "../common/commonResponses.js"; -// import { -// attachJsDoc, -// billingPortalJsDoc, -// cancelJsDoc, -// checkoutJsDoc, -// queryJsDoc, -// setUsageJsDoc, -// setupPaymentJsDoc, -// } from "../common/jsDocs.js"; -// // import { CheckParamsSchema, CheckResultSchema } from "./checkModels.js"; -// import { -// BillingPortalParamsSchema, -// BillingPortalResultSchema, -// CancelBodySchema, -// CancelResultSchema, -// QueryParamsSchema, -// QueryResultSchema, -// SetupPaymentParamsSchema, -// SetupPaymentResultSchema, -// } from "./coreOpModels.js"; - -// export const coreOps: ZodOpenApiPathsObject = { -// "/attach": { -// post: { -// summary: "Attach Product", -// description: attachJsDoc, - -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { -// schema: ExtAttachBodySchema, -// examples: { -// basic: { -// summary: "Attach a product immediately", -// description: -// "Enable a product for a customer with immediate activation", -// value: { -// customer_id: "cus_123", -// product_id: "pro_plan", -// }, -// }, -// }, -// }, -// }, -// }, -// responses: { -// "200": { -// description: "Product attached successfully", -// content: { -// "application/json": { -// schema: AttachResultSchema, -// }, -// }, -// }, -// }, -// }, -// }, -// "/checkout": { -// post: { -// summary: "Checkout", -// description: checkoutJsDoc, -// tags: ["core"], -// requestBody: { -// content: { "application/json": { schema: ExtCheckoutParamsSchema } }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { "application/json": { schema: CheckoutResponseSchema } }, -// }, -// }, -// }, -// }, -// "/cancel": { -// post: { -// summary: "Cancel Product", -// description: cancelJsDoc, -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { schema: CancelBodySchema }, -// }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { "application/json": { schema: CancelResultSchema } }, -// }, -// }, -// }, -// }, -// // "/track": { -// // post: { -// // summary: "Track Event", -// // description: trackJsDoc, -// // tags: ["core"], -// // requestBody: { -// // content: { -// // "application/json": { schema: TrackParamsSchema }, -// // }, -// // }, -// // responses: { -// // "200": { -// // description: "200 OK", -// // content: { "application/json": { schema: TrackResponseSchema } }, -// // }, -// // }, -// // }, -// // }, -// "/query": { -// post: { -// summary: "Query Analytics", -// description: queryJsDoc, -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { schema: QueryParamsSchema }, -// }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { "application/json": { schema: QueryResultSchema } }, -// }, -// }, -// }, -// }, -// // "/check": { -// // post: { -// // summary: "Check Feature Access", -// // description: checkJsDoc, -// // tags: ["core"], -// // requestBody: { -// // content: { -// // "application/json": { schema: CheckParamsSchema }, -// // }, -// // }, -// // responses: { -// // "200": { -// // description: "200 OK", -// // content: { "application/json": { schema: CheckResultSchema } }, -// // }, -// // }, -// // }, -// // }, -// "/setup_payment": { -// post: { -// summary: "Setup Payment Method", -// description: setupPaymentJsDoc, -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { schema: SetupPaymentParamsSchema }, -// }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { "application/json": { schema: SetupPaymentResultSchema } }, -// }, -// }, -// }, -// }, -// "/billing_portal": { -// post: { -// summary: "Create Billing Portal Session", -// description: billingPortalJsDoc, -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { schema: BillingPortalParamsSchema }, -// }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { -// "application/json": { schema: BillingPortalResultSchema }, -// }, -// }, -// }, -// }, -// }, - -// "/usage": { -// post: { -// summary: "Set Usage", -// description: setUsageJsDoc, -// tags: ["core"], -// requestBody: { -// content: { -// "application/json": { schema: SetUsageParamsSchema }, -// }, -// }, -// responses: { -// "200": { -// description: "200 OK", -// content: { "application/json": { schema: SuccessResponseSchema } }, -// }, -// }, -// }, -// }, -// }; diff --git a/shared/models/cusModels/cusExpand.ts b/shared/models/cusModels/cusExpand.ts index b7ba41458..50b887f22 100644 --- a/shared/models/cusModels/cusExpand.ts +++ b/shared/models/cusModels/cusExpand.ts @@ -6,7 +6,7 @@ export enum CusExpandV0 { Entities = "entities", Referrals = "referrals", PaymentMethod = "payment_method", - UpcomingInvoice = "upcoming_invoice", + // UpcomingInvoice = "upcoming_invoice", } // New customer expand options!