The payment had a requires_capture status then it would succeed with the cancelation on Stripe. Because it's succeeded , it fails. I think this is a remnant from back when this was developed for uncaptured card payments.
Nowadays all those gateway payments are captured automatically in Stripe and you can't change that. It's a requirement to autocapture. Those payments are actually a majority in Poland. A little percentage of customers pay by card.
Some possible solutions:
Check that payment status is not succeeded before trying to cancel payment
Return a different entity indicating the issue so customer can be presented with something better
Medusa: 1.14. Stripe Plugin: 6.0
Symptom: Customer credit card is charged even when inventory is zero during order complete process.
To reproduce, do the following:
The following error is received on cart complete
The Stripe error log has:
This happens because cancelPayment() is being called on a "succeeded" payment. @chemicalkosek describes it best on Discord thread. Here is the exact line of code where it happens: https://github.com/medusajs/medusa/blob/c348263fdba73ad0cdb8b8941d91a415d5b26a2a/packages/medusa/src/strategies/cart-completion.ts#L373
Some possible solutions: