Question

$payment is of Mage_Sales_Model_Order_Payment which extends Mage_Payment_Model_Info which in turn extends Mage_Core_Model_Abstract.

On EE 1.12, there is no column cc_number (cc_number_enc exists) in sales_flat_order_payment and I don't see any function defined getCcNumner(), either. There's an extension that calls payment->getCcNumber(), and it's returning null. I do see other core codes that call this function as well..

Am I missing something here, or is this getCcNumber() not valid?

Was it helpful?

Solution

Under the class Mage_Payment_Model_Info which deals with the information of the payment. There is a custom getData function. This will take the stored encoded cc_number field and decrypt it so that the user can call getCcNumber()

public function getData($key='', $index=null)
{
    if ('cc_number'===$key) {
        if (empty($this->_data['cc_number']) && !empty($this->_data['cc_number_enc'])) {
            $this->_data['cc_number'] = $this->decrypt($this->getCcNumberEnc());
        }
    }
    if ('cc_cid'===$key) {
        if (empty($this->_data['cc_cid']) && !empty($this->_data['cc_cid_enc'])) {
            $this->_data['cc_cid'] = $this->decrypt($this->getCcCidEnc());
        }
    }
    return parent::getData($key, $index);
}

When it is being saved there is the revers of this and the encrypt. This is done under the Mage_Payment_Model_Method_Cc in the function prepareSave()

public function prepareSave()
{
    $info = $this->getInfoInstance();
    if ($this->_canSaveCc) {
        $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
    }
    //$info->setCcCidEnc($info->encrypt($info->getCcCid()));
    $info->setCcNumber(null)
        ->setCcCid(null);
    return $this;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top