From 5afd5a2de346de146ddf4976a80fde384fd6937b Mon Sep 17 00:00:00 2001 From: John Yeo Date: Mon, 23 Feb 2026 11:21:28 +0000 Subject: [PATCH] chore: added setup payment v1 params --- server/src/external/autumn/autumnCli.ts | 4 ++-- server/src/internal/billing/handlers/handleSetupPayment.ts | 5 +++-- server/src/internal/customers/cusProducts/repos/index.ts | 2 +- shared/api/billing/setupPayment/setupPaymentParamsV0.ts | 7 ++++++- shared/api/models.ts | 1 + 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/server/src/external/autumn/autumnCli.ts b/server/src/external/autumn/autumnCli.ts index f2cd18ab5..2cf1520c7 100644 --- a/server/src/external/autumn/autumnCli.ts +++ b/server/src/external/autumn/autumnCli.ts @@ -30,7 +30,7 @@ import { type ProductItem, type RewardRedemption, type SetUsageParams, - type SetupPaymentParams, + type SetupPaymentParamsV0, type TrackParams, type UpdateBalanceParamsV0, type UpdateSubscriptionV0Params, @@ -908,7 +908,7 @@ export class AutumnInt { return data; }, - setupPayment: async (params: SetupPaymentParams) => { + setupPayment: async (params: SetupPaymentParamsV0) => { const data = await this.post(`/setup_payment`, params); return data; }, diff --git a/server/src/internal/billing/handlers/handleSetupPayment.ts b/server/src/internal/billing/handlers/handleSetupPayment.ts index c98d8c4e2..f8ba3afa4 100644 --- a/server/src/internal/billing/handlers/handleSetupPayment.ts +++ b/server/src/internal/billing/handlers/handleSetupPayment.ts @@ -1,8 +1,9 @@ import { AffectedResource, ErrCode, - SetupPaymentParamsSchema, + SetupPaymentParamsV0Schema, } from "@autumn/shared"; + import { createStripeCli } from "@/external/connect/createStripeCli.js"; import { getOrCreateStripeCustomer } from "@/external/stripe/customers"; import { createRoute } from "@/honoMiddlewares/routeHandler.js"; @@ -11,7 +12,7 @@ import RecaseError from "@/utils/errorUtils.js"; import { getOrCreateCustomer } from "../../customers/cusUtils/getOrCreateCustomer.js"; export const handleSetupPayment = createRoute({ - body: SetupPaymentParamsSchema, + body: SetupPaymentParamsV0Schema, resource: AffectedResource.Customer, handler: async (c) => { const ctx = c.get("ctx"); diff --git a/server/src/internal/customers/cusProducts/repos/index.ts b/server/src/internal/customers/cusProducts/repos/index.ts index aa135f8bb..338b6637b 100644 --- a/server/src/internal/customers/cusProducts/repos/index.ts +++ b/server/src/internal/customers/cusProducts/repos/index.ts @@ -1,4 +1,4 @@ -import { batchUpdateCustomerProducts } from "@/internal/customers/cusProducts/repos/batchUpdteCustomerProducts"; +import { batchUpdateCustomerProducts } from "./batchUpdateCustomerProducts"; export const customerProductRepo = { batchUpdate: batchUpdateCustomerProducts, diff --git a/shared/api/billing/setupPayment/setupPaymentParamsV0.ts b/shared/api/billing/setupPayment/setupPaymentParamsV0.ts index 8074509a5..836528de9 100644 --- a/shared/api/billing/setupPayment/setupPaymentParamsV0.ts +++ b/shared/api/billing/setupPayment/setupPaymentParamsV0.ts @@ -1,7 +1,7 @@ import { z } from "zod/v4"; import { CustomerDataSchema } from "../../common/customerData"; -export const SetupPaymentParamsSchema = z.object({ +export const SetupPaymentParamsV0Schema = z.object({ customer_id: z.string().meta({ description: "The ID of the customer", }), @@ -25,3 +25,8 @@ export const SetupPaymentResponseV0Schema = z.object({ description: "URL to the payment setup page", }), }); + +export type SetupPaymentParamsV0 = z.infer; +export type SetupPaymentResponseV0 = z.infer< + typeof SetupPaymentResponseV0Schema +>; diff --git a/shared/api/models.ts b/shared/api/models.ts index e7f2a2f4c..108ce0280 100644 --- a/shared/api/models.ts +++ b/shared/api/models.ts @@ -51,6 +51,7 @@ export * from "./balances/track/trackResponseV2.js"; export * from "./balances/track/trackResponseV3.js"; export * from "./balances/update/updateBalanceParams.js"; export * from "./balances/usageModels.js"; +export * from "./billing"; // Billing export * from "./billing/index.js"; export * from "./common/customerData.js";