Checkout page not found when order created through Drupal Commerce API for not authenticated (anonymous) user
You need to add the order to the session, see commerce_checkout_access().

Something like this should work:

$_SESSION['commerce_cart_orders'][] = $order-&gt;order_id;


between saving the order and redirecting.