Let the price of one mango be \( m \) and one orange be \( o \).
Initial purchase:
\[
5m + 10o = 40 \tag{1}
\]
Then, John returns 1 mango and gets 2 oranges — exchange is value-to-value, so:
\[
m = 2o \tag{2}
\]
Substitute (2) into (1):
\[
5(2o) + 10o = 40 10o + 10o = 40 20o = 40 o = 2
\]
\[
\boxed{2 \text{ rupees per orange}}
\]