News:

Looking for documentation? Take a look on our wiki

Main Menu

Paypal Partial Refund Cancels Order

Started by randomdev, February 21, 2013, 03:09:13 AM

Previous topic - Next topic

randomdev

Is there any way to stop a partial refund via paypal from cancelling the whole order?

randomdev

I haven't tested this yet, but looks like this would work.

in plugins/vmpayment/paypal.php

Around line 522 (at the end of the elseif check for 'Pending') add

} elseif (strcmp ($paypal_data['payment_status'], 'Refunded') == 0) {
//uncomment below if you dont want to notify customer
        //$order['customer_notified'] = 0;
$order['comments'] = 'Refund Issued for: '.$paypal_data['mc_gross'];


So it looks like

} elseif (strcmp ($paypal_data['payment_status'], 'Pending') == 0) {
$key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_' . strtoupper ($paypal_data['pending_reason']);
if (!$lang->hasKey ($key)) {
$key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_DEFAULT';
}
$order['comments'] = JText::sprintf ('VMPAYMENT_PAYPAL_PAYMENT_STATUS_PENDING', $order_number) . JText::_ ($key);
$order['order_status'] = $method->status_pending;
} elseif (strcmp ($paypal_data['payment_status'], 'Refunded') == 0) {
//$order['customer_notified'] = 0;
$order['comments'] = 'Refund Issued for: '.$paypal_data['mc_gross'];
} elseif (isset ($paypal_data['payment_status'])) {
$order['order_status'] = $method->status_canceled;
} else {
/*
* a notification was received that concerns one of the payment (since $paypal_data['invoice'] is found in our table),
* but the IPN notification has no $paypal_data['payment_status']
* We just log the info in the order, and do not change the status, do not notify the customer
*/
$order['comments'] = JText::_ ('VMPAYMENT_PAYPAL_IPN_NOTIFICATION_RECEIVED');
$order['customer_notified'] = 0;
}


You could/should probably check if the refund amount is equal to the total order amount and just set the whole status as refunded in that case also.