Skip to content

[Bug]: order.summary.paid_total and order.summary.pending_difference not updating after partial payment captures #13635

@cesarmerlo

Description

@cesarmerlo

Package.json file

{
  "name": "medusa-starter-default",
  "version": "0.0.1",
  "description": "A starter for Medusa projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "start": "medusa start",
    "dev": "medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.10.2",
    "@medusajs/cli": "2.10.2",
    "@medusajs/framework": "2.10.2",
    "@medusajs/medusa": "2.10.2",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.10.2",
    "@mikro-orm/cli": "6.4.3",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11",
    "yalc": "^1.0.0-pre.53"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v22.18.0

Database and its version

PostgreSQL 13

Operating system name and version

Windows 10

Browser name

No response

What happended?

After performing partial payment captures on an order(via API), the fields order.summary.paid_total and order.summary.pending_difference do not update to reflect the actual captured amounts. These fields remain stale and show incorrect values, only considering the first capture.

Expected behavior

  • order.summary.paid_total should sum all capture amounts (e.g., 500 + 200 = 700)
  • order.summary.pending_difference should be the order total minus all captured amounts (e.g., 1330 - 700 = 630)

Actual behavior

  • order.summary.paid_total shows only the first capture (e.g., 500)
  • order.summary.pending_difference is calculated based on that incorrect value (e.g., 830)

Additional Context
The captures array within each payment correctly shows all capture records with accurate amounts, but the summary fields are not being recalculated after subsequent captures.

Temporary workaround:
We are manually calculating totals by iterating through order.payment_collections[].payments[].captures[] and summing the amounts.

Link to reproduction repo

na

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions