You're allowed to show different content based on referrers, just not if the user-agent is googlebot.
Googlebot's referrer is google.com, so it is able to bypass the paywall, just like anyone else clicking off google.com
You're allowed to show different content based on referrers, just not if the user-agent is googlebot.