
Originally Posted by
BillJ
I'm writing a plugin for 1.57c and among other things I need to observe the amount of a refund, preferably independently of the payment module performing the refund. I can see in admin/orders.php I could place a notifier into the "doRefund" action but it looks as though orders.php doesn't get visibility of the actual refund amount. The form containing the amount is generated and processed by the payment module itself.
Is there a generic way I can observe a refund taking place and see the refund amount or do I have to hook into each payment module individually (effectively ruling out making this a general plugin)?
i am not sure what problem/situation your plugin is attempting to solve (and i am all for solving problems), but i do not see an easy way to do it. first, not all payment modules use the method _doRefund for doing a refund. so even if you created a PR to the base code and got a notifier in there, it would not be of value for those modules that do not use that method for doing a refund. in addition, each payment module seems to create its own payment table. something of which i have given some thought. it would be great if the there was a payments table that was independent of the payment module in use. and within that table, the payment module would be indicated. but i do not see that happening. furthermore the call to that method is in the admin/orders.php with only the order number being passed, ie:
PHP Code:
if (method_exists($module, '_doRefund')) {
$module->_doRefund($oID);
}
and yet just looking at the base code for v158, at these methods, there are various different parms being used:
Code:
includes/modules/payment/paypaldp.php:1207: function _doRefund($oID, $amount = 'Full', $note = '') {
includes/modules/payment/paypalwpp.php:863: function _doRefund($oID, $amount = 'Full', $note = '') {
includes/modules/payment/authorizenet_aim.php:768: function _doRefund($oID, $amount = 0) {
includes/modules/payment/square.php:1076: public function _doRefund($oID, $amount = null, $currency_code = null)
if you dig a little deeper, you will see that the _POST fields used to calculate the amounts of the refund are slightly different in each module.
obviously no problem is insurmountable, this one might have a bunch of challenges.
best.
Bookmarks