2

Is there a way to update payment method of order in magento 2 via dependency Injector or Object factory without using raw sql query?

5

You need to load order instance either from order entity_id or increment_id. After that, try these code. I haven't tested these code

$payment = $order->getPayment();
$payment->setMethod('yourpaymentmethodcode');
$payment->save();
$order->save();

or

$order->getPayment()->importData(['method' => 'yourpaymentmethodcode']);
$order->save();

I hope this will help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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