我正在使用自定义支付模块,并且在收到来自自定义支付网关的失败交易响应后,我想
使用“pending_payment”状态/状态保存订单,不要发送任何订单电子邮件。
我不想创建任何发票/处理它或发送任何发票电子邮件。
此外,我想将我的客户重定向到失败页面或结帐/购物车页面,但顶部有一条消息说他们的付款详细信息有误,请重试。
一旦我收到来自我的支付网关的“失败”响应,我就可以将订单保存到 pending_payment 状态并停止它发送新的订单电子邮件,但我无法阻止它开票 n 因此停止 d 发票电子邮件送出。
我在我的自定义支付模块中调用事件观察员,sales_order_place_after
该模块为订单开具发票并在成功交易时发送发票电子邮件。
现在我不知道该文件是否也需要编辑(app/code/local/Mage/Paymentmodule/Model/Observer.php)或者只是我的 app/code/local/Mage/Paymentmodule/Model/PaymentMethod.php 就足够了。
PaymentMethod.php
public function capture(Varien_Object $payment, $amount)
{
$error = false;
// check for payment
if($amount > 0)
{
$payment->setAmount($amount);
$order = $payment->getOrder();
if($payment->getTxnNumber() == "")
{
$transaction = $this->_build($payment, self::TRANSACTION_PREAUTH);
$authResponse = $this->_send($transaction);
if($authResponse->getResponseCode() > 0 && $authResponse->getResponseCode() <= self::ERROR_CODE_LIMIT)
{
$payment->setCcApproval($authResponse->getReceiptId())
->setLastTransId($authResponse->getReceiptId())
->setCcTransId($authResponse->getTxnNumber()) ->setCcCidStatus($this->getCvdDescription($authResponse->getCvdResultCode()));
}
else if($authResponse->getResponseCode() > self::ERROR_CODE_LIMIT && $authResponse->getResponseCode() < self::ERROR_CODE_UPPER_LIMIT)
{
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false)->save();
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
else
{
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false)->save();
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
}
$check = $this->checkCvdResponse($authResponse->getCvdResultCode());
if($check == true)
{
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false)->save();
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
else
{
$transaction_completion = $this->_build($payment, self::TRANSACTION_COMPLETION);
$response = $this->_send($transaction_completion);
if($response->getResponseCode() > 0 && $response->getResponseCode() <= self::ERROR_CODE_LIMIT)
{
$payment->setStatus(self::STATUS_SUCCESS);
$payment->setCcApproval($response->getReceiptId())
->setLastTransId($response->getReferenceNum())
->setCcTransId($response->getTxnNumber())
->setCcAvsStatus($this->getAvsDescription($authResponse->getAvsResultCode()))
->setCcCidStatus($this->getCvdDescription($authResponse->getCvdResultCode()));
}
else if($response->getResponseCode() > self::ERROR_CODE_LIMIT && $response->getResponseCode() < self::ERROR_CODE_UPPER_LIMIT)
{
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false)->save();
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
else
{
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false) ->save();
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
}
}
else
{
$error = Mage::helper('paygate')->__('Invalid amount for authorization.');
}
if ($error !== false)
Mage::throwException($error);
return $this;
}
观察者.php
public function implementOrderStatus($event)
{
$order = $event->getEvent()->getOrder();
if ($this->_getPaymentMethod($order) == 'custompaymentmodule')
{
if($order->getState() == 'pending_payment')
{
$order->setCanSendNewEmailFlag(false);
$order->setCanInvoiceFlag(false);
}
if ($order->canInvoice())
$this->_processOrderStatus($order);
}
return $this;
}
任何想法我如何才能保存它pending_payment 状态并停止它形成发票并使用适当的消息重定向到购物车页面。
任何有关解决任何问题的帮助将不胜感激。谢谢