我正在构建一个基于Authorize.net (aim)模块的支付网关模块。问题是,在3DSecure验证后,它会重定向回网站,但我认为购物车不在上下文中。
在重定向之前,我将购物车id保存到会话。
抛出以下错误:
"购物车无法加载或已使用此购物车下过订单"
触发:
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false)
类/PaymentModule.php第188行
如何加载/重新加载购物车?
感谢雅克在许多支付模块中,Prestashop在银行重定向之前创建订单,缺少支付状态,等待银行确认更新订单。
如果你仍然想重新生成购物车,你可以使用ParentOrderController中的submitReorder功能。
$oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id));
$duplication = $oldCart->duplicate();
if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) {
$this->errors[] = Tools::displayError('Sorry. We cannot renew your order.');
} elseif (!$duplication['success']) {
$this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
} else {
$this->context->cookie->id_cart = $duplication['cart']->id;
$context = $this->context;
$context->cart = $duplication['cart'];
CartRule::autoAddToCart($context);
$this->context->cookie->write();
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc');
}
Tools::redirect('index.php?controller=order');
}