I've never messed with this kind of stuff, but I'll throw out a wild guess for you for something to try.
I was looking at ..\data\npc\lib\npcsystem\modules.lua and theres a function
function ShopModule:callbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
I think it may be called when trying to purchase something through npc trade window, it handles the cost in there.. maybe this might be what you're looking for?