Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Paypal Instant Payment Notification

  • 16-02-2006 5:50pm
    #1
    Closed Accounts Posts: 975 ✭✭✭


    Anybody have any experience with programming websites to handle paypal IPN so that the payment clearance can be done instantly and automatically? I've googled a few php scripts and started looking at the paypal manuals. At first glance it looks fairly involved, for a moderate php programmer with little E-commerce exposure.

    Is there a simpler solution for getting instant clearance of a payment in a script so that script can then authorise delivery of the service/product to the buyer immediately?

    Thoughts, observations, experiences and ramblings welcomed.


Comments

  • Closed Accounts Posts: 190 ✭✭ShayHT


    can this not be done on the paypal site??

    your site >>> paypal >>> your site


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    I'm pretty sure PP provides sample code for various languages on their website. Here's what I'm using, with some extra cruft.

    If you don't fancy the job yourself, there's plenty of developers out there that can do it for you.

    adam

    [PHP]elseif ($provider == 'paypal') {
    $tx = $_GET;
    $req = "cmd=_notify-synch&tx=$tx&at=$ppDTT";
    $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://$ppHOST", 443, $errno, $errstr, 30) or exit("No file pointer.");
    fputs ($fp, $header . $req);
    $res = '';
    $headerdone = false;
    while (!feof($fp)) {
    $line = fgets ($fp, 1024);
    if (strcmp($line, "\r\n") == 0) {
    $headerdone = true;
    }
    elseif ($headerdone) {
    $res .= $line;
    }
    }
    fclose ($fp);
    $lines = explode("\n", $res);
    if (strcmp ($lines[0], "SUCCESS") == 0) {
    $keyarray = array();
    for ($i=1; $i<count($lines); $i++) {
    list($key,$val) = explode("=", $lines[$i]);
    $keyarray[urldecode($key)] = urldecode($val);
    }
    extract($keyarray);
    if ($payment_status != 'Completed') {
    exit("PayPal cannot confirm your payment, please contact help@domain.com for assistance.");
    }
    if ($receiver_email != $ppID) {
    exit("Your payment appears to have been made to an incorrect address, please contact help@domain.com for assistance.");
    }
    $providernum = 2;
    $providertxt = 'PayPal';
    if ($custom == 'AC-SUB') {
    $doaction = 'join';
    } else {
    $doaction = 'rejoin';
    $userid = str_replace('AC-RESUB-', '', $custom);
    }
    $transid = $txn_id;
    $receipt = "Your Transaction ID is <strong>$transid</strong>.<br />PLEASE WRITE THIS DOWN IMMEDIATELY.";
    } else {
    exit("We were unable to contact PayPal to confirm your payment, please contact help@domain.com for assistance.");
    }
    }[/PHP]


  • Registered Users, Registered Users 2 Posts: 92 ✭✭cianuro


    Take a look at their API reference document.

    https://www.paypal.com/en_US/pdf/PP_APIReference.pdf

    Also, there is a LOT of documentation on their API and code you can use on their site as well as a ton of free scripts you can use as a reference.


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Thanks for the replies and the code samples. I was just wondering in a general way how tough it was really. I know "tough" is relative, but I haven't seen any comments saying it was a pain to get going so I guess it's not too bad? Do you think it is the simplest/best/most elegant solution for an instant payment authorisation e-commerce site?


  • Registered Users, Registered Users 2 Posts: 92 ✭✭cianuro


    It completely depends. Are you creating something custom for a client?
    Why not use something thats already built, something open source and build on that?


  • Advertisement
  • Closed Accounts Posts: 975 ✭✭✭squibs


    Yes it's a custom built content management site for a client. Customers will be advertising on the site and I'll need the ads to go live immediately after the customer has paid. Charege will probably always be the same or might vary depending on the duration that the ad will spend on the site. Something like OScommerce is far too big for what I need. Do you have any suggestions? Thanks.


  • Registered Users, Registered Users 2 Posts: 92 ✭✭cianuro


    I see where your going so. :)
    Rather than reinvent the wheel, why not take a look at a ready made solution to integrate?

    Take a look at http://www.bannermanage.com/

    This has the PAYPAL system already built in and is relatively cheap.


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Cianuro - the ads will be created by filling out a form, so I don't actually need any ad management stuff, it's only the payment part I need help with. Sorry - my bad. I should have made that clearer.


  • Registered Users, Registered Users 2 Posts: 92 ✭✭cianuro


    :) Sorry for the confusion.

    In that case, you may wish to take a look at the IPN code samples here:

    https://www.paypal.com/cgi-bin/webscr?cmd=p/xcl/rec/ipn-code-outside


  • Closed Accounts Posts: 975 ✭✭✭squibs


    Bookmarked - along with 20 other websites gound in google containing manuals, tutorials, snippets and classes!
    Thanks.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,667 ✭✭✭MartMax


    we don't use paypal at the moment but a merchant account with one local provider.

    we had our website running oscommerce, didn't work well coz it didn't fit our business. so here we are trying phpCoin. both are free, but phpCoin looks promising. we can do the payment gateway thing easily, simple billing system. plus, the theme is easy to play with, PLUS phpCoin comes with helpdesk and good enuff to be a basic CMS.

    as for the paypal thing, it already has built-in code or u can use API plug-in to make it the way u want it. that's all i can say as we don't use paypal thou.


Advertisement