Add online payment refund
If I want to add Paypal refund, which file should I override? Thanks!
Hello @jcgdjob and sorry for the long response time. The limitation of possible refund payment methods is done in OfflineRefundPaymentMethodsProvider which is an implementation of RefundPaymentMethodsProviderInterface. You should implement your own service with this interface and inject it to RefundUnitsAction.
But it is the easy part, as it's only a select options display :) To handle the refund process from the Paypal perspective, you would also have to listen on some event (probably UnitsRefunded, but it all depends on your approach) and hook into the Paypal refund process. Probably some customization of event class would also be necessary to include some more detail required by payment gateway... It's quite a complicated case, as there are lot's of things that can go wrong, that's also one of the reasons we decided to support only offline refunds (at least for now, but for sure it won't change before a 1.0 release).
Nevertheless, good luck, if you find some elegant solution for this case it would be great if you want to share it :) 🖖
I went with a console command that will be triggered by cron job, get refunds payments according to state, calls its linked gateway's Refund Action (which you may have to implement yourself) and transitions the refund payment to completed if it succeeded. It is a little too specific to the single customized gateway the project is using to be of much help but I think that's the easiest to implement right now, at least for my use case (Stripe v3 w/ recurring payments).