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

1 Answer 1


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();


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

I hope this will help

  • this one doesn't return the name of assigned payment method in customer.orders query for some reason
    – Herokiller
    Commented Jun 30, 2022 at 9:03

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.