I am using Magento ver. 22.214.171.124, when we want to partially refund orders in paypal, All item in the order is coming back to stock and messed up the inventory. You originally want to refund one item for example out of 5 and you can only manually refund 1 items amount but thanks to paypal ipn, all of a sudden all items sends refunded and back to in stock.
So solution is simple, I have used magento core files to change the ipn, this actually should solved by magento long time ago.
Step 1- go to /public_html/app/code/core/Mage/Paypal/Model/
step 2- on line 437 find the below code
* Process a refund or a chargeback
protected function _registerPaymentRefund()
$reason = $this->getRequestData(’reason_code’);
$isRefundFinal = !$this->_info->isReversalDisputable($reason);
$payment = $this->_order->getPayment()
->registerRefundNotification(-1 * $this->getRequestData(’mc_gross’));
step 3- take out the last bit to stop paypal saving it back to magento#
Job done !!!!