Unfortunately a full out victory is impossible. Texas is in firm American hands by now. It was annexed a few month prior to the war. Mexico's hold on Norther California was quite bad, the are hadn't been fully mapped. Most of the outpost north of San Fran Bay were American. While Utah was already being settled by Mormons.
Secondly despite what most American elementary history text books say, Mexico wasn't a power. It was was large, yes, but it was disunited unstable, and by all definitions a failed state at this point.
You need to change this.
This is somewhat easy to do. Have Winfield Scott really, really bugger the Battle of Churubusco with Mexico having a little less infighting and Scott's entire army is defeated and destroyed. The end.
Churubusco is a bit too late. The entire east coast of Mexico is occupied by this point. Taylor's army has made it all the way to Tampico and Veracruz, Scott is inside the Mexico City Valley (Churubusco is the southern edge of it), Kearney has made it to South California, as has Fremont, while Stockton is blockading the entire Pacific coast.
To stop Scott you need Puebla not to declare neutrality and stop him at Puebla or before he reaches Cuernavaca. From there it is easy to break his supply line to Veracruz. But you also need to stop Taylor, Monterrey can hold and if it does it probably diverts Kearny as well. Without Kearney Fremont and Stockton wont have enough men to quell the Southern Alta California rebellions.
If you manage all this. The best Mexico can get is a border around the 37-38th parallel, (basically around Arizona & New Mexico's northern border). And the Nueces and Pecos strips in in Texas.
This would anger Southerners in the US a lot. Perhaps an earlier attempt at secession? Texas would certainly feel betrayed by the US and cheated. And they might declare their annexation invalid. If they mange to get independence from the US, they be stuck between a revanchanist Mexico with whom they have border conflicts and a sour US. Unless the south is able to secede they might have to choose between the lesser of two evils.
You might see a "Republic of California" at some point breaking aay from Mexico after a large immigrant influx due to the gold rush. But I'd this is 50/50 since the US is likely to already hold the northern half which is the gold rich half.
For Mexico, little changes. The Reform War between liberals and conservatives will still happen. Perhaps a little earlier and not as violent. The Second Empire with Maximilian would probably be butterflied away. However since Mexico did not suffer the humiliation of OTL it might stabilize sooner, it all depends on who get the credit for keeping the gringoes away.
If you are interested read the TL on my sig.