Amazon (AMZN -0.63%) has had a lot of success in India, one of the fastest growing markets for online commerce. The company saw more customers sign up for Prime in its first year of offering the shipping service in the country than it saw in the first year in any other country, and it's quickly become the second-largest online retailer in the country.

India's largest online retailer, Flipkart, is currently looking for investors. Amazon has put in a bid for a controlling stake in the company, but so has its U.S. rival Walmart (WMT -0.73%). Flipkart is reportedly favoring Walmart's bid thanks to the fact that it would have an easier time overcoming regulatory hurdles.

If Flipkart and its investors do agree to sell a stake to Walmart, it would be a big blow to Amazon. Not only would Amazon miss out on expanding its presence in one of the fastest growing e-commerce markets in the world, its chief rival would get a huge cash infusion to help it step up the competition.

Flipkart logo on its office building.

Image source: Flipkart.

The opportunity in India

India has a population of 1.3 billion people, and only 2.5% of its shopping takes place online. By comparison, the United States has a population of about 327 million and about 9% of shopping takes place online.

It's only a matter of time before more Indians start shopping online and making it a bigger part of their shopping habits. Simply increasing online shopping to a level equal with the United States would result in a 3- to 4-fold increase in online spending. Online sales could reach $100 billion as early as 2020, according to an estimate from Morgan Stanley analysts. For reference, that's less than the $453 billion Americans spent online last year, but it's still a massive opportunity.

Amazon, for example, saw sales of just $54.3 billion in markets outside of North America last year. Grabbing a significant share of the growing Indian market would help boost growth in that segment and help make the segment profitable.

Amazon notably only operates a marketplace business in India exclusively selling goods from third-party merchants due to government regulations on foreign companies. Amazon simply takes a cut of every sale and should produce high gross margins at scale.

For Walmart, Flipkart presents an opportunity to diversify its international e-commerce operations, which have often struggled to compete. It recently shuttered its first-party online operations in Brazil. In 2016, it sold its Chinese marketplace to

Amazon is already investing billions in India

Amazon has committed to spending $5 billion in India, mostly to build out the delivery infrastructure needed to operate its business effectively. Amazon ships orders itself in India, instead of relying on third-party delivery services like it does in other markets.

That's a huge upfront cost to building out its business, and it will take a long time for the investment to pay off. At the same time, Amazon is building a competitive advantage that will prevent smaller competitors from offering similar services like its Prime shipping benefits.

Amazon is also investing in building a Prime subscriber base. It introduced the program to the market in July of 2016 at a discounted annual rate of 499 rupees, which is less than $8. Even the full price, 999 rupees, is extremely inexpensive considering the value customers get -- unlimited shipping and Prime Video, among other Prime perks.

Indian Prime subscribers gained access to Prime Video along with the rest of the world in December of 2016, and Amazon stepped up its investment in India content throughout 2017. The company will reportedly double down on its Indian video content investment this year as it looks to attract even more subscribers. Its growing local content library and its low price have led Amazon Prime to become more popular than Netflix in India.

Of course, all of that investment in Prime is very likely producing a loss. At the same time, Prime represents another way to create a moat by making customers more loyal. Prime members in the U.S., for example, spend more on Amazon than non-members.

A cash infusion for Flipkart will make things a lot harder for Amazon

In a vacuum, Amazon's investments in infrastructure and Prime content are great. But if Flipkart takes billions of dollars in investment funds from Walmart, it could build out its own infrastructure and loyalty program. It would make the competition a lot more fierce, which means further pressure on profit margin for both companies even as the market is growing rapidly.

Amazon is happy to invest and lose money in the near term if it sees a long-term payoff, but it's already playing catch-up to Flipkart, which could make things very painful for Amazon if it receives significant cash infusion. If Flipkart goes with Walmart, it could cause Amazon to take another step up in its commitment to investing in India while increasing the uncertainty of the long-term payoff.