2013-02-26 11 views
0

在我們的Magento CE 1.7商店,我們允許「貿易」客戶組中的客戶下單並支付採購訂單。在下訂單前請求密碼確認 - Magento

我們需要實施一個額外的安全層 - 當客戶到達結賬流程的訂單審覈步驟時,就在通過採購訂單付款方式下訂單之前,需要提示他們請求他們帳戶登錄密碼(即使他們已登錄)。他們需要正確輸入他們的賬戶密碼才能下訂單。

這是一個相當困難的前景,我知道 - 有誰知道這是相對可能的,或任何現有的模塊,提供這種功能?

在此先感謝!

+0

不在話下這裏...但是你嘗試過什麼? – 2013-02-26 15:11:24

+0

嗨,我很新 - 只是尋找解決方案,以確定最好的 - 尋找可能做過類似的人的指導? – Marc 2013-02-26 15:13:43

回答

0

你也許可以做到這一點使用事件/觀察者,但我會做到這一點的方法是使用自定義的付款方式,基本上重複定單

見/應用/代碼/核心/法師/支付/型號/法/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