Everything works fine if i use this structure:
function create_order_with_custom_products()
{
    $orderGenerator = new OrderGenerator();
    $orderGenerator->setCustomer(6907);
    $orderGenerator->createOrder(array(
        // Add configurable product
        array(
            'product' => 30151,
            'qty' => 1
        ), array(
            'product' => 30150,
            'qty' => 2
        ),
    ));
}
If i create an array and use it like that:
$ItemsId = [];
if(!empty($ItemsInCart) && count($ItemsInCart)>0)
{
    foreach($ItemsInCart['productid'] as $key=>$value){
        $ProductId = $value;
        $ProductQty = $ItemsInCart["productqty"][$key];
        $product_id = $ProductId; // Replace id with your product id
        $qty = $ProductQty; // Replace qty with your qty
        $ItemsId[] = ["product"=>$ProductId,"qty"=>$qty];
    }
}
function create_order_with_custom_products()
{
    $orderGenerator = new OrderGenerator();
    $orderGenerator->setCustomer(6907);
    $orderGenerator->createOrder($ItemsId);
}
If i print_r($ItemsId); i receive the following output:
Array ( [0] => Array ( [product] => 30143 [qty] => 1 ) [1] => Array ( [product] => 30144 [qty] => 2 ) [2] => Array ( [product] => 30145 [qty] => 3 ) [3] => Array ( [product] => 30146 [qty] => 4 ) [4] => Array ( [product] => 30147 [qty] => 5 ) )
It is no longer working. And i do not see the reason.
The code of createOrder function you can see here: http://pastebin.com/0iUbZpHU
Can you please tell me where is my mistake and why my code is not working.
 
    