Jump to content

Edit History

mrsparrow

mrsparrow


add more info

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.

mrsparrow

mrsparrow


add more info

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.

mrsparrow

mrsparrow

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?

mrsparrow

mrsparrow

I am trying to create a custom payment module for a payment processor that does not have one yet.

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?

mrsparrow

mrsparrow

I am trying to create a custom payment module for a payment processor that does not have one yet.

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_CHEQUE'), $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?

×
×
  • Create New...