With the rise of online shopping and the ubiquity of smartphones, more consumers are using technology to make their purchases than ever before. This has led to a so-called war on cash -- where consumers use physical money less and less -- and isn't likely to end any time soon.

To benefit from this massive shift, investors need only to look to Square (NYSE:SQ), PayPal (NASDAQ:PYPL), and Mastercard (NYSE:MA), which are all knee-deep in building a cashless society. Here's how each company is benefiting from this trend.

Woman holding phone over a payment terminal.

Image source: Getty Images.

Square

Square has built out its position in the cashless society with its payment terminals, found on the counters of millions of merchants, and with its Cash app. Square has seen phenomenal growth as the company has provided merchants and consumers with innovative payment solutions.

For example, the company's Cash app not only allows people to send money to their friends, but has been expanded to allow users to invest their money as well. The Cash app now has 15 million users, and revenue from the app (excluding bitcoin revenue) reached $159 million in the most recent quarter, up 115% year over year.

Square's total revenue grew 44% in the third quarter, and its gross payment volume (GPV) increased by 25%. The company may be smaller than PayPal and other peers, but investors should take note of Square's growth and its ability to continually add more merchants and users to its ecosystem.

PayPal 

PayPal is one of the leading facilitators of online payments, and the company's recent moves have helped set itself up for an even stronger position in the fintech market in the coming years. 

For example, PayPal used to be seen as a competitor to other payment platforms from credit card companies and banks. But over the past few years, the company has forged partnerships with former competitors.

Additionally, PayPal has wisely pursued new payment trends, including peer-to-peer payments through its Venmo aoo. Venmo allows users to pay each other through its app easily, and it's helping PayPal tap into the growing P2P payment market, which is expected to reach $396 billion in transactions this year.

To understand just how well PayPal is performing in the payment processing market, consider that in the most recent quarter the company's total payment volume -- the amount of money processed through PayPal's platform -- increased 25%. If that's not impressive enough, sales also increased by 19% from the year-ago quarter, and PayPal's active accounts increased by 16% to 295 million.

Mastercard

While tech companies are often at the forefront of the war on cash, don't think that traditional players are losing out on this trend. Mastercard is benefiting from e-commerce and digital payments just as much -- and probably even more -- than flashier tech companies. 

That's because Mastercard's vast payment infrastructure has already been set into place for decades. The company collects a small transaction fee when its Mastercards are used, and those fees add up very fast. Mastercard's revenue in the most recent quarter was $4.5 billion, up 15% from the year-ago quarter.

With millions of people already using Mastercard's products, and digital payments and e-commerce still in their infancy, the company is in the perfect position to continue benefiting from this trend. With the company's stellar position in the payment market, there's little reason to doubt Mastercard's continued potential to grow. 

Remember this

Each of these companies represents a different angle for investors to benefit from the war on cash.

Square is a scrappy young company that's taking on bigger, more established players, while PayPal continues to make its payment processing platform more ubiquitous than ever before. And finally, Mastercard offers investors a way to benefit from digital payments and e-commerce transactions in a way that nearly no other company can match.

Whichever way investors choose to benefit from the war on cash, just remember to keep a long-term perspective on your investment, and be willing to ride out rough quarters when they come along.