From: Rabbi Moshe Sofer
To: Rabbi David Katz
Reuven and Shimon are business partners; a non-Jew made an error benefiting Reuven, and Shimon claims a share. The Chasam Sofer concludes that for voluntary partners the Rema's rule applies and all gains belong to the partnership, but since this rests on his own analysis rather than an explicit authority, and the Shach rules otherwise, we do not compel Reuven to pay; however, if Shimon already seized his share, it is not taken from him.
Source: Shu"t Chasam Sofer CM §47