应该在prestashop中创建订单表吗?

时间:2016-06-23 12:17:35

标签: paypal prestashop prestashop-1.6 prestashop-1.5

如果必须在PrestaShop中实际创建订单,我们会集成一个本地支付模块,该模块将重定向到该页面,并在输入卡详细信息并验证其返回的付款后,并在此时创建订单。 我的问题是,如果付款遭拒,(或者如果我在付款页面中处理付款时关闭浏览器),则不会在ps_order表中创建订单,但会创建购物车,如果我使用其他WEB服务查询银行,该cart_id的付款响应成功,id_order为0, 但我在ps_order表中创建的ps_order表中没有订单或条目。如何满足这种情况?

在付款处理之前创建订单(插入订单表)是否正确并将current_state字段设置为3状态3表示正在处理并在付款成功时更改current_state字段。

从ps_orders中选择*

这是payemnt模块的工作方式

if($reponseParameters[8]=='00000'){
                // Update the Respose to the ps_networkonline_payment 

                    $sql_response = " UPDATE `"._DB_PREFIX_."networkonline_payment` SET response = '".$text."' , `status` = '".$reponseParameters[4]."', error_code = '".$reponseParameters[8]."' WHERE order_id = '".$cart->id."' ";
                    Db::getInstance()->execute($sql_response);

                // Create Order In prestashop pass the values to order-confrimation class 
                    $total = (float)$cart->getOrderTotal(true, Cart::BOTH);
                    $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, 'Transaction Reference: ' . $reponseParameters[5], array(), (int)$currency->id, false, $customer->secure_key);

                // Update the ps_order_payment table to make the PrestaShop Payment success 
                     $q_orders  = 'SELECT `reference` FROM ' . _DB_PREFIX_ . 'orders WHERE `id_cart` = ' . (int) $cart->id;

                    if ($r_orders = Db::getInstance()->getRow($q_orders)){
                        Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'order_payment` SET `transaction_id` = \'' . pSQL($reponseParameters[5]) . '\' , `card_brand` = \'' . pSQL($reponseParameters[7]) . '\' WHERE `order_reference` = \'' . pSQL($r_orders['reference']) . '\'');                         
                    }


                    Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);           
                return;     
            }else{

                $this->error = $reponseParameters[9];//$this->module->getErrorMessage($object->error_code);
                $total = (float)$cart->getOrderTotal(true, Cart::BOTH); 
                $this->module->validateOrder($cart->id, Configuration::get('PS_OS_ERROR'), $total, $this->module->displayName, $this->error, array(), (int)$currency->id, false, $customer->secure_key);

            }


        }else{

            //fail
            $this->error = $reponseParameters[9];//$this->module->getErrorMessage($object->error_code);
            $total = (float)$cart->getOrderTotal(true, Cart::BOTH); 
            $this->module->validateOrder($cart->id, Configuration::get('PS_OS_ERROR'), $total, $this->module->displayName, $this->error, array(), (int)$currency->id, false, $customer->secure_key);

        }


}

1 个答案:

答案 0 :(得分:0)

当您的客户被重定向到他们的平台时,哪些支付模块通常具有银行查询您的网站的方式,这样无论在他们身边发生什么事情都会在您身边创建订单(留给您新创建的)订单状态如“待付款”)。

然后,通过银行的电话(具有“已屏蔽”,“已取消”或“已接受付款”状态),客户返回您的网站时,订单会更新。