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.
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With