The 29-year-old former Manchester United player will now fly to London to finalise personal terms and have a medical with the Hammers.
Meanwhile, Austria forward Marko Arnautovic is due to have a medical in the next 48 hours after West Ham agreed a deal with Stoke City.
It is understood Stoke have accepted a fee in the region of £24m.
In May, Hernandez - widely known by the nickname Chicharito, which means 'little pea' - became Mexico's leading all-time scorer with his 47th international goal.
Hernandez scored 59 goals in 156 appearances for United after arriving at Old Trafford in 2010, before joining Leverkusen for £7.3m in August 2015.
He has netted 39 times in 76 matches for the German club.
Arnautovic, 28, joined Stoke from Werder Bremen four years ago and is just 12 months into a four-year contract with the Potters.
He scored seven times in 35 games in all competitions last season.
West Ham signed Manchester City and England goalkeeper Joe Hart on a season-long loan deal on Tuesday.
Media playback is not supported on this device
Find all the latest football transfers on our dedicated page.

Britain remained firmly opposed to any move towards creating an EU army, Sir Michael Fallon said, as it would simply undermine Nato.
And yet it wasn't on the agenda when EU defence ministers met in Slovakia and barely anyone is talking about the idea. There are no plans for legions of Eurotroops decked out in helmets emblazoned with yellow stars on a blue background.
UK will oppose plan for 'EU army'
Juncker proposes EU military HQ
Brexit vote revives EU army dream
It's difficult, indeed pointless, to oppose something that doesn't exist and isn't being suggested. But that's the problem with the argument over the EU's future military capabilities; for now it's a battle of semantics, a war of words.
Instead the official agenda here in Bratislava spoke of "the EU Global Strategy and its synergies and sequencing with the Commission-led EDAP".
But for Sir Michael Fallon there's already much to dislike.
France and Germany presented proposals that would include joint development of military hardware such as helicopters and drones, expanding the EU's peace-keeping missions and, most contentiously of all, establishing a permanent joint European military HQ.
"We will continue to oppose any kind of duplication like that, or any unnecessary bureaucracy that cuts across the primary mechanism for defending Europe, which is Nato," Mr Fallon told reporters.
He was by no means alone in opposing such "bureaucratic duplication", he said.
Germany insists that the idea has nothing to do with a European army.
"It is not aimed against Nato," said Defence Minister Ursula Von der Leyen. "On the contrary, we need a strong Europe and whatever strengthens Europe in defence also strengthens Nato."
And those words were underlined by Nato Secretary General Jens Stoltenberg, who told reporters at the meeting that there was "no contradiction between strong European defence and a strong Nato".  The importance lay in avoiding duplication, he said.
When he stepped out of the meeting, the UK defence secretary said that 12 countries had spoken and half were against the EU military headquarters, including Sweden, the Netherlands, Poland, Latvia and Lithuania. The BBC couldn't immediately verify that.
EU foreign affairs chief Federica Mogherini said after the informal summit that "in our three hours discussion on this topic with all the ministers, I never heard once the word 'veto', I never heard once the word 'blocking', and I never heard once the word 'army'," she said.
Primarily Sir Michael said he remained sceptical about European willingness to stump up the cash for new defence projects when only a handful of European countries met their existing defence budget obligations to Nato.
"The real issue is whether they're prepared to step up to the 2% (of GDP on defence spending) as we already have," Mr Fallon told reporters.
"There are half a dozen of them in that room who don't spend 1%," he said, explaining why he was cool towards Europe's common defence ambitions.
"Europe is full of Eurosceptics now. We are all Eurosceptics."
West Ham have agreed a deal with German club Bayer Leverkusen to sign Mexico striker Javier Hernandez for £16m.
[NEXT_CONCEPT]
The UK defence secretary was adamant.