View Full Version : Paypal integration: Trying to send user-submitted amount
09-11-2011, 08:10 AM
I have a project and I've hit a wall...
I have a site that allows the visitor to "list" an item. I am trying to implement an option where they can "upgrade" this item to a "Preferred" listing by paying a fee. The problem i have is that the fee will not be a set fee, but rather determined by the price the last preferred listing cost.
ie: Previous Preferred Listing was "upgraded" for $10. The next Preferred Listing will be entered by the visitor and should be higher than $10. (hope that makes sense)
I got close with a PayPal "Buy Now" button, but it does not let me send a user-submitted amount to the checkout site, and I can't allow the user to enter it once at PayPal because I can't validate if it's higher than the previous one at that point.
What are my options here? I'd like to stay with Paypal if possible because I'm familiar with it. I also don't want to have to implement an entire "shopping cart" aspect to the site when all I need is a simple single-item dynamically-"priced" form to post to PayPal.
09-11-2011, 08:40 PM
This is where you will need to get into the PayPal IPN method.
PayPal gives you a key where you process a transaction using PHP (and their API).
No more buttons needed ... it's all done within your PHP scripting.
Everything happens on your site until the user clicks your "paynow" link.
At that point, they enter PayPal to finish the transaction. After the transaction,
they are returned back to your site for a "thankyou", "approved", or "we have a problem".
PayPal offers a terrific tool ... a sandbox where you can set everything up for free.
It acts as a real paypal account, with a fake buyer, seller, and credit card. You get
everything working how you want, and then simply change your IPN key and account
name to your REAL paypal account.
This is a "must have" thing for all paypal users.
09-12-2011, 06:39 AM
Hey thanks man, I actually found another site that suggested sending the data as a "cart", which does EXACTLY what I need. It allows me to send the user-supplied price as a variable to the paypal site. So! the only thing I'm really struggling with is once that payment shows paid, I need it to update a field in my database, but I don't know how to tell it which record to update.
I have a "ListingID" with is something like "XRsSEV3m". When the payment is flagged as paid, I need the IPN to update a field in that specific record, but don't know how to get the IPN to pass back the ListingID when it responds back.
On top of that, I'm not really sure how long that process should take. I have a sandbox set up with an email account for Buyer and Seller (only the buyer one lets me log in though for some reason) and I can see the payments in the buyer section. I have the ipn file in my web server and it's edited properly for my settings. How long does it take to get the "notification" and how do I know if it's working or not?
Appreciate the help. I'm new to the PayPal integration stuff.
09-12-2011, 01:26 PM
It happens immediately.
I use the PayPal Express Checkout pretty much all the time.
They have example scripts with filenames like:
It's the DoExpressCheckoutPayment.php script that checks for a successful
transaction. Within that script you update the database, send an email, and
display a thankyou, etc.
I guess you may be processing things differently. I suppose it depends
on the site, shopping cart, etc.
09-13-2011, 07:21 AM
I seem to have gotten the IPN thing partially working. I'm using the sandbox at the moment and I can send the IPN's using the PayPal simulator. It DOES update the "paypal" info in my database, but it won't update a different table in the same database. I'm not getting the email either that I'm using for testing. These 3 lines of code are right after each other so I can't figure out why the one database insert works, but the other two lines fail...
I can't seem to do any diagnostic stuff with the "ipn" php file either because I can't call it directly.
09-13-2011, 01:16 PM
You are correct about diagnosing stuff ... you have to run it through each time.
We'll now need to see the script that updates your database, but fails to do the rest.
09-13-2011, 03:32 PM
well i'm happy to report... it's working!!!
There were so many conditional blocks in the ipn php file that I finally thought to put different text file output code in each condition block to see which one was actually executing when my db was being updated with the paypal info. Sure enough, it pinpointed exactly which condition was being met based on how I was sending my "cart" info and I added my other DB update code along with the Paypal one and it's working beautifully!!
I haven't tested it in the live site yet, so we'll cross that bridge when it comes, but it was pretty exciting to see that value get updated in the DB!! It was pretty quick too (almost instantaneous).
thanks again man! Much appreciated.
09-13-2011, 04:31 PM
PayPal sandbox is the bomb!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.