代码之家  ›  专栏  ›  技术社区  ›  Marc

下单前要求确认密码-Magento

  •  0
  • Marc  · 技术社区  · 12 年前

    在我们的Magento CE 1.7商店,我们允许“贸易”客户群中的客户下订单并在采购订单上付款。

    我们需要实现一个额外的安全层,即当客户到达结账过程的订单审查步骤时,就在通过采购订单支付方式下订单之前,需要有一个提示,请求他们的帐户登录密码(即使他们已经登录)。他们需要正确输入帐户密码才能下订单。

    据我所知,这是一个相当困难的前景——有人知道这是否是相对可能的,或者任何提供此功能的现有模块吗?

    提前谢谢!

    1 回复  |  直到 12 年前
        1
  •  0
  •   MagePal Extensions    12 年前

    你可能可以使用event/obstator来完成这项工作,但我的方法是使用一种基本上重复Purchaseorder的自定义支付方法

    请参阅/app/code/core/Mage/Payment/Model/Method/Purchaseorder.php

    class Mage_Payment_Model_Method_Purchaseorder extends Mage_Payment_Model_Method_Abstract
    {
    
        .....
    
    
        /**
         * Validate payment method information object
         *
         * @return Mage_Payment_Model_Abstract
         */
        public function validate()
        {
             $paymentInfo = $this->getInfoInstance();
    
             validate customer password there
    
             if($paymentInfo->getOrder()->getCustomerId()){
    
                //see login() in /app/code/core/Mage/Customer/Model/Session.php
                $customer = Mage::getModel('customer/customer')
                    ->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
                //May need to change to the order store id and not Mage::app()->getStore()->getWebsiteId()
    
                //get password enter on PO screen
                $password = $paymentInfo->getPassword()
    
                if ($customer->authenticate($paymentInfo->getOrder()->getCustomerEmail(), $password)) {
                    return true;
                }
                return false;
             }
             else{
                //customer not login
                return false;
             }
    
             /**
              * to validate payment method is allowed for billing country or not
              */
             if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
                 $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
             } else {
                 $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
             }
             if (!$this->canUseForCountry($billingCountry)) {
                 Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
             }
             return $this;
        }
    
        /**
         * Assign data to info model instance
         *
         * @param   mixed $data
         * @return  Mage_Payment_Model_Method_Purchaseorder
         */
        public function assignData($data)
        {
            if (!($data instanceof Varien_Object)) {
                $data = new Varien_Object($data);
            }
    
            $this->getInfoInstance()->setPoNumber($data->getPoNumber());
            $this->getInfoInstance()->setPassword($data->getPassword());
            return $this;
        }
    
    
    }
    

    看一看@ How to create a payment method