Banks and credit-card companies are discussing ways to identify purchases of guns in their payment systems, a move that could be a prelude to restricting such transactions, according to people familiar with the talks.

The discussions are preliminary but could be deeply controversial. Gun-rights groups have long resisted any effort to monitor which Americans own guns; there are federal laws limiting the government’s use of electronic databases of gun sales.