diff --git a/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-method.js b/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-method.js deleted file mode 100644 index 3c405175bd..0000000000 --- a/packages/medusa/src/api/routes/store/carts/__tests__/update-payment-method.js +++ /dev/null @@ -1,46 +0,0 @@ -import { IdMap } from "medusa-test-utils" -import { request } from "../../../../../helpers/test-request" -import { CartServiceMock } from "../../../../../services/__mocks__/cart" - -describe("POST /store/carts/:id/payment-method", () => { - describe("successfully sets the payment method", () => { - let subject - - beforeAll(async () => { - const cartId = IdMap.getId("cartWithPaySessions") - subject = await request("POST", `/store/carts/${cartId}/payment-method`, { - payload: { - provider_id: "default_provider", - data: { - money_id: "success", - }, - }, - }) - }) - - afterAll(() => { - jest.clearAllMocks() - }) - - it("calls CartService setPaymentMethod", () => { - expect(CartServiceMock.setPaymentMethod).toHaveBeenCalledTimes(1) - expect(CartServiceMock.setPaymentMethod).toHaveBeenCalledWith( - IdMap.getId("cartWithPaySessions"), - { - provider_id: "default_provider", - data: { - money_id: "success", - }, - } - ) - }) - - it("returns 200", () => { - expect(subject.status).toEqual(200) - }) - - it("returns the cart", () => { - expect(subject.body.cart.id).toEqual(IdMap.getId("cartWithPaySessions")) - }) - }) -}) diff --git a/packages/medusa/src/api/routes/store/carts/index.ts b/packages/medusa/src/api/routes/store/carts/index.ts index 6e42fb2269..9234a86ae9 100644 --- a/packages/medusa/src/api/routes/store/carts/index.ts +++ b/packages/medusa/src/api/routes/store/carts/index.ts @@ -82,11 +82,6 @@ export default (app, container) => { middlewares.wrap(require("./set-payment-session").default) ) - route.post( - "/:id/payment-method", - middlewares.wrap(require("./update-payment-method").default) - ) - // Shipping Options route.post( "/:id/shipping-methods", @@ -155,5 +150,4 @@ export * from "./create-payment-sessions" export * from "./set-payment-session" export * from "./update-cart" export * from "./update-line-item" -export * from "./update-payment-method" export * from "./update-payment-session" diff --git a/packages/medusa/src/api/routes/store/carts/update-payment-method.ts b/packages/medusa/src/api/routes/store/carts/update-payment-method.ts deleted file mode 100644 index 845f13ad8b..0000000000 --- a/packages/medusa/src/api/routes/store/carts/update-payment-method.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { IsOptional, IsString } from "class-validator" -import { defaultStoreCartFields, defaultStoreCartRelations } from "." -import { CartService } from "../../../../services" -import { validator } from "../../../../utils/validator" - -/** - * @oas [post] /store/carts/{id} - * operationId: PostCartsCartPaymentMethodUpdate - * summary: Update a Cart" - * description: "Updates a Cart." - * parameters: - * - (path) id=* {string} The id of the Cart. - * requestBody: - * content: - * application/json: - * schema: - * required: - * - provider_id - * properties: - * provider_id: - * type: string - * description: The id of the Payment Provider. - * data: - * type: object - * description: "" - * tags: - * - Cart - * responses: - * 200: - * description: OK - * content: - * application/json: - * schema: - * properties: - * cart: - * $ref: "#/components/schemas/cart" - */ -export default async (req, res) => { - const { id } = req.params - - const validated = await validator( - StorePostCartsCartPaymentMethodUpdateReq, - req.body - ) - - const cartService: CartService = req.scope.resolve("cartService") - - let cart = await cartService.setPaymentMethod(id, validated) - cart = await cartService.retrieve(id, { - select: defaultStoreCartFields, - relations: defaultStoreCartRelations, - }) - - res.status(200).json({ cart }) -} - -export class StorePostCartsCartPaymentMethodUpdateReq { - @IsString() - provider_id: string - - @IsOptional() - data?: object -}