I didn't accomplish adding items to an order (after the checkout stage) and having the payment module aware of them.
As pointed out in Fooman's answer, this was most likely caused by the getAllItems result being cached before I'd added the items to the order.
This was probably a BAD way to go about doing the task anyhow, adding items on to an order after the customer has completed the checkout just seems tacky.
I thought it was the only way, but I've managed to add the products to the cart and override their standard pricing and such as I was trying to do.
The trick was to use the observer checkout_cart_product_add_after and set flags on the quote object so I knew what was going on the next time the observer fired.
Here is an example of a way to add product ID 101 with a custom price to the cart when a customer buys product ID 100. I hope this will help someone.
public function checkout_cart_product_add_after(Varien_Event_Observer $observer) {
$this->log('Observer: checkout_cart_product_add_after');
$cart = Mage::getModel('checkout/cart');
$cart->init();
$quoteItem = $observer->getQuoteItem();
$quote = $quoteItem->getQuote();
$my_flag = $quote->getMyFlag(); // Grab the flag, if it's been set yet
if($my_flag == "adding bonus") {
// If we're here we know that this time the observer was fired after we added our bonus product to the cart
$my_price = $quote->getMyPrice(); // Get the price that was set last time the observer fired
$quoteItem->setIsSuperMode(true); // You need to set this to override a product price
$quoteItem->setCustomPrice($my_price); // Set your override price here
$quoteItem->setOriginalCustomPrice($my_price); // And here
$quoteItem->save(); // Save the item so the new price will stick in the cart
} else {
// If we're here we are processing/observing a normal "add to cart"
if($quoteItem->getProduct()->getId() == "100") { // Check if the product being added is the ID we want to add a bonus for
$quote->setMyFlag("adding bonus"); // This is how we'll know the next time the observer fires that we need to override the price
$quote->setMyBonusPrice(5.00); // Here is a way you can store the price you want to override it to (we'll grab this value next time the observer fires)
$bonusItem = Mage::getModel('catalog/product')->load("101"); // load the bonus product
$params = array(
'product' => "101",
'qty' => "1"
);
$cartItem = $cart->addProduct($bonusItem,$params); //Add it to the cart - this will fire the observer again... but this time with the flags we set earlier.
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}
}
}