Economists view two part tarifs as a means to the end of price discrimination in partially or fully monopolistic markets. The way it works is the producer charges the consumer surplus as a 'cover charge' and then has a per unit charge that is the marginal cost of the unit.
For example, imagine a restaurant that can produce spagetti for a marginal cost of $1 a plate. A customer comes in who is willing to pay $3 for the first plate, $2 for the second plate, $1 for the next plate and $0 for the fourth plate. If the restaurant charges $1 for a plate of spagetti, then the customer will buy three plates of spagetti for $3 and will get a consumer surplus of $3 (since they get a consumer surplus of $3-$1 = $2 for the first plate and $2-$1 = $1 for the second plate and $1-$1 = $0 for the third). If the restaurant charges $2 for a plate of spagetti, then the customer will buy two plates at $2 for a consumer surplus of $1. The producer will get $2 of producer surplus (2*($2 - $1) or amount sold * (price - marginal cost)). That is the best the producer can do with a single price. However, if they can charge a two part tariff, then the restaurant can charge $3 to enter the restaurant and $1 per plate of spagetti. The customer will pay the $3 to enter the restaurant (since they get $3 of consumer surplus from buying spagetti at $1 a plate) and then buy three plates of spagetti, for a net consumer surplus of $0. The restaurant gets $3 of producer surplus from the entrance fee, which is better than they can do with a single price.
In short, the way two-part tariff's work is the producer charges the consumer surplus as an entrance fee or cover charge, and then just charges the marginal cost for each unit of the good. This theoretically allows the producer to capture all of the consumer surplus.
In reality, the producer does not know the consumer's demand curve (a.k.a. their willingness to pay) and there is a transaction cost associated with collecting the money twice. Also, each consumer will have a different individual demand curve, so if there is just one cover charge or entrance fee, some of the customers will get some consumer surplus and some will decline to enter even though they would have been willing to pay some lesser entrance fee (since the entrance fee can be above their consumer surplus for getting the good at its marginal cost) so the producer cannot capture all of the consumer surplus.