This paper presents a model of a card payment system as a two-sided market that allows for partial participation by heterogeneous consumers and merchants. Taking into account the strategic effects arising from competition between merchants, the model is used to characterize the optimal structure of fees between those charged to cardholders and those charged to merchants and, more specifically, the level of the interchange fee that banks charge each other. The results modify the existing characterizations of the interchange fee, and explain the source of potential deviations between the privately and socially optimal level of the fee.