chore: fixes to http and request types for payments (#13830)

This commit is contained in:
Shahed Nasser
2025-10-28 11:09:24 +02:00
committed by GitHub
parent 83f2d87fa5
commit 64c5019b3b
14 changed files with 55 additions and 39 deletions

View File

@@ -15,11 +15,11 @@ export interface AdminRefundPayment {
/**
* The ID of the refund's reason.
*/
refund_reason_id?: string | null
refund_reason_id?: string
/**
* A note to attach to the refund.
*/
note?: string | null
note?: string
}
export interface AdminCreatePaymentCollection {
@@ -28,10 +28,9 @@ export interface AdminCreatePaymentCollection {
*/
order_id: string
/**
* The payment collection's amount. If not specified,
* the order's total is used as the amount instead.
* The payment collection's amount.
*/
amount?: number
amount: number
}
export interface AdminMarkPaymentCollectionAsPaid {

View File

@@ -1,9 +1,10 @@
import { FindParams } from "../../common"
import {
BasePaymentCollectionFilters,
BasePaymentSessionFilters,
} from "../common"
export interface StorePaymentProviderFilters {
export interface StorePaymentProviderFilters extends FindParams {
/**
* The ID of the region to retrieve its payment providers.
*/

View File

@@ -1,14 +1,9 @@
import { BaseFilterable, OperatorMap } from "../../../dal"
import { BaseFilterable } from "../../../dal"
import { SelectParams } from "../../common"
import { BaseRefundReasonListParams } from "../common"
export interface AdminRefundReasonListParams
extends BaseRefundReasonListParams,
BaseFilterable<AdminRefundReasonListParams> {
/**
* Apply filters on the refund reason's deletion date.
*/
deleted_at?: OperatorMap<string>
}
BaseFilterable<AdminRefundReasonListParams> {}
export interface AdminRefundReasonParams extends SelectParams {}

View File

@@ -47,14 +47,6 @@ export interface BaseRefundReasonListParams extends FindParams {
* Filter by refund reason ID(s).
*/
id?: string | string[]
/**
* Filter by label(s).
*/
label?: string | OperatorMap<string>
/**
* Filter by description(s).
*/
description?: string | OperatorMap<string>
/**
* Filter by parent refund reason ID(s).
*/
@@ -67,4 +59,8 @@ export interface BaseRefundReasonListParams extends FindParams {
* Filter by update date.
*/
updated_at?: OperatorMap<string>
/**
* Apply filters on the refund reason's deletion date.
*/
deleted_at?: OperatorMap<string>
}

View File

@@ -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

View File

@@ -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({

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
),
],

View File

@@ -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 {

View File

@@ -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
>

View File

@@ -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

View File

@@ -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)