chore: fixes to http and request types for payments (#13830)
This commit is contained in:
@@ -5,10 +5,12 @@ import {
|
||||
MedusaResponse,
|
||||
refetchEntity,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminMarkPaymentCollectionPaidType } from "../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminMarkPaymentCollectionPaidType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminMarkPaymentCollectionAsPaid,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -5,14 +5,16 @@ import {
|
||||
MedusaResponse,
|
||||
refetchEntity,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminCreatePaymentCollectionType } from "./validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentCollectionType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreatePaymentCollection,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
||||
) => {
|
||||
const { result } = await createOrderPaymentCollectionWorkflow(req.scope).run({
|
||||
input: req.body,
|
||||
input: req.validatedBody,
|
||||
})
|
||||
|
||||
const paymentCollection = await refetchEntity({
|
||||
|
||||
@@ -4,11 +4,13 @@ import {
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refetchPayment } from "../../helpers"
|
||||
import { AdminCreatePaymentCaptureType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentCaptureType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCapturePayment,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -4,11 +4,13 @@ import {
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refetchPayment } from "../../helpers"
|
||||
import { AdminCreatePaymentRefundType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentRefundType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminRefundPayment,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -8,10 +8,9 @@ import {
|
||||
MedusaResponse,
|
||||
refetchEntity,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminUpdatePaymentRefundReasonType } from "../validators"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminRefundReasonParams>,
|
||||
res: MedusaResponse<RefundReasonResponse>
|
||||
) => {
|
||||
const refund_reason = await refetchEntity({
|
||||
@@ -25,7 +24,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdatePaymentRefundReasonType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateRefundReason,
|
||||
HttpTypes.AdminRefundReasonParams
|
||||
>,
|
||||
res: MedusaResponse<RefundReasonResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import * as queryConfig from "./query-config"
|
||||
import {
|
||||
AdminCreatePaymentRefundReason,
|
||||
AdminGetRefundReasonParams,
|
||||
AdminGetRefundReasonsParams,
|
||||
AdminUpdatePaymentRefundReason,
|
||||
} from "./validators"
|
||||
@@ -38,7 +39,7 @@ export const adminRefundReasonsRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
middlewares: [
|
||||
validateAndTransformBody(AdminUpdatePaymentRefundReason),
|
||||
validateAndTransformQuery(
|
||||
AdminGetRefundReasonsParams,
|
||||
AdminGetRefundReasonParams,
|
||||
queryConfig.retrieveTransformQueryConfig
|
||||
),
|
||||
],
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
refetchEntity,
|
||||
} from "@medusajs/framework/http"
|
||||
import {
|
||||
AdminCreateRefundReason,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
RefundReasonResponse,
|
||||
@@ -34,7 +33,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateRefundReason>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateRefundReason,
|
||||
HttpTypes.AdminRefundReasonParams
|
||||
>,
|
||||
res: MedusaResponse<RefundReasonResponse>
|
||||
) => {
|
||||
const {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createOperatorMap } from "../../utils/validators"
|
||||
import { createFindParams, createOperatorMap, createSelectParams } from "../../utils/validators"
|
||||
|
||||
export type AdminCreatePaymentRefundReasonType = z.infer<
|
||||
typeof AdminCreatePaymentRefundReason
|
||||
@@ -41,3 +41,9 @@ export const AdminGetRefundReasonsParams = createFindParams({
|
||||
export type AdminGetRefundReasonsParamsType = z.infer<
|
||||
typeof AdminGetRefundReasonsParams
|
||||
>
|
||||
|
||||
export const AdminGetRefundReasonParams = createSelectParams()
|
||||
|
||||
export type AdminGetRefundReasonParamsType = z.infer<
|
||||
typeof AdminGetRefundReasonParams
|
||||
>
|
||||
@@ -7,7 +7,10 @@ import { refetchPaymentCollection } from "../../helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreInitializePaymentSession>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.StoreInitializePaymentSession,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
||||
) => {
|
||||
const collectionId = req.params.id
|
||||
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
import { Modules } from "@medusajs/utils"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreatePaymentCollection>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.StoreCreatePaymentCollection,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
Reference in New Issue
Block a user