Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PayPal_Shopping_Cart_IPN


devosc

Recommended Posts

i amended the other fields in mysql! one thin g im not sure of is that the orders_session_info shows up as having 0 rows is this correct????

that table show have 6 fields in it.....

 

orders_id int(11)

sendto tinyint(1)

billto tinyint(1)

language varchar(32)

currency char(3)

content_type varchar(32)

Link to comment
Share on other sites

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Are there problems with STS templates and this contribution? I just tried to get it working and I got a complaint from sts_output_display.php line 200. I'm a total noob at this, but I'm pretty sure that I did everything correctly.

Link to comment
Share on other sites

Does anyone know of any problems with Paypal recently?

Recently, I've been getting orders with totals of 0.00, and no information in my Order.php list, however, about 4 hours or so later, I get a paypal payment email (which is late...)

Link to comment
Share on other sites

PS Typo found in v2.0

 

(new files to cp include:)

catalog/includes/modules/payment/paypal/process.tpl.php

 

 

This should be:

catalog/includes/modules/payment/paypal/processing.tpl.php

 

 

... this thread is pretty quiet ...

Edited by veral
Link to comment
Share on other sites

Apologies for the spam.

 

Regarding v2.0. I notice that in whatever it is that I've done, in 'Edit Order', I don't have actual details of the IPN customer.

 

So I have received payment, the order is in, but unlike for my setup for v1.7, I don't have Paypal transaction IDs etc...

 

Any advice? - Should I care about the fact that it's blank?

Edited by veral
Link to comment
Share on other sites

Found a discrepancy in the docs supplied with the distro:

 

The file says:

 

Find (line 321):

 

<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action','referer'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

 

But the string is at line 348 and reads:

 

<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

 

The difference being in the second to last line.

 

(array('action','referer'))) vs (array('action')))

Edited by razorjack
Link to comment
Share on other sites

Also the install docs state:

 

"What url should I specify for the IPN feature to be used

 

 

You don't, just make sure that it is enabled (i.e. ticked/on), specifying a url will mean any PayPal transaction will result in an IPN being sent to your store even if it is unrelated, thus better not to specify one, it is taken care of by this contribution already. "

 

When you go to turn IPN on (at PayPal's site) it REQUIRES a URL.

 

Anyone? I'm watching my logs and I'm getting 404's for paypal_notify.php = off off the root and I can't find a paypal_notify.php file anywhere...

Link to comment
Share on other sites

the contrib does work. I have IPN obviously turned on and as a return URL I have it going to checkout_success.php....doesn't interfere with anything else from what I can tell and I have accepted payments in and out of my store.

 

B)

Link to comment
Share on other sites

I can accept payment, I just want the notification thingy turned on :)

 

Does your notification panel work?

it does now... I did have problems initially as posted earlier in this thread but everything works fine now....I think the trick was how the payment module was configured in your admin panel...

 

B)

Link to comment
Share on other sites

Well, screwing around I found that ipn.php was not mentioned anywhere in the docs, so I popped it into my catalog directory. I also edited the www.paypal.com line at thee top of the file to read www.paypal.com/cgi-bin/webscr - I submitted a live payment and it worked. Ugh, this was painful...but hey it was free...well kinda :) Lots of 1.00 purchases on the wife's CC :)

Link to comment
Share on other sites

Well, screwing around I found that ipn.php was not mentioned anywhere in the docs, so I popped it into my catalog directory. I also edited the www.paypal.com line at thee top of the file to read www.paypal.com/cgi-bin/webscr - I submitted a live payment and it worked. Ugh, this was painful...but hey it was free...well kinda :) Lots of 1.00 purchases on the wife's CC :)

hi razorjack,

 

i did exactly the same thing as you, putting the ipn.php in the catalog folder and changing from www.paypal.com to www.paypal.com/cgi-bin/webscr.

 

everthing works fine but what bothers me is that if you look at ipn.php in catalog/includes/modules/payment/paypal/ipn.php

 

"/cgi-bin/webscr" is added automatically to the repost algo.

 

now i am not even sure if the contrib is truly veryfying or not.

Link to comment
Share on other sites

now i am not even sure if the contrib is truly veryfying or not.
If you're in Live mode and your debug emails are showing that the PayPal has verified the IPN as a valid transaction then they're being verified.

