diff --git a/.changeset/sixty-peaches-hug.md b/.changeset/sixty-peaches-hug.md new file mode 100644 index 0000000000..7ee7546002 --- /dev/null +++ b/.changeset/sixty-peaches-hug.md @@ -0,0 +1,5 @@ +--- +"@medusajs/core-flows": patch +--- + +fix(core-flows): return refunded when all captured payments have been refunded 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 3b5585dfa5..94abf727ae 100644 --- a/packages/core/core-flows/src/order/utils/aggregate-status.ts +++ b/packages/core/core-flows/src/order/utils/aggregate-status.ts @@ -55,7 +55,10 @@ export const getLastPaymentStatus = (order: OrderDetailDTO) => { } if (paymentStatus[PaymentStatus.REFUNDED] > 0) { - if (paymentStatus[PaymentStatus.REFUNDED] === totalPaymentExceptCanceled) { + if ( + paymentStatus[PaymentStatus.REFUNDED] === + paymentStatus[PaymentStatus.CAPTURED] + ) { return PaymentStatus.REFUNDED }