You need to call payment->setOrder from order->addPayment, or the opposite. But end dev should not be forced to call both of them.