I need to change order status to custom status if payment fails.
I tried to get order via $payment->getOrder()
, and tried to set state and status. I called save()
also. However It looks like not working. It is always saving order with 'processing' status. However, It saves comments when I run following functions using same method; addStatusToHistory
, addStatusHistoryComment
. Any idea how can I implement this?
class Payment extends \Magento\Payment\Model\Method\Cc {
...
fn(){
$payment->getOrder()->setState( 'holded' )->setStatus( 'custom_new_status' )->save();
Thank you.