chore: fixes to http and request types for payments (#13830)
This commit is contained in:
1 parent
83f2d87fa5
commit
64c5019b3b
14 files changed
+55
-39
No files matched your search
@@ -15,11 +15,11 @@ export interface AdminRefundPayment {
|
|||||||
/**
|
/**
|
||||||
* The ID of the refund's reason.
|
* The ID of the refund's reason.
|
||||||
*/
|
*/
|
||||||
refund_reason_id?: string | null
|
refund_reason_id?: string
|
||||||
/**
|
/**
|
||||||
* A note to attach to the refund.
|
* A note to attach to the refund.
|
||||||
*/
|
*/
|
||||||
note?: string | null
|
note?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminCreatePaymentCollection {
|
export interface AdminCreatePaymentCollection {
|
||||||
@@ -28,10 +28,9 @@ export interface AdminCreatePaymentCollection {
|
|||||||
*/
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
/**
|
/**
|
||||||
* The payment collection's amount. If not specified,
|
* The payment collection's amount.
|
||||||
* the order's total is used as the amount instead.
|
|
||||||
*/
|
*/
|
||||||
amount?: number
|
amount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminMarkPaymentCollectionAsPaid {
|
export interface AdminMarkPaymentCollectionAsPaid {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import { FindParams } from "../../common"
|
||||||
import {
|
import {
|
||||||
BasePaymentCollectionFilters,
|
BasePaymentCollectionFilters,
|
||||||
BasePaymentSessionFilters,
|
BasePaymentSessionFilters,
|
||||||
} from "../common"
|
} from "../common"
|
||||||
|
|
||||||
export interface StorePaymentProviderFilters {
|
export interface StorePaymentProviderFilters extends FindParams {
|
||||||
/**
|
/**
|
||||||
* The ID of the region to retrieve its payment providers.
|
* The ID of the region to retrieve its payment providers.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { BaseFilterable, OperatorMap } from "../../../dal"
|
import { BaseFilterable } from "../../../dal"
|
||||||
import { SelectParams } from "../../common"
|
import { SelectParams } from "../../common"
|
||||||
import { BaseRefundReasonListParams } from "../common"
|
import { BaseRefundReasonListParams } from "../common"
|
||||||
|
|
||||||
export interface AdminRefundReasonListParams
|
export interface AdminRefundReasonListParams
|
||||||
extends BaseRefundReasonListParams,
|
extends BaseRefundReasonListParams,
|
||||||
BaseFilterable<AdminRefundReasonListParams> {
|
BaseFilterable<AdminRefundReasonListParams> {}
|
||||||
/**
|
|
||||||
* Apply filters on the refund reason's deletion date.
|
|
||||||
*/
|
|
||||||
deleted_at?: OperatorMap<string>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminRefundReasonParams extends SelectParams {}
|
export interface AdminRefundReasonParams extends SelectParams {}
|
||||||
@@ -47,14 +47,6 @@ export interface BaseRefundReasonListParams extends FindParams {
|
|||||||
* Filter by refund reason ID(s).
|
* Filter by refund reason ID(s).
|
||||||
*/
|
*/
|
||||||
id?: string | string[]
|
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).
|
* Filter by parent refund reason ID(s).
|
||||||
*/
|
*/
|
||||||
@@ -67,4 +59,8 @@ export interface BaseRefundReasonListParams extends FindParams {
|
|||||||
* Filter by update date.
|
* Filter by update date.
|
||||||
*/
|
*/
|
||||||
updated_at?: OperatorMap<string>
|
updated_at?: OperatorMap<string>
|
||||||
|
/**
|
||||||
|
* Apply filters on the refund reason's deletion date.
|
||||||
|
*/
|
||||||
|
deleted_at?: OperatorMap<string>
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,12 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { AdminMarkPaymentCollectionPaidType } from "../../validators"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminMarkPaymentCollectionPaidType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminMarkPaymentCollectionAsPaid,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -5,14 +5,16 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { AdminCreatePaymentCollectionType } from "./validators"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentCollectionType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreatePaymentCollection,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
res: MedusaResponse<HttpTypes.AdminPaymentCollectionResponse>
|
||||||
) => {
|
) => {
|
||||||
const { result } = await createOrderPaymentCollectionWorkflow(req.scope).run({
|
const { result } = await createOrderPaymentCollectionWorkflow(req.scope).run({
|
||||||
input: req.body,
|
input: req.validatedBody,
|
||||||
})
|
})
|
||||||
|
|
||||||
const paymentCollection = await refetchEntity({
|
const paymentCollection = await refetchEntity({
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { refetchPayment } from "../../helpers"
|
import { refetchPayment } from "../../helpers"
|
||||||
import { AdminCreatePaymentCaptureType } from "../../validators"
|
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentCaptureType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCapturePayment,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { refetchPayment } from "../../helpers"
|
import { refetchPayment } from "../../helpers"
|
||||||
import { AdminCreatePaymentRefundType } from "../../validators"
|
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentRefundType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminRefundPayment,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { AdminUpdatePaymentRefundReasonType } from "../validators"
|
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest<HttpTypes.AdminRefundReasonParams>,
|
||||||
res: MedusaResponse<RefundReasonResponse>
|
res: MedusaResponse<RefundReasonResponse>
|
||||||
) => {
|
) => {
|
||||||
const refund_reason = await refetchEntity({
|
const refund_reason = await refetchEntity({
|
||||||
@@ -25,7 +24,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminUpdatePaymentRefundReasonType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateRefundReason,
|
||||||
|
HttpTypes.AdminRefundReasonParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<RefundReasonResponse>
|
res: MedusaResponse<RefundReasonResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
import * as queryConfig from "./query-config"
|
import * as queryConfig from "./query-config"
|
||||||
import {
|
import {
|
||||||
AdminCreatePaymentRefundReason,
|
AdminCreatePaymentRefundReason,
|
||||||
|
AdminGetRefundReasonParams,
|
||||||
AdminGetRefundReasonsParams,
|
AdminGetRefundReasonsParams,
|
||||||
AdminUpdatePaymentRefundReason,
|
AdminUpdatePaymentRefundReason,
|
||||||
} from "./validators"
|
} from "./validators"
|
||||||
@@ -38,7 +39,7 @@ export const adminRefundReasonsRoutesMiddlewares: MiddlewareRoute[] = [
|
|||||||
middlewares: [
|
middlewares: [
|
||||||
validateAndTransformBody(AdminUpdatePaymentRefundReason),
|
validateAndTransformBody(AdminUpdatePaymentRefundReason),
|
||||||
validateAndTransformQuery(
|
validateAndTransformQuery(
|
||||||
AdminGetRefundReasonsParams,
|
AdminGetRefundReasonParams,
|
||||||
queryConfig.retrieveTransformQueryConfig
|
queryConfig.retrieveTransformQueryConfig
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
refetchEntity,
|
refetchEntity,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import {
|
import {
|
||||||
AdminCreateRefundReason,
|
|
||||||
HttpTypes,
|
HttpTypes,
|
||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
RefundReasonResponse,
|
RefundReasonResponse,
|
||||||
@@ -34,7 +33,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateRefundReason>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateRefundReason,
|
||||||
|
HttpTypes.AdminRefundReasonParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<RefundReasonResponse>
|
res: MedusaResponse<RefundReasonResponse>
|
||||||
) => {
|
) => {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { createFindParams, createOperatorMap } from "../../utils/validators"
|
import { createFindParams, createOperatorMap, createSelectParams } from "../../utils/validators"
|
||||||
|
|
||||||
export type AdminCreatePaymentRefundReasonType = z.infer<
|
export type AdminCreatePaymentRefundReasonType = z.infer<
|
||||||
typeof AdminCreatePaymentRefundReason
|
typeof AdminCreatePaymentRefundReason
|
||||||
@@ -41,3 +41,9 @@ export const AdminGetRefundReasonsParams = createFindParams({
|
|||||||
export type AdminGetRefundReasonsParamsType = z.infer<
|
export type AdminGetRefundReasonsParamsType = z.infer<
|
||||||
typeof AdminGetRefundReasonsParams
|
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"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreInitializePaymentSession>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreInitializePaymentSession,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
||||||
) => {
|
) => {
|
||||||
const collectionId = req.params.id
|
const collectionId = req.params.id
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {
|
|||||||
import { Modules } from "@medusajs/utils"
|
import { Modules } from "@medusajs/utils"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreatePaymentCollection>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreCreatePaymentCollection,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|||||||
Reference in new issue
Block a user