/cgi-bin/webscr should not have to be added to the domain name , since it is hard coded.

There is however a bug with the httpS verification as pointed out in this post.

The docs will be revised in the next update.

I think I now appreciate what is meant by a bug in the code is worth two in the documentation.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

I'm just trying to figure out why I'm still seeing these:

 

notify.paypal.com - - [15/Apr/2004:02:01:42 -0700] "POST /paypal_notify.php HTTP/1.0" 404 1056 "-" "-"

notify.paypal.com - - [15/Apr/2004:02:03:05 -0700] "POST /paypal_notify.php HTTP/1.0" 404 1056 "-" "-"

notify.paypal.com - - [15/Apr/2004:02:40:08 -0700] "POST /paypal_notify.php HTTP/1.0" 404 1056 "-" "-"

Link to comment
Share on other sites

Have a look int you paypal account profile, ipn should be set to 'on' bu no url needs to be specified, delete the 'http://' bit before clicking save so that it doesn't try to force you to enter a url.

This contrib will automatically let paypal know where to send notifications, so nothing specific needs to be configured.

Out of interest prior to being transferred to the PayPal site do you see a plain html page with your store logo and a PayPal checkout button and a 'Processing Transaction' msg?

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

that curl stuff works, it should return 'INVALID', in either case the way the script is designed is that if it doesn't work it will then try a socket connect, and if that don't work it will try fopen, note there is an error in the one for httpS those 2 lines should be:
$fp = @fopen('https://'.$domain.'/cgi-bin/webscr?'.$this->_response_string);
$paypal_response = @fgets($fp, 1024); @fclose($fp);

here the '@' suppresses any errors so it will cascade through untill the it finally attempts 'http'

Greg,

 

can you post more code before and after this so I make the correct changes? It seems that the two lines you are suggesting we change are a pretty drastic change from what was with the contrib.

 

not that i don't trust your skills as I know you got game but I just want to make sure I have the context and not working off an older version or something...

 

so far, rock solid!

 

Thanks Greg!

 

B)

Link to comment
Share on other sites

Hi Rodney,

in catalog/includes/modules/payment/paypal/ipn.php

find:

$paypal_https_response = @file('https://'.$domain.'/cgi-bin/webscr?'.$this->_response_string);
$paypal_response = @$paypal_https_response[0];

and change to:

$fp = @fopen('https://'.$domain.'/cgi-bin/webscr?'.$this->_response_string);
$paypal_response = @fgets($fp, 1024); @fclose($fp);

