diff --git a/.changeset/light-gorillas-play.md b/.changeset/light-gorillas-play.md new file mode 100644 index 0000000000..b7f7c19cc0 --- /dev/null +++ b/.changeset/light-gorillas-play.md @@ -0,0 +1,5 @@ +--- +"@medusajs/core-flows": patch +--- + +fix(core-flows): refresh payment collection using raw total diff --git a/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts b/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts index 6eb15c0295..e3c0d82c56 100644 --- a/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts +++ b/packages/core/core-flows/src/cart/workflows/refresh-payment-collection.ts @@ -120,7 +120,7 @@ export const refreshPaymentCollectionForCartWorkflow = createWorkflow( return { selector: { id: cart.payment_collection.id }, update: { - amount: cart.total, + amount: cart.raw_total, currency_code: cart.currency_code, }, } diff --git a/packages/core/core-flows/src/order/utils/aggregate-status.ts b/packages/core/core-flows/src/order/utils/aggregate-status.ts index 94abf727ae..d9afd14be0 100644 --- a/packages/core/core-flows/src/order/utils/aggregate-status.ts +++ b/packages/core/core-flows/src/order/utils/aggregate-status.ts @@ -26,7 +26,7 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => { (isDefined(paymentCollection.amount) && MathBN.eq(paymentCollection.amount, 0)) ) { - paymentStatus[PaymentStatus.CAPTURED] += MathBN.eq( + paymentStatus[PaymentStatus.CAPTURED] += MathBN.gte( paymentCollection.captured_amount as number, paymentCollection.amount ) @@ -35,7 +35,7 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => { } if (MathBN.gt(paymentCollection.refunded_amount ?? 0, 0)) { - paymentStatus[PaymentStatus.REFUNDED] += MathBN.eq( + paymentStatus[PaymentStatus.REFUNDED] += MathBN.gte( paymentCollection.refunded_amount as number, paymentCollection.amount )