简体   繁体   English

3DSecure重定向后的Prestashop 1.6 Cart恢复

[英]Prestashop 1.6 Cart recovery after 3DSecure redirect

I am building a payment gateway module based on the Authorize.net (aim) module. 我正在基于Authorize.net(aim)模块构建付款网关模块。 The issue is that after 3DSecure validation, it redirects back to the website, but the cart is not in context, I think. 问题在于,经过3DSecure验证后,它会重定向回网站,但我认为购物车不在上下文中。

Before I am redirecting, I am saving the cart id to the session. 重定向之前,我将购物车ID保存到会话中。

It throws the following error: 它引发以下错误:

"Cart cannot be loaded or an order has already been placed using this cart" “无法加载购物车或已使用此购物车下订单”

This is triggered by: 这是由以下原因触发的:

if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false)

on line 188 of classes/PaymentModule.php 在class / PaymentModule.php的第188行

How can I load/reload the cart? 如何加载/重新加载购物车?

Thanks 谢谢

Jacques 雅克

In many payment modules, Prestashop create order before bank redirect with missing payment status and wait bank confirmation to update order. 在许多付款模块中,Prestashop会在银行重定向之前创建订单(缺少付款状态),然后等待银行确认以更新订单。

If you want still regenerate cart, you can do that with the submitReorder functionnality in ParentOrderController. 如果您仍要重新生成购物车,则可以使用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');
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM