SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist Sikwondo's Avatar
    Join Date
    Sep 2005
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PayPal... Payment to download

    Hi all,

    I'm not sure if this is the correct place to post this, please let me know if so, but I am well and truly stuck.

    I need to set up payments through PayPal, that will take the user from the site to PayPal to pay, then, once paid, redirect back to the site to then download the purchased file.

    Is this doable via PayPal? Been through their docs and can't work it out.

    Also, is it possible to encrypt the download link to protect it being shared?

    Sorry if this is the wrong place.

    many thanks for any help in advance
    Si

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,295
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    This is certainly doable. I wanted to do this a while back, and after scouting around various solutions, I settled on Linklok, which is a great little bit of software. You install a vary simple script on your server that interacts with PayPal. After payment, the customer is redirected to a page on your site with an encrypted link to the download file. The link is generated on purchase, so the real location of the file can't be determined. You can set the link to expire any time.

    It's a really nice little solution, and a small, one-off payment. It was even easy for a noob like me to set up.

    [PS: I've moved this thread to the PHP forum to Ecommerce.]

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sure, you can use PayPal's IPN service to permit the download once payment has been confirmed.

    * Create a database record, indicating purchased file, hashing users IP and browser agent, add a cookie too
    * Send to PayPal for payment
    * Provide user a unique URL for this download
    * Once payment has been confirmed, enable download in database for set period of time

    That's usually the, very rough, gist of it.

    PHP Code:
    <?php
    /*
      Get the download where the browser and ip is the
      same as the user who paid, and has the cookie value,
      and is paid for, and where the number of downloads
      is less than or equal to 2.
    */
    $sql sprintf(
      
    "SELECT
        file
      FROM
        purchases
      WHERE
        paid = 1
          AND
        ua = '%s'
          AND
        ip = '%s'
          AND
        hash = '%s'
          AND
        downloads <= 2;"
    ,
      
    mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']),
      
    mysql_real_escape_string($_SERVER['REMOTE_ADDR']),
      
    mysql_real_escape_string($_COOKIE['hash'])
    );
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Location
    Pakistan
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The following class can help you setting up quickly
    paypal_ipn (paypal IPN) - PHP Classes

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Si,

    If you don't want to have to write and manage the code for this yourself, you can use a pre-built off the shelf solution for your digital download store which works with your PayPal account to take the payments but handles the secure delivery of the files to your customer. I have used this 3rd party digital download service before and it is a real time saver and means you avoid ongoing support for your own cobbled together code: Sell Digital Downloads
    If at first you don't succeed... buy it from someone else
    Life's to short to be wasting time trying again and again!

  6. #6
    SitePoint Evangelist Sikwondo's Avatar
    Join Date
    Sep 2005
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for your help everyone, really appreciate it.

    I am going to give Ralph's solution a try - have purchased and working through the setup now


Bookmarks

Posting Permissions

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