fix(core-flows): missing variable of when condition (#10958)
This commit is contained in:
1 parent
65bf6e4fce
commit
c5a207144e
2 files changed
+12
-4
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(core-flows): process payment capture condition
|
||||||
@@ -2,9 +2,9 @@ import { WebhookActionResult } from "@medusajs/types"
|
|||||||
import { PaymentActions } from "@medusajs/utils"
|
import { PaymentActions } from "@medusajs/utils"
|
||||||
import { createWorkflow, when } from "@medusajs/workflows-sdk"
|
import { createWorkflow, when } from "@medusajs/workflows-sdk"
|
||||||
import { completeCartWorkflow } from "../../cart/workflows/complete-cart"
|
import { completeCartWorkflow } from "../../cart/workflows/complete-cart"
|
||||||
|
import { useQueryGraphStep } from "../../common"
|
||||||
import { authorizePaymentSessionStep } from "../steps"
|
import { authorizePaymentSessionStep } from "../steps"
|
||||||
import { capturePaymentWorkflow } from "./capture-payment"
|
import { capturePaymentWorkflow } from "./capture-payment"
|
||||||
import { useQueryGraphStep } from "../../common"
|
|
||||||
|
|
||||||
interface ProcessPaymentWorkflowInput extends WebhookActionResult {}
|
interface ProcessPaymentWorkflowInput extends WebhookActionResult {}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ export const processPaymentWorkflow = createWorkflow(
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when({ input }, ({ input }) => {
|
when({ input, paymentData }, ({ input, paymentData }) => {
|
||||||
return (
|
return (
|
||||||
input.action === PaymentActions.SUCCESSFUL && !!paymentData.data.length
|
input.action === PaymentActions.SUCCESSFUL && !!paymentData.data.length
|
||||||
)
|
)
|
||||||
@@ -66,7 +66,9 @@ export const processPaymentWorkflow = createWorkflow(
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
when({ input }, ({ input }) => {
|
when(
|
||||||
|
{ input, cartPaymentCollection },
|
||||||
|
({ input, cartPaymentCollection }) => {
|
||||||
// Authorize payment session if no Cart is linked to the payment
|
// Authorize payment session if no Cart is linked to the payment
|
||||||
// When associated with a Cart, the complete cart workflow will handle the authorization
|
// When associated with a Cart, the complete cart workflow will handle the authorization
|
||||||
return (
|
return (
|
||||||
@@ -74,7 +76,8 @@ export const processPaymentWorkflow = createWorkflow(
|
|||||||
input.action === PaymentActions.AUTHORIZED &&
|
input.action === PaymentActions.AUTHORIZED &&
|
||||||
!!input.data?.session_id
|
!!input.data?.session_id
|
||||||
)
|
)
|
||||||
}).then(() => {
|
}
|
||||||
|
).then(() => {
|
||||||
authorizePaymentSessionStep({
|
authorizePaymentSessionStep({
|
||||||
id: input.data!.session_id,
|
id: input.data!.session_id,
|
||||||
context: {},
|
context: {},
|
||||||
|
|||||||
Reference in new issue
Block a user