I'm working on a web-app using PHP and client-side Javascript, in which is implemented the Google Maps Javascript API.
The purpose of this web-app is to able to reserve a driver for a journey, like ....
In order to calculate the distance of the journey, I'm using the Distance Matrix API, but I ask me how can I secure the callback against cheating?
See my code
service.getDistanceMatrix(
{
origins: [route[origin]],
destinations: [route[destination]],
travelMode: 'DRIVING',
avoidTolls: true,
}, callback());
function callback(response, status) {
var dist = response.rows["0"].elements["0"].distance.value;
var duration = response.rows["0"].elements["0"].duration.value;
}
);
Here users can easily change the value of the "dist" variable! Which will be used to calculate the price of the journey.
Even if I directly send the data to the server with AJAX call, they could be modify parameters to this call and set whatever they want.
I may be using the wrong development solution in this kind of situation.
Please let me know if I'm using the wrong solution or if it exists ways to secure my application.
Thank you in advance for your answers.