The mishnah before us (daf 30, mishnah 12) is the fourteenth and final mishnah of the chapter, and it opens with the very same words with which the previous mishnah opened: a Jew who prepares kosher wine under his own supervision and in his own presence, but in the plant and on the premises of an idolater. How is such a thing possible?
In the previous mishnah we learned two criteria: that the place be open to supervision, and that the supervision be carried out by Jews. When that situation does not exist, one is obligated to hire a watchman on site. We also noted the dispute as to whether it makes a difference that the wine is stored on the premises of a different non-Jew, one who is not the owner of the plant: the Tanna Kamma holds that this makes a difference, while Rabbi Shimon ben Elazar holds that the two non-Jewish premises have the same status. This dispute applies to this part of the halachah as well.
The third condition in our mishnah:
According to the Bartenura, who learns like Rashi, our mishnah adds a third condition that must be met for the wine to be kosher, beyond what has been said so far. When a Jew prepares kosher wine in a non-Jew's winery, the non-Jew is required to hand him written authorization, a sort of receipt, which states: "I have already received payment from you". Even if in fact the Jew has not yet paid, he holds a document testifying that he has already paid - and the meaning of this is that he may take the wine whenever he wishes, without needing permission from the non-Jewish owner.
What is more: now the non-Jewish owner has a great deal to lose, since the Jew has a monetary claim on the wine. Previously the non-Jew could say to himself: "It is not so terrible; if the Jew catches me, I simply will not give him the wine and I will sell it to non-Jews". Now this is not possible, since the Jew holds a contract or a receipt on the basis of which he can collect. Once this third condition is met, together with the two conditions of supervision in the previous mishnah, that is enough for the wine to remain kosher.
But if the situation is that when the Jew comes to take his wine the non-Jew does not let him until he pays for it (and the vav in the wording of the mishnah here is in doubt, and means "or") - the non-Jew has the upper hand the entire time. He has almost nothing to lose if ill will is created on the part of the Jew because he handled the wine. This is exactly what happened in Beis She'an, and it is stated there that the wine was forbidden.
The reason for the prohibition is the same reason we saw several mishnayos earlier: the non-Jew stands over the wine and we do not know what he did with it. Just as when he holds a loan and the wine is pledged to him he has some claim on it, and we are concerned that he handled it and it became forbidden for benefit - so too here: if the Jew does not hold a receipt showing that he already paid, the non-Jew can claim that he has a financial claim on the wine; therefore we do not know what he did with it, and it is forbidden for benefit.
The view of the Bartenura (like Rashi) - three conditions:
That there be a possibility of supervision.
That the supervisors be Jews.
That the Jew hold a contract testifying that the wine is already his, that he paid for it, and that he may take it whenever he wishes.
And if it is impossible to fulfill the first two conditions - because there are no Jews in the city, or because there are no windows in the house where the wine is stored - one can hire a watchman in their place. Alternatively, according to the Bartenura and Rashi, one can lock the door and place a seal on the barrel, in a manner that makes it impossible to break in without the matter being detected; the lock and the seal come in place of the watchman. And as long as the Jew also meets the third condition, that he holds a contract testifying that he already paid, the wine will be kosher.
The view of Rabbeinu Tam:
Rabbeinu Tam rejects this understanding entirely. In his view, it is self-evident that the wine is locked with a key and sealed with a seal that the non-Jew cannot tamper with; without that there is no discussion at all, since we do not know what happened. But even if the barrel of wine is sealed and the room in which it is stored is locked with a key held by the Jew, and seemingly the non-Jew cannot get to it - that is not enough, and in addition one of two situations is required.
Either the situation described in the previous mishnah - the wine is locked and sealed, and in addition it stands open to a public thoroughfare where Jews can observe it, or it is locked and sealed with a watchman keeping an eye on it. And if there is no supervision at all, it is enough to have the situation of our mishnah - the wine is locked and sealed, and the Jew holds a contract showing that he has already paid for it and that he may collect it whenever he wishes. Either this or that.
The practical halachah:
The Shulchan Aruch: The halachah leans more toward the approach of Rabbeinu Tam - the wine must be sealed and also locked with a key, and then, if there is supervision over it, whether because it stands open to public view, or because Jews come by there from time to time, or because a watchman has been appointed, it remains kosher.
The Rema: After the fact, if it was sealed or locked with a key and there was Jewish supervision over it, even though people are coming and going, that suffices. And likewise, if the Jew held a receipt showing that he had already paid for the wine, and the wine was kept sealed and locked in a place to which only the Jew has access - it is kosher even without ongoing Jewish supervision.
The Vilna Gaon: He is even more lenient: if there are two seals on the wine, the lock and the key, then even without supervision and even without a contract in the Jew's hand, that is enough to know that no one touched it, and the wine is permitted.
In summary: Our mishnah adds, according to the Bartenura following Rashi's approach, a third condition for the kashrus of wine produced on a non-Jew's premises - a receipt or contract in the Jew's hand testifying that he has already paid and that the wine is his. Without it we suspect that the non-Jew handled the wine because of his monetary claim against it, as in the incident that occurred in Beis She'an. Rabbeinu Tam disagrees and holds that locking and sealing are the basic condition, and in addition to them either supervision or the bill of payment is required. The halachah was decided essentially according to Rabbeinu Tam, together with the Rema's leniencies after the fact and the Vilna Gaon's broad leniency in the case of two seals.