PayPal, the payments unit of eBay, just dropped a cool $800 million on Braintree, a smaller rival. We hope it’s not done.

As we noted, Braintree will help PayPal boost its appeal to app developers, who have been frustrated with its older software and cumbersome customer-service operations.

But PayPal needs more pieces to really win the battle as e-commerce takes over the physical world.

I think one of those might just be Foursquare, the maker of a popular location check-in app.

Checking In To Retail

Braintree brought something special to PayPal: a foothold in apps that capture your credit card once and store it for future transactions. When you call a car with Uber and walk out at your destination without having to hand over your credit card, that particular bit of magic is handled by Braintree.

But PayPal has another big battle in mobile payments ahead of it—and that’s in signing up local stores to take PayPal, too.

It recently revamped its mobile app to emphasize local shopping and discounts. It’s easy to order a meal to go at a local restaurant and bill it to your PayPal account, for example.

The challenge, though, is persuading consumers to install the PayPal app and pop it open when they’re on the move. Sure, there are coupons and other offers, but it’s hard to see those providing enough value to persuade busy users to change their routines, when there are dozens of apps fighting for their attention.

Here's PayPal Beacon, a shopper detector for stores.

PayPal is also hoping to persuade merchants to install a piece of hardware called Beacon, which uses Bluetooth to identify when shoppers are nearby and let them automatically check into a store or restaurant, readying them to pay with PayPal just by saying their name.

I’m skeptical of the Beacon strategy. Small businesses operate in cramped environs, and while Beacon promises to be low-maintenance, even the spare wall plug it requires might be a scarce commodity in some stores.

Foursquare On The Money

This problem could be easily circumvented, because what Beacon does with hardware, Foursquare already does with software.

You may have heard of Foursquare’s eponymous app, which people use to broadcast their location to friends. But you may be less familiar with Foursquare’s near-ubiquitous presence within other apps. When you tag an Instagram photo at a location, for example, the photo-sharing service uses Foursquare’s database of locations to tag the image.

Foursquare CEO Dennis Crowley recently showed ReadWrite a detailed map of downtown San Francisco, with irregular polygons drawn around buildings. Those polygons represent a map built by the 4.5 billion check-ins Foursquare has logged to date, and that map is incredibly detailed, showing the outlines of a coffee shop within a mall.

That’s the same fine-grained detail that PayPal CEO David Marcus recently told ReadWrite he wants to capture with Beacon. But Foursquare is doing it by amassing stores of data across a host of connected apps, not requiring merchants to install a proprietary piece of hardware and consumers to download the PayPal app.

What Foursquare Offers PayPal

Buying Foursquare would do four things for PayPal:

It would give PayPal a large, user-updated database of local businesses to which it could market its payment services.

It would give PayPal another product to sell those businesses besides payments—Foursquare’s still-nascent but fast-growing advertising business, where it places ads within the Foursquare app.

It would boost PayPal’s appeal to mobile-app developers, by giving them another resource, Foursquare’s location database, to incorporate within their own apps.

It would add teams of experienced mobile developers in New York and San Francisco—markets where it’s famously difficult to recruit talent.

When you consider how PayPal is trying to expand its business, from Web-based e-commerce to app-driven local and mobile payments, a deal to buy Foursquare makes more and more sense.

As to why Foursquare might sell: It’s time. The company had to borrow $41 million earlier this year instead of raising a round of equity, because its investors could not agree on how to value its brand-new advertising business. It’s been named a possible acquisition target by everyone from Google and Yahoo to Microsoft and Apple.

Compared to those buyers, though, PayPal seems like it might be a more benevolent owner, less likely to squash Foursquare by integrating it into existing maps and commerce services. Foursquare considered offering payments services early in its life, but decided to avoid the cost and complexity—so while there’s good strategic fit, there’s relatively little overlap. And PayPal’s Marcus, an entrepreneur who sold a mobile-payments startup to PayPal before becoming an executive there, seems to want to leave the startups he buys alone as much as possible, rather than ruin them by integrating them too quickly.

So get out that wallet, Marcus. You’ve got some shopping to do.