Gauge invariance and Feynman path-integrals Let me look at the Hamiltonian of a charged particle in a plane in a constant magnetic field ($\vec{B}$) pointing upwards - then in usual notation it is,
$$\hat{H} = \frac{1}{2m}\biggl(\hat{p} + \frac{e}{c}\hat{A}(\hat{r})\biggr)^2$$
To convert this in a Feynman-path-integral language, I pick say a gauge $\vec{A}=(-\frac{B}{2}y,\frac{B}{2}x)$and then in this gauge $\hat{p}$ and $\hat{A}$ commute and that makes rewriting in the path-integral language much easier. 
If I put this through the usual process of "deriving" a Feynman path-integral then I would get the expression, 
$$\int \bigl[\mathcal{D}\vec{r}\bigr]\bigl[\mathcal{D}\vec{p}\bigr] \exp\biggl[i \int dt \biggl(\vec{p}\cdot\dot{\vec{r}} - \frac{1}{2m}\Bigl(\vec{p}+\frac{e}{c}\vec{A}\Bigr)^2\biggr)\biggr]$$


*

*Is it obvious (or true ) that the above expression is independent of the gauge I chose to the calculation? Is there a way to write the system in the path-integral language without explicitly choosing a gauge? (I have worked through calculations in Yang-Mills theory in the Fadeev-Popov gauge which does exactly that in those cases but I can't see a way out here...) 

*Can't I have written down the above path-integral without even going through the usual process of finding infinitesimal transition amplitudes and then collecting them together? I mean how often is it safe to say that for a Hamiltonian $H(p,q)$ the path integral representation of the transition amplitude will be $\int [\mathcal{D}p][\mathcal{D}q]e^{i\int dt (p\dot{q}-H(q,p)) }$? 
Now the Heisenberg's equation of motion will tell that,
$$\frac{d\vec{r}}{dt} = \frac{1}{m} \biggl(\vec{p} + \frac{e}{c}\vec{A}\biggr)^2$$
In the Feynman path-integral the position and the momentum vectors are treated to be independent variables and hence it would be wrong to substitute the above expression into the path-integral but outside one can I guess do this substitution and one would get for the action (whatever sits in the exponent),
$$S = \int dt \biggl(\frac{p^2}{2m} - \frac{e^2}{2mc^2}A^2\biggr)$$


*

*But the above expression doesn't look right!? The integrand isn't what the Lagrangian should be. right? 


Now in the derivation of the Feynman-path-integral if one integrates out the momentum for every infinitesimal transition amplitude and then reconstitutes the path-integral then one would get the expression,
$$\int [\mathcal{D}\vec{r}] \exp\biggl[i\int dt \biggl(\frac{m}{2}\dot{\vec{r}}^2 - \frac{e}{c}\dot{\vec{r}}\cdot\vec{A}\biggr)\biggr]$$


*

*Now what seems to sit in the exponent is what is the "correct" Lagrangian - I would think. Why did the answer differ in the two different ways of looking at it? 

*I wonder if given a Hamiltonian its corresponding Lagrangian can be "defined" as whatever pops out in the exponent if that system is put through this Feynman re-writing. In this case keeping to just classical physics I am not sure how to argue that the $\frac{m}{2} \dot{\vec{r}}^2 - \frac{e}{c} \dot{\vec{r}}\cdot\vec{A}$ is the Lagrangian for the system with the Hamiltonian $\frac{1}{2m}\bigl(\vec{p} + \frac{e}{c}\vec{A}(\vec{r})\bigr)^2$ 
I think I have seen examples on curved space-time where the "classical" Lagrangian differs from what pops out in the exponent when the system is path-integrated. 
 A: For the first question, the momentum $p = m\dot{\vec{x}}-e \vec{A}$ that is conjugate to the coordinate is also gauge-variant in exactly the way to make the canonical action gauge-invariant:
$$
\begin{aligned}
\vec{A} &\rightarrow \vec{A} + \frac{\hbar}{e}\nabla\Lambda\\
\vec{p} &\rightarrow \vec{p} - \hbar\nabla\Lambda
\end{aligned}
$$
(by the way, please take note I am using SI units.  The original question does not.)
For the second question, in almost all cases, it is possible write down the transition amplitude right away.  However, there are certain cases, for example the famous Duru-Kleinert path integral representation for the Coulomb problem, that required care to get.
For the third question, you can't substitute an equation of motion into the action.  That would be nonsense as you have found out.  (actually it looks like you already knew this, so I don't know why you asked about it anyway)
Fourth question: the reason it the answer differs in the two different ways of looking at it is because one of the ways is just wrong (see question 3).
Fifth question:  If you're given the Hamiltonian, then the Lagrangian is defined/obtained by taking the Legendre transformation with respect to the momentum:
$$L = p\dot{q} - H\,,$$
and where $p$ is eliminated in favor of the conjugate velocity $\dot{q}$.
