Jump to content

Paypal Refund Error


redsmartie

Recommended Posts

I am trying to refund a payment via Paypal using the Refund Total Transaction button. I have used this successfully before to the account I am trying to refund to but I am now getting an error:

Error from PayPal: The partial refund must be the same currency as the original transaction (#10009)

The full message is:

At 2011-05-17 08:59:46 from Private:
Refund operation result:
TIMESTAMP: 2011-05-17T07:59:46Z
CORRELATIONID: 884e643979fcf
ACK: Failure
VERSION: 60.0
BUILD: 1882144
L_ERRORCODE0: 10009
L_SHORTMESSAGE0: Transaction refused
L_LONGMESSAGE0: The partial refund must be the same currency as the original transaction
L_SEVERITYCODE0: Error
Transaction error!

The payment and refund are in pounds sterling.

Thanks, Martin

Link to comment
Share on other sites

same error as above for me
using 1.4.1 prestashop and included paypal module
credit payments, paypal account balance and prestashop in GBP. Also tried to refund euro payment with same error.
Am going to check the code to see what is supposed to be happening.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 2 weeks later...

I've had this bug for a while now, the fix for the currency bug is to change the SQL query in _makeRefund (the one included with Prestashop doesn't actually work, it always selects EURO).

However to apply this fix you'll need experience in PHP as you'll also have to change the parameter of _makeRefund to $id_order instead of $id_transaction and then change all invocations of _makeRefund.

There's even more problems with regards to calculating the total refund amount. As it is configured at the moment it can skip some products, it skips discounts (meaning it can try to refund too much!) and it also misses wrapping if enabled (this particular bug can be spotted in _doTotalRefund, near line 1029). This module is so buggy I think the prestashop dev. team need to take a better look at it!

Enough rambling, here is my modified line from _makeRefund in /modules/paypal/paypal.php (near the bottom):

$isoCurrency = Db::getInstance()->getValue('
		SELECT `iso_code`
		FROM `'._DB_PREFIX_.'orders` o
		LEFT JOIN `'._DB_PREFIX_.'currency` c ON (o.`id_currency` = c.`id_currency`) WHERE o.`id_order` = '.$id_order);

 

you'll also need to insert

$id_transaction = $this->_getTransactionId($id_order);

somewhere near the top of this function.

 

Then to change the invocations, two invocations are a little bit futher down in _doTotalRefund (with the incorrect total refund calculation code) and the other invocation is within hookCancelProduct (line 357).

 

My (semi-)fixed refund calculation code is as below:

// Amount for refund
	$amt = 0.00;
	foreach ($products AS $product)
            $amt += ($product['product_quantity'] - $product['product_quantity_refunded'])*(float)($product['product_price']);
	$amt += (float)($order->total_shipping);
	$amt -= (float) $order->total_discounts;
               $amt -= (float) $order->total_wrapping;
	// check if total or partial
	if (round($order->total_paid_real,2) == round($amt,2))
		$response = $this->_makeRefund($id_order, $id_transaction);
	else
		$response = $this->_makeRefund($id_order, $id_transaction, (float)($amt));

 

I really hoped these bugs would have been fixed in 1.4.4, but no such luck I'm afraid, they both got through!

I hope this code helps

Link to comment
Share on other sites

  • 3 weeks later...

I did what you said and got error : 'Fatal Error: id_transaction is null'

 

I took a look, in line 364, the parameter for _makeRefund() should be $order->id instead of $id_order then your solution is perfect for the problem of non-Euro transaction refund! I tested it, it works now!

 

Thank you!

 

I am trying to customize more like partial refund, I think that is what a lot of shopper owner needs. I did not find any solutions now so I will make a try myself.

 

I've had this bug for a while now, the fix for the currency bug is to change the SQL query in _makeRefund (the one included with Prestashop doesn't actually work, it always selects EURO).

However to apply this fix you'll need experience in PHP as you'll also have to change the parameter of _makeRefund to $id_order instead of $id_transaction and then change all invocations of _makeRefund.

There's even more problems with regards to calculating the total refund amount. As it is configured at the moment it can skip some products, it skips discounts (meaning it can try to refund too much!) and it also misses wrapping if enabled (this particular bug can be spotted in _doTotalRefund, near line 1029). This module is so buggy I think the prestashop dev. team need to take a better look at it!

Enough rambling, here is my modified line from _makeRefund in /modules/paypal/paypal.php (near the bottom):

$isoCurrency = Db::getInstance()->getValue('
		SELECT `iso_code`
		FROM `'._DB_PREFIX_.'orders` o
		LEFT JOIN `'._DB_PREFIX_.'currency` c ON (o.`id_currency` = c.`id_currency`) WHERE o.`id_order` = '.$id_order);

 

you'll also need to insert

$id_transaction = $this->_getTransactionId($id_order);

somewhere near the top of this function.

 

Then to change the invocations, two invocations are a little bit futher down in _doTotalRefund (with the incorrect total refund calculation code) and the other invocation is within hookCancelProduct (line 357).

 

My (semi-)fixed refund calculation code is as below:

// Amount for refund
	$amt = 0.00;
	foreach ($products AS $product)
			$amt += ($product['product_quantity'] - $product['product_quantity_refunded'])*(float)($product['product_price']);
	$amt += (float)($order->total_shipping);
	$amt -= (float) $order->total_discounts;
			$amt -= (float) $order->total_wrapping;
	// check if total or partial
	if (round($order->total_paid_real,2) == round($amt,2))
		$response = $this->_makeRefund($id_order, $id_transaction);
	else
		$response = $this->_makeRefund($id_order, $id_transaction, (float)($amt));

 

I really hoped these bugs would have been fixed in 1.4.4, but no such luck I'm afraid, they both got through!

I hope this code helps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...