支付失败不清空购物车
来源:互联网 发布:用友支票打印软件 编辑:程序博客网 时间:2024/04/30 03:05
app\code\local\Lotusbreath\Checkout\Model\Service\Checkout.php
public function submitOrder() { try { $data = $this->getRequest()->getPost('payment', array()); if ($data) { $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL; $this->getOnepage()->getQuote()->getPayment()->importData($data); } //save comment if (Mage::getStoreConfig('lotusbreath_onestepcheckout/general/allowcomment')) { Mage::getSingleton('customer/session')->setOrderCustomerComment($this->getRequest()->getPost('order_comment')); } $this->subscribeNewsletter(); $result = array(); $dispatchParams = array( 'data' => $this->getRequest()->getPost(), 'result' => $result ); Mage::dispatchEvent('lotus_checkout_submit_order_before',$dispatchParams); $this->getOnepage()->saveOrder(); $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl(); $result['success'] = true; $result['error'] = false; } catch (Mage_Payment_Model_Info_Exception $e) { $message = $e->getMessage(); $result['success'] = false; $result['error'] = true; if (!empty($message)) { $result['error_messages'] = $message; } } catch (Mage_Core_Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $result['success'] = false; $result['error'] = true; $result['error_messages'] = $e->getMessage(); if ($gotoSection = $this->getOnepage()->getCheckout()->getGotoSection()) { $result['goto_section'] = $gotoSection; $this->getOnepage()->getCheckout()->setGotoSection(null); } } catch (Exception $e) { Mage::logException($e); //echo $e->getMessage(); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $result['success'] = false; $result['error'] = true; $result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.'); }// $this->getOnepage()->getQuote()->save(); /** * when there is redirect to third party, we don't want to save order yet. * we will save the order in return action. */ if (isset($redirectUrl)) { $result['redirect'] = $redirectUrl; }else{ $this->getOnepage()->getQuote()->save(); } return $result; }
app\code\core\Mage\Checkout\controllers\OnepageController.php
/** * Create order action */ public function saveOrderAction() { if (!$this->_validateFormKey()) { $this->_redirect('*/*'); return; } if ($this->_expireAjax()) { return; } $result = array(); try { $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds(); if ($requiredAgreements) { $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); $diff = array_diff($requiredAgreements, $postedAgreements); if ($diff) { $result['success'] = false; $result['error'] = true; $result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.'); $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); return; } } $data = $this->getRequest()->getPost('payment', array()); if ($data) { $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL; $this->getOnepage()->getQuote()->getPayment()->importData($data); } $this->getOnepage()->saveOrder(); $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl(); $result['success'] = true; $result['error'] = false; } catch (Mage_Payment_Model_Info_Exception $e) { $message = $e->getMessage(); if (!empty($message)) { $result['error_messages'] = $message; } $result['goto_section'] = 'payment'; $result['update_section'] = array( 'name' => 'payment-method', 'html' => $this->_getPaymentMethodsHtml() ); } catch (Mage_Core_Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $result['success'] = false; $result['error'] = true; $result['error_messages'] = $e->getMessage(); $gotoSection = $this->getOnepage()->getCheckout()->getGotoSection(); if ($gotoSection) { $result['goto_section'] = $gotoSection; $this->getOnepage()->getCheckout()->setGotoSection(null); } $updateSection = $this->getOnepage()->getCheckout()->getUpdateSection(); if ($updateSection) { if (isset($this->_sectionUpdateFunctions[$updateSection])) { $updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection]; $result['update_section'] = array( 'name' => $updateSection, 'html' => $this->$updateSectionFunction() ); } $this->getOnepage()->getCheckout()->setUpdateSection(null); } } catch (Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $result['success'] = false; $result['error'] = true; $result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.'); }// $this->getOnepage()->getQuote()->save(); /** * when there is redirect to third party, we don't want to save order yet. * we will save the order in return action. */// 跳转到第三方支付不清空购物车 if (isset($redirectUrl)) { $result['redirect'] = $redirectUrl; }else{ $this->getOnepage()->getQuote()->save(); } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); }
支付成功清空购物车
\web\app\code\core\Mage\Checkout\controllers\OnepageController.php
public function successAction() { $session = $this->getOnepage()->getCheckout(); if (!$session->getLastSuccessQuoteId()) { $this->_redirect('checkout/cart'); return; } $lastQuoteId = $session->getLastQuoteId(); $lastOrderId = $session->getLastOrderId(); $lastRecurringProfiles = $session->getLastRecurringProfileIds(); if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) { $this->_redirect('checkout/cart'); return; } $this->update_customer_points(); $this->earnpointswithmakepurchase(); $points = Mage::getSingleton('customer/session')->getApplyPoints(); if($points) { $this->spendpoints($points); }//清空购物车 $this->getOnepage()->getQuote()->save(); $session->clear(); $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); $this->renderLayout(); }
阅读全文
0 0
- 支付失败不清空购物车
- 购物车跳转到支付
- 购物车的支付宝模块
- 电商 购物车-订单-支付流程
- asp.net购物车,订单以及模拟支付宝支付(四)---模拟支付宝支付
- asp.net购物车,订单以及模拟支付宝支付(一)---购物车表及添加购物车流程
- 购物网站18:购物车列表---购物车管理----配送信息管理----订单确认----支付方式----购物完成----购买管理
- ASP.NET 2.0打造购物车和支付系统之一
- ASP.NET 2.0打造购物车和支付系统之一
- ASP.NET 2.0打造购物车和支付系统之一
- ASP.NET 2.0打造购物车和支付系统
- ASP.NET 2.0打造购物车和支付系统之一
- [转]一步一步asp.net_购物车订单与支付宝
- asp.net购物车,订单以及模拟支付宝支付(二)---订单表
- asp.net购物车,订单以及模拟支付宝支付(三)---提交订单
- 支付宝支付失败:4000
- magento 提交订单失败跳回到购物车的问题
- 【支付宝】支付宝支付失败:4000
- Activity 四种启动模式
- C/C++ BMP(24位真彩色)图像处理(5)------图像の线性变换
- Linux下nginx使用记录
- MDA模式开发Struts Portlet
- 微信开发从入门到精通教程大全 资料大全 java和php版本;教程文档、代码、视频 微信商城实例
- 支付失败不清空购物车
- JedisPool的配置参数
- jmeter源码集成eclipse二次开发
- g++的思考
- F1V3.0-24 UI前端模块的发布及部署
- PHP两个数组合并键值
- 找出二叉搜索树第k大的节点
- RSA公钥加密算法
- 15 个 Android 通用流行框架大全