views:

184

answers:

3

I'm trying to link my 3rd party shopping cart to PayPal, and in the process I'm finding that my variables are extremely exposed, such that, if someone uses, say, Firebug, to manipulate the values of my variables, they can change the cost of the items in the transaction.

I'm very new to online carts and shopping, so my question is how do I keep this layer of exposure away from users and secure for the website?

+2  A: 

The answer is in the Instant Payment Notification service.

Upon completing the transaction, PayPal notifies you, in a separate process, of the payment details for the last transaction.

You can check these details against the data you stored locally. If they match, all is fine. If they do not match, you will need to investigate the issue.


Never understood why PayPal does not allow the data to be signed with some sort of hash + shared secret... but that does not help you any further.


If you POST the variables to PayPal, you can encrypt the data. Unfortunately, this is not possible for a GET request, triggered from a redirect.

Jacco
I think it does allow you to set up the shared secret. My problem is that there is no explanation about what standard variables to send with a cart so paypal knows it's an encrypted cart with several items. All I can seem to make work is a single item purchase.
dclowd9901
I want to reiterate that my main issue was with using this solution: http://www.stellarwebsolutions.com/en/articles/paypal_button_encryption_php.php It ended up that the button itself carries a variable `_s-xclick` to denote a secure click, but the array of encrypted data you send carries the variable `_cart` along with its relative set of cart data.
dclowd9901
+1  A: 

Use the PayPal NVP or SOAP API to create an encrypted button. Basically you set all the information using PHP and then the API gives you the HTML. Alternatively if you only have a couple of products you can make custom buttons.

The API's are well documented and easy to use. Personally I used the NVP as it was recommended for less experienced programmers. You can also use both in with the IPN (Instant Payment Notification) system so that for example digital products can be automatically emailed.

Olly Hicks
+1  A: 

There is a way of getting PayPal to host the button variables on their side. Look out for PayPal Hosted Buttons in their documentation:

https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ButtonMgrAPIIntro#id093VD0JE0Y4

Otherwise verify with IPN as mentioned bu Jacco.

ChrisB