Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Free order appears as awaiting after "capturing" free amount #10238

Closed
jgatto1 opened this issue Nov 22, 2024 · 0 comments
Closed

[Bug]: Free order appears as awaiting after "capturing" free amount #10238

jgatto1 opened this issue Nov 22, 2024 · 0 comments

Comments

@jgatto1
Copy link

jgatto1 commented Nov 22, 2024

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",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "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 --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "migrate": "npx medusa db:migrate"
  },
  "dependencies": {
    "@hello-pangea/dnd": "^16.6.0",
    "@medusajs/admin-sdk": "2.0.4",
    "@medusajs/cli": "2.0.4",
    "@medusajs/framework": "2.0.4",
    "@medusajs/icons": "^1.2.1",
    "@medusajs/js-sdk": "^2.0.4",
    "@medusajs/medusa": "2.0.4",
    "@medusajs/types": "^2.0.4",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "@opentelemetry/instrumentation": "^0.55.0",
    "@opentelemetry/instrumentation-pg": "^0.47.1",
    "@opentelemetry/resources": "^1.28.0",
    "@opentelemetry/sdk-node": "^0.55.0",
    "@opentelemetry/sdk-trace-node": "^1.28.0",
    "@sentry/node": "^8.38.0",
    "@sentry/opentelemetry-node": "^7.114.0",
    "@sentry/profiling-node": "^8.38.0",
    "@tanstack/react-table": "^8.17.3",
    "awilix": "^8.0.1",
    "axios": "^1.7.2",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "16.3.1",
    "express": "^4.17.2",
    "ioredis": "^5.4.1",
    "jose": "^5.9.6",
    "jwt-decode": "^4.0.0",
    "moment": "^2.30.1",
    "pg": "^8.13.0",
    "prism-react-renderer": "^2.0.4",
    "quill": "^2.0.2",
    "react-hook-form": "^7.52.0",
    "react-hot-toast": "^2.4.1",
    "react-quilljs": "^2.0.3",
    "react-select": "^5.8.1",
    "tailwind-merge": "^2.4.0",
    "tus-js-client": "^4.1.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.14.3",
    "@babel/core": "^7.14.3",
    "@babel/preset-typescript": "^7.21.4",
    "@medusajs/test-utils": "2.0.4",
    "@mikro-orm/cli": "5.9.7",
    "@stdlib/number-float64-base-normalize": "0.0.8",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/express": "^4.17.13",
    "@types/jest": "^29.5.13",
    "@types/mime": "1.3.5",
    "@types/node": "^20.0.0",
    "@types/quill": "^2.0.14",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "cross-env": "^7.0.3",
    "eslint": "^6.8.0",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "rimraf": "^3.0.2",
    "ts-jest": "^27.0.7",
    "ts-loader": "^9.2.6",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11"
  },
  "jest": {
    "globals": {
      "ts-jest": {
        "tsconfig": "tsconfig.spec.json"
      }
    },
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "<rootDir>/node_modules/"
    ],
    "rootDir": "src",
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|js)$",
    "transform": {
      ".ts": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "./coverage",
    "testEnvironment": "node"
  },
  "resolutions": {
    "glob": "^7.1.6"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v20.17.0

Database and its version

PostgreSQL 13.16

Operating system name and version

MacOS 14.0 (23A344)

Browser name

No response

What happended?

After adding products to a cart with a price of $0, completed the order using the system default payment provider and captured the $0 amount, the order didn't update to captured. I think this is because how Medusa handles the captured state:

    if (MathBN.gt(paymentCollection.captured_amount ?? 0, 0)) {
      paymentStatus[PaymentStatus.CAPTURED] += MathBN.eq(
        paymentCollection.captured_amount as number,
        paymentCollection.amount
      )
        ? 1
        : 0.5
    }

But if a free order then captured amount is 0. If think if:
captured_amount === captured_amount === amount === 0 then mark it as captured.

What do you think?

Thanks!

Expected behavior

Should be marked as captured.

Actual behavior

Is marked as awaiting

Link to reproduction repo

not apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants