medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.96k stars 2.61k forks source link

Refunds for other providers not working #9924

Closed SGFGOV closed 1 week ago

SGFGOV commented 1 week ago

Bug report

Describe the bug

A clear and concise description of what the bug is.

System information

Medusa version (including plugins): Node.js version: 20.18 Database:postgres Operating system:amazon linux Browser (if relevant):ms edge

Steps to reproduce the behavior

Install the razorpay payment provider and configure to region India.

place a checkout and then capture the payment.

Expected behavior

Auto Refund

Screenshots

image

The outstanding amount when it is 0. I'm unable to issue refunds. If the outstanding amount is the funds available for refunds, maybe you need to change the label in the admin.

sradevski commented 1 week ago

Hey @SGFGOV where does the razorpay provider come from? I also don't understand if there isan outstanding balance to refund or not here, can you write it more clearly what the state of the order is, and what you would have expected to see?

SGFGOV commented 1 week ago

@sradevski razorpay provider (@sgftech/payment-razorpay) was written by me. Following the same flow as stripe provider.

Where the two are different is in the way refunds are handled.

Razorpay transfers funds to your bank account when you capture but it doesn't automatically reverse from the bank account when you refund. You can only refund from the stripe escrow before you capture.

Alternatively you need to keep money in a special refund account managed by razorpay..in which case it will refund from there even after capture. This is done via the razorpay console.

With medusa only the second option will work..

The issue I faced was that the word outstanding balance was misleading. I interpreted it to mean amount due to the merchant from the customer.

But I think the context of medusa it means funds available for refunds.. perhaps we should use a different nomenclature

sradevski commented 1 week ago

@SGFGOV ok got it, so it's mainly about naming then. Feel free to open a PR with the suggested improvement, and we can review it there. I'll close this in the meantime if you agree.

SGFGOV commented 1 week ago

Ok..