Need a very simple Paypal setup

Discussion in 'Programming' started by Stu--, Jul 31, 2009.

  1. #1
    Hi,

    I need to know how to set up a very very simple paypal system, where a customer hits the buy now button, pays via paypal, and is then emailed either an attachment or a password to a secret area.

    I've had this set up before and I know it's very simple so I know I don't need to pay for it. I've played with the code a bit myself but it's been a while. I used IPN.

    Can anyone point me to a simple php script to set up this system? I could do the email stuff myself, I just need to handle the paypal info. It's only one ebook.
     
    Stu--, Jul 31, 2009 IP
  2. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Martinoes, Jul 31, 2009 IP
  3. Stu--

    Stu-- Active Member

    Messages:
    355
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks, but not quite. I need info on how to wire this up to the php script.
     
    Stu--, Aug 1, 2009 IP
  4. Mkcoy

    Mkcoy Well-Known Member

    Messages:
    1,602
    Likes Received:
    77
    Best Answers:
    2
    Trophy Points:
    195
    #4
    Hi you could set up an account with Payloadz.com.

    The customer clicks to purchase. Pays. And an email is sent with a file to download.
    You could include the password within that file. (A .txt file within a .zip file perhaps)
    Very simple.

    I've been doing this for about 3 years with Payloadz.com

    Hope this helps.
     
    Mkcoy, Aug 1, 2009 IP
  5. Stu--

    Stu-- Active Member

    Messages:
    355
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Thanks.

    But I found the answer on the paypal site. I use this script and simply send an email to the customer containing their download info.

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    
    foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
    
    // post back to PayPal system to validate
    $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
    
    // assign posted variables to local variables
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];
    
    if (!$fp) {
    // HTTP ERROR
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {
    // check the payment_status is Completed
    // check that txn_id has not been previously processed
    // check that receiver_email is your Primary PayPal email
    // check that payment_amount/payment_currency are correct
    // process payment
    }
    else if (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
    }
    }
    fclose ($fp);
    }
    ?>
    PHP:
     
    Stu--, Aug 1, 2009 IP
  6. chiendent

    chiendent Peon

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you Stu for sharing the code. I keep it for the day I will need it!
     
    chiendent, Aug 1, 2009 IP
  7. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #7
    I have something similar I offer for google checkout. Call it Google-Digital-Chekcout and sell it for 15.00 to people looking for a quick solution to digital delivery. I dont know why i chose google checkout. Who has the better rates anyone know off hand? Cause seeing any skimmed off the top makes me cringe.
     
    adbox, Aug 1, 2009 IP