Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Custom Payment Method: how to get data that was set via Mage_Payment_Model_Method_Abstract::assignData()?

I'm currently developing a payment method and things are working quite well.

Just one thing: The customer enters some information along the payment method and through debugging I can see that it gets written into the InfoInstance via Mage_Payment_Model_Method_Abstract::assignData() Unfortunately, I can't read that data when I'm in the capture()-Method. I retrieve the InfoInstance and try to read the information, but it's not set.

assignData() method:

public function assignData($data) {
    if (!($data instanceof Varien_Object)) {
        $data = new Varien_Object($data);
    }

    $info = $this->getInfoInstance();
    $info->setEtixType($data->getEtixType());

    return $this;
}

capture() method:

public function capture(Varien_Object $payment, $amount) {
    // ...

    $info = $this->getInfoInstance();

    Mage::log('etix_type: '.$info->getEtixType());  //I expect something like "etix_type: cc"

    // ...
}

Any help is appreciated. I'm sure I missed something.

like image 220
aeno Avatar asked Sep 08 '11 15:09

aeno


1 Answers

Found it,

Assigning veriables directly to the InfoInstance works, but it does not persist through the whole checkout process. Instead, you have to set it on the additional_data:

$info = $this->getInfoInstance();
$info->setAdditionalInformation('etix_type', $data->getEtixType());

And later you can read it via:

$info = $this->getInfoInstance();
$etix_type = $info->getAdditionalInformation('etix_type');
like image 88
aeno Avatar answered Sep 28 '22 01:09

aeno