Reputation: 273
In my custom module, I changed the table sales_flat_order_payment
and sales_flat_quote_payment
and added two new fields:
$installer->run("
ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `ep_entity` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `ep_reference` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `ep_entity` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `ep_reference` VARCHAR( 255 ) NOT NULL ;
");
In my model , there is the following function that will make the client redirect to my custom success page:
public function getOrderPlaceRedirectUrl() {
return Mage::getUrl('mymodule/mymethod/success', array('_secure' => false));
}
In the controller, there is the following function:
public function successAction()
{
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
$order->setEpReference('123456');
$order->save();
}
The problem is that no data is recorded on the sales_flat_order_payment
table in the ep_reference
field.
How to write data to sales_flat_order_payment
table in a custom field?
I don't want to add custom fields in the form, the custom field is automatically populated after the payment is completed.
Upvotes: 3
Views: 1465
Reputation: 273
I found the solution:
public function successAction()
{
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
$payment = $order->getPayment();
$payment->setEpReference('123456');
$paymentQuote = $quote->getPayment();
$paymentQuote->setEpReference('123456');
$paymentQuote->save();
$order->save();
}
Upvotes: 4