What happens in that section of the script is that it first trys curl and if that fails it then trys a socket connection (for both ssl:// and tcp://) which if that fails it then trys the httpS:// and lastly http://.

Actually looking at the code and above it might seem that the httpS:// should be used prior to trying to use tcp://, I might look into this.

If you check your debug emails it should give an inclination of what type of connection is being used, if curl is used it will say curl=1 and if not it should say what type of sockect connection is being used, unfortunately due to change in a previous update I don't think it says anything about the http types of connection.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

/cgi-bin/webscr should not have to be added to the domain name , since it is hard coded.

hi greg, i have fixed the bug in the https and http section that you have suggested then i went back to $domain = 'www.paypal.com' instead $domain = 'www.paypal.com/cgi-bin/webscr'. heres the response email:

 

-----------------------------------------------------------------------------------------------

Connection Type

------------------------------------------------------

curl= , socket= tcp://, domain= www.paypal.com, port= 80

 

PayPal Response

------------------------------------------------------

HTTP/1.0 411 Length Required

Server: squid/2.5.STABLE3

Mime-Version: 1.0

Date: Wed, 14 Apr 2004 21:50:26 GMT

Content-Type: text/html

Content-Length: 1290

Expires: Wed, 14 Apr 2004 21:50:26 GMT

X-Squid-Error: ERR_INVALID_REQ 0

X-Cache: MISS from nimrod2.super.net.sg

Connection: close

 

!

 

ERROR

The requested URL could not be retrieved

 

 

While trying to process the request:

 

GET / HTTP/1.0

Content-Type: application/x-www-form-urlencoded

Content-Length: 630

 

 

 

The following error was encountered:

 

 

 

Invalid Request

 

 

 

 

Some aspect of the HTTP Request is invalid. Possible problems:

 

Missing or unknown request method

Missing URL

Missing HTTP Identifier (HTTP/1.0)

Request is too large

Content-Length missing for POST or PUT requests

Illegal character in hostname; underscores are not allowed

 

Your cache administrator is [email protected].

 

 

 

 

Generated Wed, 14 Apr 2004 21:50:26 GMT by nimrod2.super.net.sg (squid/2.5.STABLE3)

 

----------------------------------------------------------------------------------------------

 

but if i change it back to $domain = 'www.paypal.com/cgi-bin/webscr' then the reply email is:

 

----------------------------------------------------------------------------------------------

 

Connection Type

------------------------------------------------------

curl= , socket= tcp://, domain= www.paypal.com/cgi-bin/webscr, port= 80

 

PayPal Response

------------------------------------------------------

VERIFIED

 

-----------------------------------------------------------------------------------------------

 

really strange...........and the "cgi-bin/webscr" is hard coded....... :huh:

Link to comment
Share on other sites

Hi szenses,

 

I'll have to look into that when I have time but below is an example from the PayPal website which you can compare with the script used in the contib.

 

If you could let me know what version of PHP you are using and whether it is a CGI version or the module(?) version in apache - might be handy to know.

 

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$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, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

Hi guys,

 

I have a really tricky one here.

I am hoping you genious people can assist me.

 

The reason for installing the IPN for me was to automate the system.

I wanted a purchase order sent to my supplier of the product automatically.

 

And I can send a purchase order from admin/orders.php, where you normally click on to update & notify customer, i changed the email to below params -

 

I added -

$productsemail_query = tep_db_query("select products_id, products_model, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $oID . "'");

        $productsemail = tep_db_fetch_array($productsemail_query);

 

$vendorid_query = tep_db_query("select vendors_id from " . TABLE_PRODUCTS_TO_VENDORS . " where products_id = '" . $productsemail['products_id'] . "'");

        $vendorid = tep_db_fetch_array($vendorid_query);

$vendor_query = tep_db_query("select vendors_name, vendors_email from " . TABLE_VENDORS . " where vendors_id = '" . $vendorid['vendors_id'] . "'");

        $vendor = tep_db_fetch_array($vendor_query);

just after

        $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);

I have "enhanced vendors" installed and each product has a vendor associated to it, so the above first gets the vendor_id a variable in the vendors table from the products table.

 

So in short, I wanted the product details, then the vendor_id for that product, and once i have the vendor_id i can query another table to get the vendor name & email as per the vendor_ID.

 

Now this worked fine by changing the tep_email to

            $email = "<b><u>" . STORE_NAME . "</u></b> \n" . EMAIL_TEXT_ADD1 . "\n" . EMAIL_TEXT_ADD2 . "\n" . EMAIL_TEXT_ADD3 . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_SEPARATOR . "\n <b>" . EMAIL_TEXT_NOINVOICE . "</b> \n" . EMAIL_TEXT_REFER . "\n" . EMAIL_TEXT_VENBILL . "\n" . EMAIL_SEPARATOR . "\n <b>" . EMAIL_TEXT_PRODUCTS . " \n" . "      " . EMAIL_TEXT_MODEL . "           " . EMAIL_TEXT_NAME . "</b> \n" . "    " . $productsemail['products_model'] . "  -" . $productsemail['products_name'] . "\n" . EMAIL_SEPARATOR . "\n <b>" . EMAIL_TEXT_SHIPTO . "</b> \n" . $check_status['customers_name'] . "\n" . $check_status['customers_street_address'] . "\n" . $check_status['customers_suburb'] . "\n" . $check_status['customers_state'] . "  -" . $check_status['customers_postcode'] . "\n\n" . EMAIL_TEXT_SUMMARY1 . "\n" . EMAIL_TEXT_SUMMARY2 . "\n" . EMAIL_TEXT_SUMMARY3 . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']);

 

            tep_mail($vendor['vendors_name'], $vendor['vendors_email'], EMAIL_TEXT_SUBJECT, $email, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);

And this sends a email like -

Koala Computers

PO Box 371

Redcliffe

QLD, 4020

------------------------------------------------------

Purchase Order Number: 76

------------------------------------------------------

Please do not include any invoices with this package as it is being shipped direct to the customer.

Please refer all correspondence to [email protected]

You are authorised to debit my credit card on file as previously agreed for the wholesale amount of this order plus GST & freight.

------------------------------------------------------

Please supply the following products:

      Model#:          Product Description:

    CW-ASUSCD52X  -ASUS Internal (52X CD-ROM)

------------------------------------------------------

Please ship this order directly to -

Curtis Raams

13 Lee Street

Brahma Lodge

Australian Capitol Territory  -5109

 

Thank you,

Mr Tony Lopez

Email: [email protected]

Date Ordered: Thursday 15 April, 2004

 

Now I wanted to send this email auto when someone pays with paypal and its approved, so in catalog/includes/modules/payment/paypal/checkout_update.php

I pasted the above in the section where you send the order email and modified, but it wont send.

I of course modified some fields like $oID to $orders_id as defined in that script.

 

PLEASE can someone tell me how to have this send the email auto on a paypal order.

 

PLEASE

 

Thanks

Link to comment
Share on other sites

/cgi-bin/webscr should not have to be added to the domain name , since it is hard coded.

hi greg, razorjack,

 

cgi-bin/webscr is hard coded in paypal/ipn.php so righfully catalog/ipn.php should point to 'www.paypal.com' not 'www.paypal.com/cgi-bin/webscr' to have a respond from paypal. i have added a change that seems to fix this, add *** in paypal/ipn.php

 

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";

*** $header .= "Host: www.paypal.com\r\n";

$header .= "Content-Type: application/x-www-form-urlencoded\r\n";

$header .= "Content-Length: ".strlen($this->_response_string)."\r\n\r\n";

 

before change:

 

-----------------------------------------------------------------------------------------------

Connection Type

------------------------------------------------------

curl= , socket= tcp://, domain= www.paypal.com, port= 80

 

PayPal Response

------------------------------------------------------

HTTP/1.0 411 Length Required

Server: squid/2.5.STABLE3

Mime-Version: 1.0

Date: Wed, 14 Apr 2004 21:50:26 GMT

Content-Type: text/html

Content-Length: 1290

Expires: Wed, 14 Apr 2004 21:50:26 GMT

X-Squid-Error: ERR_INVALID_REQ 0

X-Cache: MISS from nimrod2.super.net.sg

Connection: close

 

!

 

ERROR

The requested URL could not be retrieved

 

 

While trying to process the request:

 

GET / HTTP/1.0

Content-Type: application/x-www-form-urlencoded

Content-Length: 630

 

 

 

The following error was encountered:

 

 

 

Invalid Request

 

 

 

 

Some aspect of the HTTP Request is invalid. Possible problems:

 

Missing or unknown request method

Missing URL

Missing HTTP Identifier (HTTP/1.0)

Request is too large

Content-Length missing for POST or PUT requests

Illegal character in hostname; underscores are not allowed

 

Your cache administrator is [email protected].

 

 

 

 

Generated Wed, 14 Apr 2004 21:50:26 GMT by nimrod2.super.net.sg (squid/2.5.STABLE3)

 

----------------------------------------------------------------------------------------------

 

 

after change:

 

 

Connection Type

------------------------------------------------------

curl= , socket= tcp://, domain= www.paypal.com, port= 80

 

PayPal Response

------------------------------------------------------

HTTP/1.0 200 OK

Date: Fri, 16 Apr 2004 22:26:46 GMT

Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a

Set-Cookie: cookie_check=yes; expires=Mon, 14-Apr-2014 22:26:47 GMT; path=/; domain=.paypal.com

Set-Cookie: Apache=210.23.1.3.101741082154406913; path=/; expires=Sun, 09-Apr-34 22:26:46 GMT

Content-Type: text/html; charset=windows-1252

X-Cache: MISS from nimrod2.super.net.sg

Connection: close

 

VERIFIED

 

-----------------------------------------------------------------------------------------------

 

i have read through this forum and no else seems to have this problem other than me an razorjack. so why we are the only two having the problem, i am not so sure why. maybe greg can shed some light.....

Edited by szenses
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...