programmatically add line item of commerce_discount type to order
Don't reinvent the wheel, here. Discounts provides functions for apply discounts to orders: 

// Pass in an $order or $product that has been entity_metadata_wrapper()ed.
// And pass in a discount name.
commerce_discount_fixed_amount(EntityDrupalWrapper $wrapper, $discount_name);

// Same thing, but a percentage.
commerce_discount_percentage(EntityDrupalWrapper $wrapper, $discount_name);


If you must reinvent the wheel, use these functions as examples to guide what you are doing.