How to add Line Items functionality to a custom module?

Take a look at this post for some ideas: