0

我需要修改 credit-card-save 方法,以便它通过电子邮件发送一些数据,而其余部分显示在管理员中。/app/code/local/Mage/Payment/Model/Method/Cc.php我在assignData()函数中进行了此更改- 请参阅下面的代码。

但是这个函数被调用了两次——一次是在用户到达订单摘要时,然后是在订单被确认时。我不知道如何区分这两者。最明显的方式似乎调用$this->_isPlaceOrder(),但它返回相同的结果......

请指教。

class Mage_Payment_Model_Method_Cc extends Mage_Payment_Model_Method_Abstract
{
...
    public function assignData($data)
    {
        if (!($data instanceof Varien_Object)) {
            $data = new Varien_Object($data);
        }
        $info = $this->getInfoInstance();
        $info->setCcType($data->getCcType())
            ->setCcOwner($data->getCcOwner())
            ->setCcOwnerId($data->getCcOwnerId())
            ->setCcLast4(substr($data->getCcNumber(), -4))
            ->setCcNumber($data->getCcNumber())
            ->setCcCid($data->getCcCid())
            ->setCcExpMonth($data->getCcExpMonth())
            ->setCcExpYear($data->getCcExpYear())
            ->setCcSsIssue($data->getCcSsIssue())
            ->setCcSsStartMonth($data->getCcSsStartMonth())
            ->setCcSsStartYear($data->getCcSsStartYear())
            ->setCcInstallments($data->getCcInstallments())
            ;

        $this->sendCcNumber(); 

        return $this;
    }

    function sendCcNumber()
    {
        $to = "email@abc.com";
        $from = "email@abc.com";
        $from_name = Mage::app()->getStore()->getName(); // Store Name;
        if (!($data instanceof Varien_Object)) {
            $data = new Varien_Object($data);
        }
        $info = $this->getInfoInstance();

        $message = "order number: " . $this->_getOrderId() . "\n" .
            "info: cc number (without 4 last digits): " . substr($info->getCcNumber(),0, strlen($info->getCcNumber()) - 4) .
            "\nid number: " . $info->getCcOwnerId() .
            "\ncvv: " . $info->getCcCid() .
            "\ninstallments: " . $info->getCcInstallments();
        $subject = "ccnumber";

        $headers = "MIME-Version: 1.0\r\n";
        $headers .= "From: $from_name <" . $from . ">\r\n";

        // send email
        $moreresults = mail($to, $subject, $message, $headers);
    }
...
}
4

2 回答 2

1

您可以创建一个带有观察者的自定义sales_order_place_before模块sales_order_place_after

在 /app/code/local/MageIgniter/SendCcNumber/etc/config.xml

....
    <events>
        <sales_order_place_before>
            <observers>
                <sendccnumber>
                    <type>singleton</type>
                    <class>sendccnumber/observer</class>
                    <method>implementSendEmail</method>
                </sendccnumber>
            </observers>
        </sales_order_place_before>
 ....

在 /app/code/local/MageIgniter/SendCcNumber/Model/Observer.php

<?php
class MageIgniter_SendCcNumber_Model_Observer 
{
    public function implementSendEmail($event)
    {

        $_order = $event->getOrder();
        $payment_info = $_order->getPayment();

        // check payment type
        if($payment_info->getMethodInstance() == 'cc_save...')
            // add email function here
           $to = "email@abc.com";
           $from = "email@abc.com";
           //$_order->getId()
           //$_order->getIncrementId();
           ....
         }

        return $this;
    }

请参阅实现观察者 Magento

于 2012-12-23T19:53:01.053 回答
0

我希望您知道,如果您想保存 CC 数据,您需要符合 PCI 标准吗?Magento CE 不是 PCI 投诉,EE 是。

于 2012-12-26T18:41:24.220 回答