Jump to content

Custom Payment module - order validated twice?

Recommended Posts

I am trying to create a custom payment module for prestashop 1.7

Everything goes well I get a reply from them once  the transaction is checked and successful.

it then redirects from payment controller to validation controller as intended to create the order from cart.

$cart = $this->context->cart;
$customer = new Customer($cart->id_customer);

if (!Validate::isLoadedObject($customer)) {

$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);

$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);


This causes an error for some reason, but the cart is converted to an order. Without this line the cart isn't converted so I have no clue why it complains like it's already done.

This is the error I get  Cart cannot be loaded or an order has already been placed using this cart

Any tips if I am missing something?


UPDATE: after a bit of digging I figured out that Validate::isLoadedObject($this->context->cart) in PaymentsModule.php is returning false.

I checked and cart_id has a value.

Edited by mrsparrow
add more info (see edit history)

Share this post

Link to post
Share on other sites

Ok so the validateOrder function seems to be called twice and the second time it seems to have a cart id of 0.

No idea where the second call is coming from though, If I remove the call in validation controller then it's not called at all.


Edited by mrsparrow (see edit history)

Share this post

Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More