feat: Refund payment (#6610)
Essentially the same as #6601 but for refunds
This commit is contained in:
@@ -1 +1,3 @@
|
||||
export * from "./capture-payment"
|
||||
export * from "./refund-payment"
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type StepInput = {
|
||||
payment_id: string
|
||||
created_by?: string
|
||||
amount?: number
|
||||
}
|
||||
|
||||
export const refundPaymentStepId = "refund-payment-step"
|
||||
export const refundPaymentStep = createStep(
|
||||
refundPaymentStepId,
|
||||
async (input: StepInput, { container }) => {
|
||||
const paymentModule = container.resolve<IPaymentModuleService>(
|
||||
ModuleRegistrationName.PAYMENT
|
||||
)
|
||||
|
||||
const payment = await paymentModule.refundPayment(input)
|
||||
|
||||
return new StepResponse(payment)
|
||||
}
|
||||
)
|
||||
@@ -1 +1,3 @@
|
||||
export * from "./capture-payment"
|
||||
export * from "./refund-payment"
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { refundPaymentStep } from "../steps/refund-payment"
|
||||
|
||||
export const refundPaymentWorkflowId = "refund-payment-workflow"
|
||||
export const refundPaymentWorkflow = createWorkflow(
|
||||
refundPaymentWorkflowId,
|
||||
(
|
||||
input: WorkflowData<{
|
||||
payment_id: string
|
||||
created_by?: string
|
||||
amount?: number
|
||||
}>
|
||||
) => {
|
||||
const payment = refundPaymentStep(input)
|
||||
return payment
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user