i would like to set order to complete programmatically after they have been processed in another software. This is the typical code i found all over the internet:

$orderId = 1000120319;
$order = $objectManager->create('\Magento\Sales\Model\Order') ->load($orderId);
$orderState = \Magento\Sales\Model\Order::STATE_COMPLETE;

All i get is this result:

Uncaught Magento\Framework\Exception\LocalizedException: Please provide payment for the order.

What i have to do, to set the payment completed as well? Thanks for your help in advanced

Best regards

2 Answers 2


Use loadByIncrementId instead of load.


I'm pretty sure you'll need to create an invoice for it first, though I don't have code handy for that. Here is an example solution for that: https://webkul.com/blog/how-to-programmatically-create-invoice-in-magento2/

  • thanks for your advice. that was my first idea. But $order->canInvoice() is false and if we try to create an invoice anyway we will end with "Uncaught Error: Call to a member function canCapture() on null"
    – Luco
    Nov 19, 2020 at 19:15

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.