你可能可以使用event/obstator来完成这项工作,但我的方法是使用一种基本上重复Purchaseorder的自定义支付方法
请参阅/app/code/core/Mage/Payment/Model/Method/Purchaseorder.php
class Mage_Payment_Model_Method_Purchaseorder extends Mage_Payment_Model_Method_Abstract
{
.....
public function validate()
{
$paymentInfo = $this->getInfoInstance();
validate customer password there
if($paymentInfo->getOrder()->getCustomerId()){
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$password = $paymentInfo->getPassword()
if ($customer->authenticate($paymentInfo->getOrder()->getCustomerEmail(), $password)) {
return true;
}
return false;
}
else{
return false;
}
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;
}
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