views:

83

answers:

2

I'm having trouble figuring out how to prevent people from editing the amount in my shopping cart with tools such as firebug. How do I make sure users can't edit the hidden field? Can I encode the amount before sending it to paypal?

Thanks!

Francois

+1  A: 

I'm sorry to say, but you can not prevent people from fiddling with the html / post variables. One common security mantra is "Don't trust the client".

The process should be to have the client post back to your server. It recomputes the totals or whatever, then send that to paypal. Obviously there should be some sanity checks like preventing zero or negative quantities; however, the client itself should NOT have control of the totals.

Chris Lively
Yeah, that's what I'm doing on the new version of the site but I was wondering if there was a quick fix for my current system.Anyhow, thanks for the reply!
Farbour
Thanks for the answer, BTW... Do you know how i can edit question here? I made a mistake in the question title and can't find where the edit button is.
Farbour
There should be an edit button just below the question.
Chris Lively
A: 

Okay, turning comment into answer...

Don't encode the hidden file! When a customer makes a payment, PayPal will handle the transaction and tell your automated system that it has received the payment. It should also tell you how much the customer paid you! You then compare the amount paid with the original invoice and if there's a difference, you just tell the user that the payment is incomplete. (Unless they paid too much, of course.)

As Chris Lively tells you, don't trust the customer! Always check the amount that has been paid. Once you do this, it doesn't matter if the user hacks into any hidden fields, since you check it afterwards.

If your security depends on keeping your users away from hidden fields, your security will fail! Your security should depend on your contact with PayPal directly. Only when PayPal confirms the payment, you should send the product.

Workshop Alex