How to deny payment via PayPal IPN? - php

I need to create dynamic 'Pay Now' buttons on my site, and PayPal says the way to do this is via an HTML FORM with preset variables for the price, currency, and item of the purchase. I use PayPal IPN to notify me when a payment has complete.
However, what's to stop someone from modifying the query parameters of the Pay Now button to change the price? Some people have told me to redirect the button through a PHP file that sends you to a PayPal payment page with the parameters in place, but the price could just as easily be manipulated in the Web browser's address bar. My question is, how can I deny a payment if the information I receive from PayPal's IPN service is invalid (if the price doesn't match our records)?
I'm quite confused and couldn't find any documentation on what I'm looking for. Hopefully, you guys can help.
Thanks!

In your IPN listner, check all your variables you sent to paypal. In paypal response, all the variables which are related to the transaction will be sent back to you (i.e., the amount, receivers email, payment status, etc.).
So, what you can do is check all the values of those variables with expected values and do the appropriate task.
See this for more details .

I think you want to enable Encrypted Website Payments. I haven't done this before, but you can read more here: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_encryptedwebpayments

Related

Passing PayPal Invoice Number Back In Notification Email

I need to make a modification to our custom cart. Basically as it currently stands when we get a payment we use IPN to post back to our site and display the details of the purchase, we then get an email from PayPal with all the details in.
I have an excel spreadsheet that then accesses Outlook and prints an Invoice based on this email and adjusts the stock database etc, at this point the order is given an Invoice number.
However, I want to make it that the invoice number is given at the checkout stage, now I know you can set the 'invoice' variable as a pass thru variable, however, what I am unable to determine from the online literature is whether or not this 'invoice' value is returned in the the PayPal instant Payment Notification email, so my excel spreadsheet can use it?
If the invoice number is not sent in the email, is there any field you know of that is?
All the best and thank you in advance.
First, it sounds like you're confusing IPN and PDT. They're very similar, but if the data is getting sent to your return URL then that would be PDT. IPN gets POSTed to a separate script outside of your checkout altogether.
IPN is the recommended method of updating things and sending out emails, etc. because even with Auto-Return enabled there is no guarantee your buyers will make it back to your return URL (when using Payments Standard.) IPN will always be triggered regardless.
So, back to your question, yes, the invoice number will be sent with IPN notifications if you pass it to PayPal with the payment request. The parameter is called "invoice". You can see all the available parameters that IPN works with in the PayPal documentation.

I want to use paypal payment for package sales, which paypal method woud be best?

I want package sales, when user click on purchase want to send user on paypal site, after success payment back to my site, I will update payment status if payed other wise will not update the payment status. 2nd question how will i know user payed?
PayPal IPN allows the PayPal servers to interact with yours, telling them statuses about if they've paid, missed payment or it failed etc.
https://www.paypal.com/ipn
For example, if you're using the Website Payments Standard (https://www.paypal-business.co.uk/accept-online-payments-with-paypal/index.htm) you send them to the PayPal site by sending hidden information in a form, they do their thing on PayPal and then get sent back. PayPal will then notify the server using the IPN details that were either sent or are in the account, letting the server know if it was successful or if anything else happened. Then your application that picks up the IPN, does its security checks, and then does the appropriate action (e.g. allows the item to be sent or them to login etc).
However - if you're doing subscriptions, I highly recommend not using PayPal. They suck for subscriptions.
visit the following link
http://www.evoluted.net/thinktank/web-development/paypal-php-integration
and follow the step by step guide.
If not work then ask question here.

Paypal checkout callback url to display unique sale id in 1x1 img for tracking

I've been asked by a client to display:
<img src='https://www.trackingserver.com.au/saleServlet?MID=43&PID=55&CRID=&ORDERID=<input orderId!>&ORDERAMNT=<input order amount!>&NUMOFITEMS=1' border='0' width='1' height='1'>
on the http://www.clientsite.com.au/paypalsuccess.htm callback url
is there anyway to dynamically fill in the and values with values returned by paypal.
The client is currently using Paypal Standard > Add to cart buttons ( https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_paypal_shopping_cart )
I can't see anything there about obtaining values upon redirection... I'd like to just be able to process the request header from Paypal in a php version of paypalsuccess.html and pull out the data in questions. Putting it into the img.
Possible? Where should I look?
It sounds like you will need to implement PayPal's IPN system.
Read up on it here: https://www.paypal.com/ipn/
Basically you:
Write your IPN script.
Add that script into every PayPal button (or you can manually set your paypal account to always inform that script of any payments).
PayPal will then sent that script a POST message whenever somebody makes a payment. That POST message contains virtually every bit of information that you can see through your PayPal control panel.
You can get data from a complete sale when it transfers back to the site using PDT: https://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec/pdt-intro-outside
I discourage using it though because an order can be completed on Paypal without ever transferring to the site again. IPN is the most reliable way to receive information about orders: https://www.paypal.com/ipn/
However since IPN is all server side stuff, it won't really help you with your question so you will need to use cURL to touch base with the URL you provided.

