Visa, Mastercard and a few banks that issue credit and debit cards agreed to pay an additional $900 million to settle a class-action lawsuit over card-swipe fees.

The $900 million will be tacked onto the $5.3 billion paid to merchants in 2012. Visa's share of the additional settlement payment is $600 million, while Mastercard agreed to pay $108 million on a pretax basis, according to Securities and Exchange Commission filings. The rest will be paid by the other defendants in the suit, which include Bank of America, J.P. Morgan Chase and Citigroup.

Mastercard shares rose 1.7 percent while Visa's stock gained 1 percent.

The class-action lawsuit was filed in 2005 by merchants who alleged card companies set credit-card fees and card-acceptance rules that benefit the banks. The suit said, for example, Visa and Mastercard would set the fees and banks would then charge the merchants. Merchants said in the suit they would rather negotiate the fees directly with banks.

The settlement, which was signed on Monday, also states that up to $700 million may be returned to the defendants if more than 15 percent of the merchants opt out of the class. It also says the defendants may terminate the amended settlement if more than 25 percent of the class members opt out.