2

I have payment processing on the checkout page on click of place order. I get the payment response on the same page. Now, I need to update the order status after the checkout form submission in the custom payment module. Does anyone know how to do it? Thanks in advance.

OR

Can I process the checkout form submission in the Controller Controller\Index\Index.php

1 Answer 1

0

Create file: etc/events.xml

<event name="sales_order_place_after">
    <observer name="sales_order_place_after_event" instance="Vendor\Module\Observer\SalesOrderPlaceAfter" />
</event>

Create Vendor/Module/Observer/SalesOrderPlaceAfter.php

public function execute(Observer $observer)
{
    /** @var Order $order */
    $order = $observer->getData('order');
    $payment = $order->getPayment();
    $order->setState('new');
    $order->setStatus('pending');
}
2
  • Can I post the additional parameters to this method from the checkout page? such as payment status
    – Garry
    Commented Nov 7, 2019 at 12:08
  • @Garry Yes. You can. But if need only payment info then you can get that from order. $payment = $order->getPayment(); Commented Nov 7, 2019 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.