Magento信用卡发送电子邮件部件号

时间:2012-12-23 17:48:56

标签: magento credit-card

我需要修改信用卡保存方法,以便通过电子邮件发送一些数据,而其余部分则显示在管理员中。 我在/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);
    }
...
}

2 个答案:

答案 0 :(得分:1)

您可以使用sales_order_place_beforesales_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;
    }

请参阅Implementing observer Magento

答案 1 :(得分:0)

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