Jump to content

[Solved]Tripple Payments


Recommended Posts

Hey devs,

 

 

I upgraded my shop to 1.5.2 and i noticed something odd.

When i perform a payment, and look up the order on the backend of Prestashop it claims that it has been paid 3 times.

 

When i look at the invoice it says there has only been 1 payment.

I downloaded a new version of Prestshop directly from the site.

And i see that there is a correction for this behavior.

However i cant find this on my current shop.

 

Should perform a new install of Prestashop?

 

Is this in any way related to the Multishipping option?

I have turned that of and it doesnt fix this.

Edited by martijnbakker (see edit history)
Link to comment
Share on other sites

Hi

 

I noticed this and posted it earlier in this forum. (using V1.5.0)

It occurred after I enabled advanced stock management and Multishipping. As I was also getting stock errors I reverted back to 1.4.9, now upgraded to 1.5.2 but I am not using either advanced stock management or Multishipping.

 

On my test server I will enable both and try and duplicate transactions as much as possible to see if I get the errors again.

 

I will come back to you if this problem re occurs.

G

Link to comment
Share on other sites

Hi

 

i have exactly same error with Paypal or SystemPay only on external payment. I never use stock management or Multishipping.

However i enable/disable check invoice management and i get an invoice in this 3 payment even if option is disabled.

Link to comment
Share on other sites

Hello Guys,

 

We of iDEAL Checkout had a look at the problem, and found the issue.

It is related to the stock management indeed.

 

The problem can be found in the file: ../classes/order/orderHistory.php around line: 233

The following code can be found:

if ($new_os->invoice && !$order->invoice_number)
$order->setInvoice($use_existing_payment);
  // set orders as paid
  if ($new_os->paid == 1)
  {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0)
 $payment_method = Module::getInstanceByName($order->module);
foreach ($invoices as $invoice)
{
 $rest_paid = $invoice->getRestPaid();
 if ($rest_paid > 0)
 {
  $payment = new OrderPayment();
  $payment->order_reference = $order->reference;
  $payment->id_currency = $order->id_currency;
  $payment->amount = $rest_paid;
  if ($order->total_paid != 0)
   $payment->payment_method = $payment_method->displayName;
  else
   $payment->payment_method = null;

  // Update total_paid_real value for backward compatibility reasons
  if ($payment->id_currency == $order->id_currency)
   $order->total_paid_real += $payment->amount;
  else
   $order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2);
  $order->save();
   idealcheckout_log('test', __FILE__, __LINE__);
  $payment->conversion_rate = 1;
  $payment->save();
  Db::getInstance()->execute('
  INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
  VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$order->id.')');
 }
}
  }

 

Replace the code with the following:

 

/* <iDEAL Checkout Fix > */
 if($new_os->id == Configuration::get('PS_OS_PAYMENT'))
 {
/* </iDEAL Checkout Fix > */
  if ($new_os->invoice && !$order->invoice_number)
$order->setInvoice($use_existing_payment);
  // set orders as paid
  if ($new_os->paid == 1)
  {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0)
 $payment_method = Module::getInstanceByName($order->module);
foreach ($invoices as $invoice)
{
 $rest_paid = $invoice->getRestPaid();
 if ($rest_paid > 0)
 {
  $payment = new OrderPayment();
  $payment->order_reference = $order->reference;
  $payment->id_currency = $order->id_currency;
  $payment->amount = $rest_paid;
  if ($order->total_paid != 0)
   $payment->payment_method = $payment_method->displayName;
  else
   $payment->payment_method = null;

  // Update total_paid_real value for backward compatibility reasons
  if ($payment->id_currency == $order->id_currency)
   $order->total_paid_real += $payment->amount;
  else
   $order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2);
  $order->save();
   idealcheckout_log('test', __FILE__, __LINE__);
  $payment->conversion_rate = 1;
  $payment->save();
  Db::getInstance()->execute('
  INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
  VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$order->id.')');
 }
}
  }
/* <iDEAL Checkout Fix > */
 }
/* </iDEAL Checkout Fix > */

 

This way u can still use the Stock Management, and not worry about dubble or even tripple payments.

Edited by iDEAL Checkout (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...