The 26-year-old was the Swans' top scorer with 12 last season after signing on a free transfer from Marseille in 2015.
Ayew is now discussing personal terms with the Hammers.
Swansea hope to complete the signing of Atletico Madrid striker Borja Baston
to add to the arrival of Spain forward Fernando Llorente from Sevilla.
The Welsh club have also enquired about Leicester City's Argentine striker Leonardo Ulloa.
Forwards Alberto Paloschi, Eder and Bafetimbi Gomis have already left Swansea this summer.
Manager Francesco Guidolin admitted in July he was unsure about Ayew's future, but hoped he would stay.
Ayew did not score between 2 February and 1 May which coincided with a run of two wins in 10 matches, but finished the season with four goals in three matches as Swansea finished in 12th place.
West Ham have signed striker Ashley Fletcher, midfielder Havard Nordtveit, and wingers Sofiane Feghouli and Gokhan Tore this summer.