This year has been challenging for investors, with the S&P 500 and the Nasdaq Composite indexes slipping into bear markets. Persistent inflation and rising interest rates have taken center stage, dragging down nearly all asset classes.

A bear market can be a scary time for investors. Nobody likes seeing their portfolio going down. However, at times like this, it helps to think like Berkshire Hathaway (BRK.A 1.01%) (BRK.B 1.25%) CEO Warren Buffett.

Buffett achieved his (and Berkshire's) decades-long success by thinking about the long term and owning companies (or stocks in companies) for years or even decades. you would do well to follow his investing techniques and focus on quality companies, building up your positions slowly rather than trying to time a market bottom. Bear markets offer opportunities to buy stocks at discounted prices, and two Buffett stocks you could invest $1,000 in today that trade at a discount are Visa (V -0.56%) and Ally Financial (ALLY 0.67%). Let's take a look at why these two Buffett stocks are great long-term investment options.

1. Visa

Visa helps people in more than 200 countries move their money via debit cards, credit cards, and other payment products. Nearly 49% of American adults had a Visa card as of 2020, while about 39% have a Mastercard and 15% have an American Express. This gives Visa a sizable lead in the payment-processing space: In 2020, the company processed a total volume of $11.4 billion, outpacing Mastercard and American Express, which processed $6.3 billion and $1 billion, respectively.  

The payment company has a sizable lead over the competition because of its widely accepted cards. Not only that, but Visa continues to innovate and expand its offerings to stay ahead of the competition.

Its business model is relatively asset-light, meaning the company doesn't need to invest much of its capital in assets. As a result, Visa has very high profit margins, averaging 44% over the past decade. It's also a money-making machine, generating over $16 billion in free cash flow over the past year. The company can use this cash to make acquisitions, pay dividends, or buy back its stock.

V Profit Margin Chart

Data by YCharts.

Visa stock has performed well, and in the first nine months of its fiscal year, its net revenue was up 22.6%, and net income grew by 26%. The company keeps performing despite high levels of inflation, which CEO Al Kelly has said, "net-net, historically, inflation has been a positive for us." Because the company earns fees as a percentage of payment volume, rising costs of goods and services increase transaction size, helping Visa rake in more fee income.  

Visa's long-term prospects look bright. According to a study by BlueWeave Consulting, the global digital payment marketplace will grow 12% annually through 2028. However, it does face increasing competition from the likes of PayPal Holdings and major banks from their money transfer service, Zelle.

To protect its top spot, Visa has acquired fintech partners that enhance its existing business. It looked to break into the open banking space by buying Plaid for $5.3 billion in 2020. However, regulators shot down the deal, and Visa instead acquired Tink for $2.1 billion, an open banking network in Europe.

Open banking could be the future of finance. According to Allied Market Research, the open banking market allows nonbank companies to build financial products and is projected to grow at 22% annually through 2032. By acquiring Tink and staying one step ahead of the competition, Visa is in an excellent position to continue delivering for its investors.

2. Ally Financial

Ally Financial is an all-digital consumer bank that specializes in automotive lending. Warren Buffett increased Berkshire's stake in the bank in the second quarter by buying 21 million shares. Berkshire's $1 billion stake gives Buffett and Berkshire over 9% ownership in the bank. Ally Financial trades at a low valuation, and its price-to-tangible-book-value ratio of just 0.93 is likely one reason Buffett upped Berkshire's stake.

The bank benefited from shortages in used cars in the past couple of years, which increased the costs of used vehicles. In the second quarter, the bank originated $13.3 billion in auto loans, its highest quarter of originations since 2006.  

Smiling people are in a car together.

Image source: Getty Images.

Ally also benefited from higher interest rates. The Federal Reserve has raised its federal funds rate from near 0% to 2.5% since March, pushing funding costs up for all loans. Ally's net interest margin, the difference between the interest it earns on its loans and the interest it pays on deposits, improved from 3.55% last year to over 4% in the second quarter.  

Ally Bank has benefited from being one of the first all-digital banks, with its deposit customers growing 20% annually since it was founded in 2009. According to Allied Market Research, the digital banking market is forecast to grow at 13.6% annually through 2027. Ally believes its purpose-driven culture will help it continue to grow in the digital banking space. This, coupled with the bank's growing suite of products like Ally Invest, its brokerage product, and Ally Lending, should provide it with multiple avenues of growth in the coming years.

Another thing to like about Ally is how much cash it returns to its shareholders. This year the bank has spent $1.2 billion buying back its stock and paid out another $259 million in dividends. Ally stock trades below book value, giving the stock a good margin for safety, and its dividend yield of 3.56% makes it a solid investment for those looking for passive income.