Skip to content

Commit 990691e

Browse files
chore(medusa): do not use transaction id on cart operations (medusajs#13931)
1 parent 224ab39 commit 990691e

File tree

17 files changed

+36
-25
lines changed

17 files changed

+36
-25
lines changed

.changeset/red-pants-raise.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/core-flows": patch
3+
"@medusajs/medusa": patch
4+
---
5+
6+
chore(medusa): do not use transactionId for cart operations

integration-tests/http/__tests__/cart/store/cart.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ medusaIntegrationTestRunner({
19221922
expect(res.data.order).toEqual(successData)
19231923
}
19241924

1925-
expect(failure.length).toBeGreaterThan(0)
1925+
expect(failure.length).toBe(0)
19261926

19271927
expect(successData).toEqual(
19281928
expect.objectContaining({

packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from "@medusajs/framework/workflows-sdk"
1111
import { useQueryGraphStep } from "../../common"
1212
import { acquireLockStep, releaseLockStep } from "../../locking"
13-
import { updateLineItemsStep } from "../steps"
13+
import { updateLineItemsStep, validateCartStep } from "../steps"
1414
import { cartFieldsForRefreshSteps } from "../utils/fields"
1515
import { pricingContextResult } from "../utils/schemas"
1616
import { getVariantsAndItemsWithPrices } from "./get-variants-and-items-with-prices"
@@ -155,6 +155,8 @@ export const refreshCartItemsWorkflow = createWorkflow(
155155
},
156156
})
157157

158+
validateCartStep({ cart })
159+
158160
const { lineItems } = getVariantsAndItemsWithPrices.runAsStep({
159161
input: {
160162
cart,

packages/core/core-flows/src/cart/workflows/refresh-cart-shipping-methods.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { AdditionalData } from "@medusajs/types"
1212
import { useQueryGraphStep } from "../../common"
1313
import { acquireLockStep, releaseLockStep } from "../../locking"
14-
import { removeShippingMethodFromCartStep } from "../steps"
14+
import { removeShippingMethodFromCartStep, validateCartStep } from "../steps"
1515
import { updateShippingMethodsStep } from "../steps/update-shipping-methods"
1616
import { listShippingOptionsForCartWithPricingWorkflow } from "./list-shipping-options-for-cart-with-pricing"
1717

@@ -109,6 +109,8 @@ export const refreshCartShippingMethodsWorkflow = createWorkflow(
109109
return fetchCart ?? input.cart
110110
})
111111

112+
validateCartStep({ cart })
113+
112114
acquireLockStep({
113115
key: cart.id,
114116
timeout: 2,

packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useQueryGraphStep } from "../../common"
1212
import { acquireLockStep, releaseLockStep } from "../../locking"
1313
import { updatePaymentCollectionStep } from "../../payment-collection"
1414
import { deletePaymentSessionsWorkflow } from "../../payment-collection/workflows/delete-payment-sessions"
15+
import { validateCartStep } from "../steps"
1516

1617
/**
1718
* The details of the cart to refresh.
@@ -107,6 +108,8 @@ export const refreshPaymentCollectionForCartWorkflow = createWorkflow(
107108
return fetchCart ?? input.cart
108109
})
109110

111+
validateCartStep({ cart })
112+
110113
acquireLockStep({
111114
key: cart.id,
112115
timeout: 2,

packages/core/core-flows/src/cart/workflows/update-cart-promotions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
prepareAdjustmentsFromPromotionActionsStep,
1919
removeLineItemAdjustmentsStep,
2020
removeShippingMethodAdjustmentsStep,
21+
validateCartStep,
2122
} from "../steps"
2223
import { updateCartPromotionsStep } from "../steps/update-cart-promotions"
2324
import { cartFieldsForRefreshSteps } from "../utils/fields"
@@ -96,6 +97,8 @@ export const updateCartPromotionsWorkflow = createWorkflow(
9697
return input.cart ?? fetchCart
9798
})
9899

100+
validateCartStep({ cart })
101+
99102
acquireLockStep({
100103
key: cart.id,
101104
timeout: 2,

packages/core/core-flows/src/cart/workflows/update-cart.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
findOrCreateCustomerStep,
2525
findSalesChannelStep,
2626
updateCartsStep,
27+
validateCartStep,
2728
} from "../steps"
2829
import { validateSalesChannelStep } from "../steps/validate-sales-channel"
2930
import { refreshCartItemsWorkflow } from "./refresh-cart-items"
@@ -111,6 +112,8 @@ export const updateCartWorkflow = createWorkflow(
111112
},
112113
}).config({ name: "get-cart" })
113114

115+
validateCartStep({ cart: cartToUpdate })
116+
114117
const cartDataInput = transform(
115118
{ input, cartToUpdate },
116119
(data: { input: UpdateCartWorkflowInput; cartToUpdate: CartDTO }) => {

packages/core/core-flows/src/cart/workflows/update-tax-lines.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { useQueryGraphStep } from "../../common"
1212
import { acquireLockStep, releaseLockStep } from "../../locking"
1313
import { getItemTaxLinesStep } from "../../tax/steps/get-item-tax-lines"
14-
import { setTaxLinesForItemsStep } from "../steps"
14+
import { setTaxLinesForItemsStep, validateCartStep } from "../steps"
1515

1616
const cartFields = [
1717
"id",
@@ -144,6 +144,8 @@ export const updateTaxLinesWorkflow = createWorkflow(
144144
return input.cart ?? fetchCart
145145
})
146146

147+
validateCartStep({ cart })
148+
147149
acquireLockStep({
148150
key: cart.id,
149151
timeout: 2,

packages/core/core-flows/src/cart/workflows/upsert-tax-lines.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "@medusajs/framework/workflows-sdk"
1111
import { useQueryGraphStep } from "../../common"
1212
import { getItemTaxLinesStep } from "../../tax/steps/get-item-tax-lines"
13+
import { validateCartStep } from "../steps"
1314
import { upsertTaxLinesForItemsStep } from "../steps/upsert-tax-lines-for-items"
1415

1516
const cartFields = [
@@ -141,6 +142,8 @@ export const upsertTaxLinesWorkflow = createWorkflow(
141142
return input.cart ?? fetchCart
142143
})
143144

145+
validateCartStep({ cart })
146+
144147
const taxLineItems = getItemTaxLinesStep(
145148
transform({ input, cart }, (data) => ({
146149
orderOrCart: data.cart,

packages/core/core-flows/src/payment/steps/complete-cart-after-payment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const completeCartAfterPaymentStep = createStep(
2525
input: {
2626
id: input.cart_id,
2727
},
28-
transactionId: input.cart_id,
2928
})
3029
}
3130
)

0 commit comments

Comments
 (0)