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)) {
Tools::redirect('index.php?controller=order&step=1');
}

$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);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$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)
Link to comment
Share on other sites

  • 4 years later...

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...