Magento Payment Info Block

2019-04-16 08:57发布

问题:

I have created new payment method (gateway). In this gateway I sending information to bank for credit payment and I use some additional payment options like Name/Person Age/Person Profit/Credit Term/...

By this fields I calculate Credit Term and send all of this data to bank.

I would like to show this information in Payment Method info block (right sidebar in default theme), but I would not like to save this fields to database (so in admin area later I will have information like it was standart Check/Money Order payment and just payment method name would be another)

I can't show this fields in Payment Method info block, because it shows only fields stored in database and only way that I found - store this data in core/session and then in info block retrieve this data back

I doing something like this in Payment Model:

class OS_LacPayCS_Model_Payment extends Mage_Payment_Model_Method_Abstract
{
...
public function assignData($data)
{
    parent::assignData($data);
    $session = Mage::getSingleton('core/session');
    $session->setData('payment_additional', $data);
    return $this;
}
...
}

and then getting it

class OS_LacPayCS_Block_Payment_Info extends Mage_Payment_Block_Info
{
...
public function getPaymentInfo()
{
    $session = Mage::getSingleton('core/session');
    return $session->getData('payment_additional');
}
...
}

Is there another way to get this data?

And also I wish to add some additional rows in Order Review Tab on checkout, how can I add them w/o rewriting review template and block?

Thanx

回答1:

Magento payment api defines additional_information field that is saved as serialized array to db and that you can use for storing the data you might need to display. You can set data to there by assignData($data) method