What I want to do is have a buy it now button somewhere on my site. When users log on they can click it and pay X amount, then after the transaction has completed I need a script to update 1 field in the database with a value.
Someone recommended using paypal ipn for this.
Is that the best solution for what I am trying to achieve?
Will I need some additional script to work with it or is it "ready-made" with just specific database variables requiring changes?
Paypal has a much nicer workflow for this that does not make the user wait an undetermined time for his payment to arrive: Paypal Express Checkout. With this you actually do know that he paid with paypal the very minute he comes back from the paypal page, and you can do all the things needed to make the transaction happen on your side as well.
Related
I have a question.
I'm using this Paypal code: http://www.saaraan.com/2012/07/paypal-expresscheckout-with-php
I would like to have a premium function on my website, where an user can buy something and the premium featuren should directly be active on his account. How can I enable this? Where should I put the Query to update his account? I mean, what if the paymentstatus is pending, then I don't have the money. Does he have the possibility to cancel the order?
Or should I add the query after the GetTransactionDetails. Or is there the possibility that the order is complete, but the query will not be excuted?
Thanks!
The best solution for your problem would be to create an IPN listener that would receive the transaction details and, if you code it properly, update your user's account accordingly. You could have it programmed to only update the account if the IPN shows that the paymentstatus is complete, if you want to. I have an IPN listener that has about 8 different scenarios depending on the transaction type and payment status.
Do a little research on IPN listeners and you'll see that you can really use them to handle a lot of the tedious details for you. Paypal's developer site has IPN listener code examples that can help get you started.
Hope this helps.
So I've been using paypal recurring payments for about a year now, and for the most part it works well (with IPN verification after payment goes through, etc...)
One issue I have run into is sometimes my customers will set up multiple payment profiles, which I definitely don't want them to do. Then I have to go in + refund payments and cancel additional profiles.
I was curious if anyone had any suggestions to prevent users from doing this, or WHERE I should prevent this from occurring.
After the IPN notification hits my server, users can't purchase again, but sometimes this can take 30 seconds, or an hour. So then my user goes back in thinking it didn't go through and purchases again.
My process is pretty much this:
Page 1 (user selects options)
Paypal API: SetExpressCheckout
Page 2 (user goes to paypal, logs in, accepts agreement)
Page 3 (I create the agreement)
Paypal API: GetExpressCheckoutDetails
Paypal API: CreateRecurringPaymentsProfile
I would think somewhere on Page 3 I should do a check, but I'm not 100% sure HOW I should go about it. Simply make an association w/PayerID they they tried to purchase something here then prevent it ongoing?
What do people recommend?
Thanks!
After creating the first recurring payment profile, in the response you will get a profile id and a profile status which should be 'ActiveProfile'. I would recommend that you save it, and do a check before he selects any subscription(or product) again on Page 1.
I'm doing a project involving Paypal, more specifically with the NVP API in PHP. But I just can't seem to figure what to use the IPN feature for.
I mean, when the user has been redirected to Paypal to confirm the purchase, he is redirected back to my website's "Paypal-succes-page", when the transaction is complete. And just to be sure that he actually payed i could use the "PaymentDetails" operation.
Now where does IPN fit in this process? and what is the benefit of it?
Thanks
The integrate with PayPal's services you will notice there are three main channels (and IMO it's important to know this so you can decide the benefits for your application):
IPN: Instant Payment Notification
PDT: Payment Data Transfer
PayPal's API
To use PayPal's IPN you need to add a 'listener' script (example) and add the address to your PayPal account. Whenever an event occurs PayPal will send a message directly to your server via your listener and you then update your accounts appropriately. This is especially useful for running subscription services as events will occur in the background without user intervention and you can capture successful/failed recurring payments etc.
PayPal's PDT is a system for accepting data when a user is redirected back to your site from PayPal. For example, a user clicks 'Buy', they are directed to PayPal, enter information etc. Then, once the payment has been taken, they are redirected back to your site. PayPal can pass details about the transaction including whether it was successful or not so you can display the appropriate success/failed page from your site.
PayPal's API allows you to integrate more deeply with PayPal's services, and you would use this if you were managing payments directly from your site.
These services aren't mutually exclusive, so you can use any combination with your application.
I hope this helps
The IPN feature is a very useful feature which you should use to update your database in my opinion. Sure the user is redirected to your success-page after the purchase where you can validate the payment details.
But what if he closes (by accident or not) the browser before reaching your success page? You will never know the result of the transaction and you will never update your database or process his order accordingly.
When using the IPN you can be sure that the transaction result will always reach you because PayPal will keep on making an offline request to your IPN page until it has reached your servers.
Instant Payment Notification
The typical usage of the IPN is to validate the purchase and to let your script or management system know that the transaction is complete so your system can update any records you may have for your service.
But the most important part is that the transaction is validated.
IPN send all data about transaction to your server - price, items, contacts ... so you can check, if someone don't pay you only 1$ instead of 100$ and confirm your order. It prevets thiefs, cheaters, ... USE IT! ;)
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.
i'm trying to integrate paypal ipn in my site
Here's the situation :
All prices will saved in the database
when user select to pay the user will be transfered to paypal (with price given by db) ,after payment i want verify payment if its accurate and then want it to add certain rows in db !
i checked http://cms.paypal.com
but i couldn't get it work .
can anybody explain me ?
For Paypal ipn you need to setup a script which will keep handling requests from paypal server. Based on these requests you need to further process you order. Sometimes a order is accepted initially but later declined. You can handle these cases only if you have ipn in place.
For frontend basic payment processing use a simple form or paypal express checkout.