If the other person at the restaurant was considered to be the buyer and customer, one is allowed to pay on his behalf. However, if he is paying for the other person, while considering himself to be party to the purchase, i.e. the actual buyer and customer, then he is not allowed to do so.