title: Mark a Magento order as complete programmatically
body: <p>I'm trying to mark a "Processing" order as Complete when I get a certain response back from a third party service. I've got everything set up for this, but the only problem is that orders are staying in the Processing state.</p>
  
  <p>I'm generating an invoice (I don't think I need this though, as each item is marked as "invoiced" in the Magento backend) and a shipment like so:</p>
  
  <pre><code>$order = Mage::getModel('sales/order')... (etc)
  $shipment = $order-&gt;prepareShipment($quantities);
  $shipment-&gt;register();
  $shipment-&gt;setOrder($order);
  $shipment-&gt;save();
  
  $invoice = $order-&gt;prepareInvoice($quantities);
  $invoice-&gt;register();
  $invoice-&gt;setOrder($order);
  $invoice-&gt;save();
  </code></pre>
  
  <p>This doesn't seem to be doing it though - I get no errors back from this code, but the order remains as processing. In the backend I can still see the "Ship" button at the top of the order, and each item is in the "invoiced" state.</p>
  
  <p>Any tips would be greatly appreciated.</p>