SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PayPal's Instant Payment Notification

    Has anyone every used this service?
    I copied and paste the sample script they provide in their Website:
    PHP Code:
    <?php

    // read post from PayPal system and add 'cmd'
    $postvars = array();
    while (list (
    $key$value) = each ($_POST)) {
        
    $postvars[] = $key;
    }
    $req 'cmd=_notify-validate';
    for (
    $var 0$var count ($postvars); $var++) {
        
    $postvar_key $postvars[$var];
        
    $postvar_value = $$postvars[$var];
        
    $req .= "&" $postvar_key "=" urlencode ($postvar_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 ("www.paypal.com"80$errno$errstr30);

    // assign posted variables to local variables
    $receiver_email $_POST['receiver_email'];
    $item_number $_POST['item_number'];
    $invoice $_POST['invoice'];
    $payment_status $_POST['payment_status'];
    $payment_gross $_POST['payment_gross'];
    $txn_id $_POST['txn_id'];
    $payer_email $_POST['payer_email'];

    if (!
    $fp) {
        
    // HTTP ERROR
        
    echo "$errstr ($errno)";
    } else {
        
    fputs ($fp$header $req);
        while (!
    feof($fp)) {
            
    $res fgets ($fp1024);
            if (
    strcmp ($res"VERIFIED") == 0) {
                
    // check the payment_status=Completed
                // check that txn_id has not been previously processed
                // check that receiver_email is an email address in your PayPal account
                // process payment
                
    echo 'ok';
            } elseif (
    strcmp ($res"INVALID") == 0) {
                
    // log for manual investigation
                
    echo 'no';
            }
        }
        
    fclose ($fp);
    }

    ?>
    And tried to test it with this page:
    http://www.certifiedtechgroup.com/test_ipn.html
    (to which they link themselves)
    But no matter what, I always get 'no' (because the so-called transaction failed).

    Can anyone give me any tips on how to get this to work? Thanks!

  2. #2
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How come my threads never get stuck? Please I really need your help!

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2001
    Location
    UK
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to know about this too.

    ^bump^

  4. #4
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh I was gonna bump this myself but you did the work for me.

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2001
    Location
    UK
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone.....

  6. #6
    SitePoint Enthusiast Goldfinger's Avatar
    Join Date
    Dec 2001
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey i need to know about this too.. for a game im making...

    and is it just me or is only people from the vbulletin site needing this .

  7. #7
    SitePoint Enthusiast AmandaArias's Avatar
    Join Date
    Sep 2001
    Location
    Houston, TX USA
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://sitepointforums.com/showthrea...threadid=51965

    Let me know if that helps.
    Amanda
    Arias Web Hosting - Affordable, Multi-Domain Linux Hosting
    http://ariaswebhosting.com

    PhpShop Customization "Manual" - http://phpshop.ariaswebhosting.com/

  8. #8
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here is another interface that works. This is part of OsCommerce (Formerly The Exchange Project) and it is a class module so a lot of what it calls is part of the whole package. Maybe what is here will be of some help though.

    PHP Code:
    <?php
    /*
      $Id: paypal.php,v 1.26 2002/01/22 21:14:46 dgw_ Exp $

      The Exchange Project - Community Made Shopping!
      [url]http://www.theexchangeproject.org[/url]

      Copyright (c) 2000,2001 The Exchange Project

      Released under the GNU General Public License
    */

      
    class paypal {
        var 
    $code$title$description$enabled;

    // class constructor
        
    function paypal() {
          
    $this->code 'paypal';
          
    $this->title MODULE_PAYMENT_PAYPAL_TEXT_TITLE;
          
    $this->description MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
          
    $this->enabled MODULE_PAYMENT_PAYPAL_STATUS;
        }

    // class methods
        
    function javascript_validation() {
          return 
    false;
        }

        function 
    selection() {
          return 
    false;
        }

        function 
    pre_confirmation_check() {
          return 
    false;
        }

        function 
    confirmation() {
          global 
    $checkout_form_action;

          
    $checkout_form_action 'https://secure.paypal.com/cgi-bin/webscr';
        }

        function 
    process_button() {
          global 
    $HTTP_POST_VARS$shipping_selected$shipping_cost$shipping_method$total_cost$total_tax$currencies;

          
    $paypal_return 'shipping_selected=' $shipping_selected '&shipping_cost=' $shipping_cost '&shipping_method=' urlencode($shipping_method);
          
    $paypal_cancel_return 'shipping_selected=' $shipping_selected;

          
    $process_button_string tep_draw_hidden_field('cmd''_xclick') .
                                   
    tep_draw_hidden_field('business'MODULE_PAYMENT_PAYPAL_ID) .
                                   
    tep_draw_hidden_field('item_name'STORE_NAME) .
                                   
    tep_draw_hidden_field('amount'number_format(($total_cost $total_tax) * $currencies->currencies['USD']['value'], 2)) .
                                   
    tep_draw_hidden_field('shipping'number_format($shipping_cost $currencies->get_value('USD'), 2)) .
                                   
    tep_draw_hidden_field('return'tep_href_link(FILENAME_CHECKOUT_PROCESS$paypal_return'SSL')) .
                                   
    tep_draw_hidden_field('cancel_return'tep_href_link(FILENAME_CHECKOUT_PAYMENT$paypal_cancel_return'SSL'));

          return 
    $process_button_string;
        }

        function 
    before_process() {
          return 
    false;
        }

        function 
    after_process() {
          return 
    false;
        }

        function 
    output_error() {
          return 
    false;
        }

        function 
    check() {
          if (!isset(
    $this->check)) {
            
    $check_query tep_db_query("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");
            
    $this->check tep_db_num_rows($check_query);
          }
          return 
    $this->check;
        }

        function 
    install() {
          
    tep_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Allow PayPal', 'MODULE_PAYMENT_PAYPAL_STATUS', '1', 'Do you want to accept PayPal payments?', '6', '3', now())");
          
    tep_db_query("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PayPal ID', 'MODULE_PAYMENT_PAYPAL_ID', 'you@yourbuisness.com', 'Your buisness ID at PayPal.  Usually the email address you signed up with.  You can create a free PayPal account at [url]http://www.paypal.com.[/url]', '6', '4', now())");
        }

        function 
    remove() {
          
    tep_db_query("delete from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");
          
    tep_db_query("delete from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_PAYPAL_ID'");
        }

        function 
    keys() {
          
    $keys = array('MODULE_PAYMENT_PAYPAL_STATUS''MODULE_PAYMENT_PAYPAL_ID');

          return 
    $keys;
        }
      }
    ?>
    Wayne Luke
    ------------


  9. #9
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Amanda and wluke.

  10. #10
    SitePoint Zealot
    Join Date
    Dec 2001
    Location
    UK
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TY


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
  •