We cannot provide advice or tutorials on general programming techniques, but you may want to research PayPal IPN handling, since our Integration feature is designed to exactly match the PayPal IPN data format, such that most ready-made scripts designed to handle IPN should be able to handle our Integration submissions with little or no modification. Just leave out or disable any parts that would try to validate the IPN with PayPal (which would fail since we are not PayPal) and make sure the script can handle or ignore some extra fields we add to the basic IPN data set, such as 'item_cart_position'.
Regardless of whether we're submitting to your Common Notification URL or to a product-specific Payment Variable Information URL, we always include the full order data for all items in the order. We only include the 'item_cart_position' in submissions to a product-specific Payment Variable Information URL, so you can tell which item in the order triggered that particular submission to that URL.
You will only ever see 'item_name', 'item_number' etc. without a numeric suffix ("X") when there's only one item in the order; in that case we will send the same data for that one item as both 'item_name' and 'item_name1', 'item_number' and 'item_number1', etc. For orders with more than one item, the first item's field names will be suffixed with "1", the second items with "2", etc.