When a Ripple-Gateway charges a fee for third parties exchanging their IOU, how is it determined who pays the fee? When a Ripple-Gateway charges a transit fee for third parties exchanging their IOU, who pays the transit fee?
When a Ripple user sends funds, he sets the amount that he wants the recipient to receive and the system will offer a proposition on how much the input for the transaction needs to be. 

Upon execution the transaction is atomical (either it happens completely or not at all). The system will use the ledger to find the optimal path and the sender pays all transit fees occurring along the path.