feat: Capture payment (#6601)

* feat: Capture payment

* add amount to workflow input
This commit is contained in:
Oli Juhl
2024-03-07 11:02:26 +01:00
committed by GitHub
parent 12b035cb18
commit 3d0da980cf
23 changed files with 584 additions and 86 deletions
+5 -4
View File
@@ -1,13 +1,14 @@
export * from "./api-key"
export * from "./customer"
export * from "./customer-group"
export * from "./definition"
export * from "./definitions"
export * as Handlers from "./handlers"
export * from "./invite"
export * from "./payment"
export * from "./product"
export * from "./promotion"
export * from "./region"
export * from "./user"
export * from "./tax"
export * from "./api-key"
export * from "./store"
export * from "./product"
export * from "./tax"
export * from "./user"
+2
View File
@@ -0,0 +1,2 @@
export * from "./steps"
export * from "./workflows"
@@ -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
captured_by?: string
amount?: number
}
export const capturePaymentStepId = "capture-payment-step"
export const capturePaymentStep = createStep(
capturePaymentStepId,
async (input: StepInput, { container }) => {
const paymentModule = container.resolve<IPaymentModuleService>(
ModuleRegistrationName.PAYMENT
)
const payment = await paymentModule.capturePayment(input)
return new StepResponse(payment)
}
)
@@ -0,0 +1 @@
export * from "./capture-payment"
@@ -0,0 +1,18 @@
import { PaymentDTO } from "@medusajs/types"
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
import { capturePaymentStep } from "../steps/capture-payment"
export const capturePaymentWorkflowId = "capture-payment-workflow"
export const capturePaymentWorkflow = createWorkflow(
capturePaymentWorkflowId,
(
input: WorkflowData<{
payment_id: string
captured_by?: string
amount?: number
}>
): WorkflowData<PaymentDTO> => {
const payment = capturePaymentStep(input)
return payment
}
)
@@ -0,0 +1 @@
export * from "./capture-payment"