Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Old 12-17-2008, 06:00 PM PayPal IPN Problems
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Hi Guys

Looking for some help with a PayPal IPN...

Im pretty sure i had this script working before then i had to leave it and noiw that ive come back to it it isnt working!

After going through the paypal cart and payment the IPN file can never get to the VERIFIED block. It always is 'unverified'. Im not sure if this is a setting of the sandbox paypal account that needs to be set to allow these users (i dont know what verified users are (or if it is infact something to do with the transaction itself) but why wouldnt i want their money?! )

Anyways, the cut-down code is below at the moment im just trying to get the basic thing working before i put in the stuff to process the cart items and stuff.

PHP Code:

<?php

include('config.php');

//------------------------------------------------
// Read post from PayPal system and create reply
// starting with: 'cmd=_notify-validate'...
// then repeating all values sent - VALIDATION.
//------------------------------------------------
$postvars = array();
while (list (
$key$value) = each ($HTTP_POST_VARS))
{
    
$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);
}

//--------------------------------------------
// Create message to post back to PayPal...
// Open a socket to the PayPal server...
//--------------------------------------------
$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.sandbox.paypal.com"80$errno$errstr30);

//---------------------------------------------

//----------------------------------------------------------------------
// Check HTTP connection made to PayPal OK, If not, print an error msg
//----------------------------------------------------------------------
if (!$fp)
{
    
//echo "$errstr ($errno)";
    //fwrite($log, "Failed to open HTTP connection!");
    
$res "FAILED";
}
//--------------------------------------------------------
// If connected OK, write the posted values back, then...
//--------------------------------------------------------
else
{

    
fputs ($fp$header $req);
    
//-------------------------------------------
    // ...read the results of the verification...
    // If VERIFIED = continue to process the TX...
    //-------------------------------------------
    
while (!feof($fp))
    {
        
$res fgets ($fp1024);

        if (
strcmp ($res"VERIFIED") == 0)
        {
            
//----------------------------------------------------------------------
            // If the payment_status=Completed... Get the password for the product
            // from the DB and email it to the customer.
            //----------------------------------------------------------------------
            
if (strcmp ($payment_status"Completed") == 0)
            {
                
//do whatever
            
}
            
//----------------------------------------------------------------------
            // If the payment_status is NOT Completed... You'll have to send the
            // password later, by hand, when the funds clear...
            //----------------------------------------------------------------------
            
else
            {
                
//do whatever
            
}
        }
        
//----------------------------------------------------------------
        // ..If UNVerified - It's 'Suspicious' and needs investigating!
        // Send an email to yourself so you investigate it.
        //----------------------------------------------------------------
        
else
        {
            
//do whatever
        
}
    }
}


//-------------------------------------------
// Close PayPal Connection, Log File and DB.
//-------------------------------------------
fclose ($fp);
?>
Btw, this script is based on one i got online somewhere so apparently should work!

Last edited by stoot98; 12-18-2008 at 04:28 AM..
stoot98 is offline
View Public Profile
 
 
Register now for full access!
Old 12-18-2008, 08:21 AM Re: PayPal IPN Problems
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Dont worry guys i have figured out what was wrong. Complete idiocy on my part! Hadnt updated the email addresses and ipn pages on the cart HTML.

@admin: you can close/delete this if you like
stoot98 is offline
View Public Profile
 
Closed Thread     « Reply to PayPal IPN Problems
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10428 seconds with 12 queries