medusa icon indicating copy to clipboard operation
medusa copied to clipboard

[Bug]: Rounding Issue when capturing payment from stripe webhook

Open fxmb opened this issue 4 months ago • 0 comments

Package.json file

Medusa 2.8.4
"stripe": "^17.6.0",

Node.js version

21

Database and its version

16

Operating system name and version

mac

Browser name

No response

What happended?

We are capturing payments from stripe via webhook and we noticed an interesting bug:

In medusa, the payment_session has this amount:

98.9009
{"value": "98.9009", "precision": 20}

Now, in Stripe we are handing over the amount in cents, so that would be 9890.

Now whenever we get the stripe webhook that the payment_intent was indeed successful with the amount (9890) the medusa backend matches its entry with the amount owed (98.9009) and detects a remainder since 98.9009 - 98.90 > 0.

Hence, it puts the payment_session in the state "Partially Captured" whereas it should be "Captured".... This in turn creates a lot of downstream issues for subscribers and stateful logics that depend on the payment being captured.

Since I cannot pass 4 digits to Stripe I need to somehow adjust this in medusa. Is anyone else having that issue?

This is rather urgent for us

Expected behavior

Match the amounts correctly, e.g. round in medusa or allow a margin of error

Actual behavior

Rounding issue

Link to reproduction repo

n/A

fxmb avatar Jun 20 '25 13:06 fxmb