PayPal buttons: how do I protect sellers' sales?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

Is the file meant to be in a specific URL part of the site??? I'm doing it in domain.com/paypalipn.php
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

Without more information about all I can tell you is "You're doing it wrong." lol. Perhaps you're trying to use SSL and your live site doesn't have a root CA. If your link has https: try http: instead. I don't know what else to tell you.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

HTTP. We don't use SSL on this site at all.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

After I enter my URL, and choose Cart Checkout, on the following page of multiple fields, do I change anything on screen at all??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

SSL was just a guess because I don't have any info. Now your last message confuses me more.

To test the IPN you don't need to submit with buttons. I suggest you start slowly. Go to the IPN Simulator: https://developer.paypal.com/webapps/de ... _simulator Log in and go to the APPLICATIONS->TOOLS->IPN SIMULATOR.

This simulates a user buying something off your site and Paypal will submit the data to your IPN listener. You can use the simulator to test spoofed data, PENDING, INVALID, and all sorts of conditions to make sure your code works right.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

Eric that is what I am using and "submitting". The button at the bottom I am clicking and then at the top, I get that error quotation.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

Then there is something wrong with your URL and/or access. That's about all I can tell you. If you give me the URL I can help you look at the problem.

P.S. I accept paypal for programming work too. ;-)
Last edited by Eric! on Wed Nov 20, 2013 4:34 pm, edited 1 time in total.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

Your script could also have an error in it preventing it from sending the

Code: Select all

header('HTTP/1.1 200 OK');
which the IPN simulator is looking for.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

Ok I found out I was missing the final ?>, but still it did nothing. So got the error log out:

[text][Wed Nov 20 19:22:50 2013] [warn] [client 173.0.81.1] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57
[Wed Nov 20 19:35:16 2013] [warn] [client 89.168.131.11] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57
[Wed Nov 20 19:35:42 2013] [warn] [client 173.0.81.1] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57
[Wed Nov 20 19:35:47 2013] [warn] [client 62.24.222.132] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57, referer: http://www.site.co.uk/paypalipn.php
[Wed Nov 20 22:20:23 2013] [warn] [client 173.0.81.1] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57
[Wed Nov 20 22:21:49 2013] [warn] [client 89.168.131.11] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'contains' (T_STRING) in /var/www/vhosts/site.co.uk/httpdocs/paypalipn.php on line 57[/text]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

This is line 57

Code: Select all

    else if (strcmp ($res, "INVALID") == 0) { Response contains INVALID - reject notification
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

This is the problem with just cutting and pasting someone else's code.

Did you notice there's no // for the comment?


P.S. I accept paypal for programming work too. ;-)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

Eric! wrote:This is the problem with just cutting and pasting someone else's code.

Did you notice there's no // for the comment?


P.S. I accept paypal for programming work too. ;-)
Sorted that comment, now I get this
We're sorry, we could not send an IPN.
This did take a while to happen too.

Error log says:
[text][Thu Nov 21 08:14:08 2013] [warn] [client 173.0.81.33] mod_fcgid: read data timeout in 45 seconds
[Thu Nov 21 08:14:08 2013] [error] [client 173.0.81.33] Premature end of script headers: paypalipn.php
[/text]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

Looks like your script is timing out. You'll probably have to debug where it is getting hung up. Just dump out the $_POST values to a file and put in other debug lines to see what's going on. You need to write debug info to a file because it will interfere with the I/O with paypal if you try echoing it to the browser.

Personally I've never had to force apache to send the 200 ok header. I'm not sure where you got that script but perhaps it works.
Last edited by Eric! on Thu Nov 21, 2013 2:59 am, edited 1 time in total.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: PayPal buttons: how do I protect sellers' sales?

Post by simonmlewis »

The script is a direct copy from a page you sent, that shows the code to use, with details about each section.
Sorry I don't know how to "dump out the $_POST" to a file etc, as never needed to.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PayPal buttons: how do I protect sellers' sales?

Post by Eric! »

You're kidding me right? Maybe you should think about hiring someone.

Code: Select all

    $log = fopen("ipn_debug.txt", "a");
    fwrite($log, print_r($_POST,true));
Post Reply