Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Paypal integration: Trying to send user-submitted amount

    Hi Forum,
    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.

    Thanks!
    i'm always learning

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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.

    https://developer.paypal.com/

    This is a "must have" thing for all paypal users.


    .

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    i'm always learning

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    It happens immediately.

    I use the PayPal Express Checkout pretty much all the time.
    https://cms.paypal.com/us/cgi-bin/?c...GettingStarted

    They have example scripts with filenames like:
    DoExpressCheckoutPayment.php
    GetExpressCheckoutPayment.php
    CallerService.php

    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.


    .

  • #5
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    i'm always learning

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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.


    .

  • #7
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    i'm always learning

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    PayPal sandbox is the bomb!


    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •