Thursday, April 21, 2011

PrestaShop Tips - Fatal error at order validation after payment 1.4.0/1.4.1

The problem
If you have upgraded from 1.3x PrestaShop to PrestaShop 1.4, you customer may encounter a Fatal error when place an order. The order occurs at order validation stage after payment.

See here for more information on how Paypal and PrestaShop process your order

Customer may or may not see the "Fatal Error" screen, it depends on the payment method of customer selected. If the payment method is late/slow validation like Paypal, then customer is not able to see error. If customer select instant/fast validation like Pay by Cheque, Bank transfer, then customer will see the error.

But either, the the order will not show up at your PrestaShop back office because the order validation failed. Customer may also not able to received "Order confirmation" email.

Why would it happen?
1. In PrestaShop 1.4x, the method of ValidationOrder() in PaymentModule class has been modified to validate the secure key. The secure key is generated when customer is registered.

if ($secure_key !== false AND $secure_key != $cart->secure_key)

From above code, you can see that if secure key passed to this method does not match the one saved in cart,then the Fatal Error will occur.

2. During upgrade from 1.3x to 1.4x, it seems there is an issue that cause customer record secure key is not migrated successfully.

Solution/Walk around
1. The best solution is repair your customer data to get secure key from old (existing store) database if you have backup.

2. As a walk around, you can comment out the secure key validation line to avoid error. But I suggest use this only for temporary solution before you fix your customer data.

There are also some other causes of Fatal at order validation.
* During creating Order Status History, if passed in order status is incorrect, it will cause an fatal error.

* If you have a customized invoice, and some error happen when generated invoice.
For example, background image not found.


faraon said...

thank you very much, i was in the trap with this error and it helped me a lot...

Alvin said...

good to know it helped and thanks for your feedback.