Using a different PayPal IPN URL per transaction

I have seen and know how to use IPN for paypal payments but I am having a small issue. With IPN you need to enter an IPN address to your PayPal File so it knows you got sent the payment (Instant Activation of Product). If I have multiple sites, I can't do this as It only allows one.
I have seen the WHMCS system manage to do this using Website Payments Standard (Does not require any IPN Settings) where the user's invoice is marked as paid after the payment is sent. The user does not need to be redirected to another page and as a seller, the only info you need to put in is your paypal email for things to start working.
Does anyone know how this works and where to learn this?
Thank you for your help
You can specify a per-transaction IPN URL by passing in notify_url along with the other data in the form.
E.g. <input type="hidden" name="notify_url" value="http://....">
This will override whatever you have set up within your PayPal Profile.

How to build a paypal donation system that gives points

Am trying to create a way to setup the following:
User sends donation to paypal with info from donation site (name, email)
Paypal receives the donation and using the 2 variables it received (name, email) it sends them back to the donation site
Donation site receives variables and donation amount and changes some variables in the website to show that the user has donated some amount.
The site shows a list of users that have donated and how much they have donated which shows as points. How can I do this with paypal and php and mysql.
I'd suggest looking into using PayPal Instant Payment Notifications (IPN).
PayPal IPN allows you to (asynchronously) process order information while not having to depend on the buyer to return to your website to complete the order (which would be the case with PDT).
You can use IPN by setting up a script which receives this (POST) data from PayPal. In addition, you must include the following code in your button and/or API call(s):
For Website Payments Standard (where "xxxxxxxx" is the full URL to your IPN script):
<input type="hidden" name="notify_url" value="xxxxxxxx">
For Express Checkout:
Include NOTIFYURL=xxxxxxxx in your SetExpressCheckout and DoExpressCheckoutPayment API call
For Website Payments Pro
Include NOTIFYURL=xxxxxxxx in your DoDirectPayment API call
Once set up, you will receive POST data from PayPal with every transaction.
Take this data, and send it back to https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate (Live) or https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate (Sandbox) to validate the data. If PayPal responds with VERIFIED (in the body of the page), you're sure the data is genuine IPN data coming from PayPal.
You can find sample code, documentation and further information on PayPal IPN at https://www.paypal.com/ipn
See also some IPN security best practices at https://www.x.com/developers/community/blogs/ppmtsrobertg/securing-your-instant-payment-notification-ipn-script
I found this tutorial, looks like what you're after.
http://tutorialzine.com/2010/05/donation-center-php-mysql-paypal-api/
Your first step is to use a paypal payments pro account. If memory serves correctly, you can only callback on pro accounts. Otherwise your paypal donation is pretty much a one way trip.
Please understand your question is very involved and is not likely going to result in a full blown example.
The best suggestion I can give is to read up on the paypal API documentation and see if the PHP API fits your needs...
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_overview
The PHP / MySQL end of things is on you at this point. You must store user information that you would use to send and validate the successful transactions based on the paypal API results.
While this answer may not serve your situation exactly, it is at least a small point in the right direction. I would suggest taking care to consider refunds and cancelled payments. If there is anything at all to gain by accumulating these "points" you mention then you need to cover security well. Otherwise you will be gamed and could stand to lose something if this is not done correctly.
If you have anything specific to add to this question to narrow down the possible answers, let me know and I will try to update this answer with a better, more specific response.
Set up Payment Data Transfer with PayPal,
PayPal PDT How To
Then on the page that receives the payment details from PayPal, calculate the number of points the person gets based off of how much money they donated (using whatever multiplier or point scheme you decide on), then log the data in a points field in the user's row of your user table in mysql.

Categories