Jump to content
Larry Ullman's Book Forums

Recommended Posts

RE: ipn.php script..is the code in the book or the download have errors...?

I noticed at least one discrepency between


on line 8 book has

    if($status === 200 && $response =='VERIFIED')


download has

if ($status === 200 && $response === 'SUCCESS')


just having trouble getting this script to work so I cannot really post a question.  just wondering if there are any known errors as I have not found any posted  in the forums


Thank you

Link to post
Share on other sites

oK... I think my error is here...it all look sgood to me...


$ch = curl_init();
    //configure curl 

        curl_setopt_array($ch, array (
        CURLOPT_URL => 'https//www.paypal.com/cgi-bin/webscr',
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => http_build_query(array('cmd' => '_notify-validate') + $_POST),
        CURLOPT_HEADER => false )  );
    //perform curl request
    $response = curl_exec($ch);
    //get status of curl response
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    //close curl


Link to post
Share on other sites

Yes Sorry Larry..Yes still having problem...


...I did notice in the book for the below line in the ipn.php script ...  txn_type uses  'web_accept'


 if(($_SERVER['REQUEST_METHOD'] === 'POST') && isset($_POST['txn_id']) && ($_POST['txn_type'] === 'web_accept'))


When I log into paypal and go Instant Payment Notification details (below is how to get there)


Profile->My Selling tools->ipn->click-update->IPN History page->Message ID-Click


I am getting back two messages.


one____IPN type
Transaction made.......USES....txn_type=subscr_payment

two----IPN type
Recurring payment profile....USES.....txn_type=subscr_signup



 I tried using each still not working


I also checked for all the values in the IPN Message and they are all there including the custom value(user_id)


HTTP response code = 200


I was was basically just wondering if the code in my last post looked correct.  Or if there are any known issues in the book or download as I have not been able to find any in the forums...


Thank you for any help you can add.

Link to post
Share on other sites

It looks okay. It'd probably help to know what the specific problem is. Is your script complaining about invalid values? If so, I'd write all the received values to a log and compare those to your conditional to see which one is the problem.

Link to post
Share on other sites
  • 1 month later...

I made changes in my ipn.php script ....It seems to be working now

My changes:

Page170 step 2
Book uses :
 if (($_SERVER['REQUEST_METHOD'] === 'POST') && isset($_POST['txn_id']) && ($_POST['txn_type'] === 'web_accept') )

I used:
if (($_SERVER['REQUEST_METHOD'] === 'POST') && isset($_POST['txn_id']) && ($_POST['txn_type'] === 'subscr_payment') )

Page172 step 8
Book uses:
if ($status === 200 && $response === 'SUCCESS')

I used:
if ($status === 200 && $response === 'VERIFIED')

Page172 step 9
Book uses:
&& ($_POST['mc_gross'] === 10.00)   

I used:
&& ($_POST['mc_gross'] === '10.00')  (10.00 is in single quotes)

For the above the below line may also work as I had to use either quotes or double == for a line  in my login.inc.php script in chp 6

&& ($_POST['mc_gross'] ==10.00)  (10.00 is in single quotes)



Just wanted to share this in the event it helps others....I am not sure why they work ...but they do work for me....I am using PHP5.5

Thank youi

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...