Keith Power
Keith Power

Reputation: 14141

magento update Total Paid after payment

I have my own custom payment gateway which is working ok with one problem. When a transaction is successful the order gets updated and the email sent but the Total paid is still €0.

How do I update the paid status? I cannot find any articles on this.

Magento 1.7

public function responseAction() {
    if($this->getRequest()->isPost()) {

        if($payment_validated) {
            // Payment was successful, so update the order's state, send order email and move to the success page
            $order = Mage::getModel('sales/order');
            $order->loadByIncrementId($orderId);
            $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'AIB has authorized the payment.');

            $order->sendNewOrderEmail();
            $order->setEmailSent(true);

            $order->save();

            Mage::getSingleton('checkout/session')->unsQuoteId();

            Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
        }

Paid not updated

Upvotes: 4

Views: 1689

Answers (1)

mrGott
mrGott

Reputation: 1076

This answer might be little out of date but still someone might find it helpful. I myself found this question and wanted an answer for this one.

So i found a very helpful article at atwix and specifically I used:

        $orderId = 200000025; // you'll get your own Order Id
        $model = Mage::getModel('sales/order');
        $model->loadByIncrementId($orderId);

        $invoice = $model->prepareInvoice();

        $invoice->register();
        Mage::getModel('core/resource_transaction')
           ->addObject($invoice)
           ->addObject($invoice->getOrder())
           ->save();

        $invoice->sendEmail(true, '');


        if($model->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)) {
            $model->save();
        }  

So after this I got payment status to Paid in the backend and also changed the status to processing.

Now next step is to let customer know that he's order has been paid and I would like to do it via email.

Cheers!!

Upvotes: 2

Related Questions