Jump to content
Sign in to follow this  
devosc

PayPal_Shopping_Cart_IPN

Recommended Posts

Cornelius,

 

In /catalog/includes/classes/paypal/ipn.php find the function authenticate($domain) {},

 

You will have to make sure you get it correctly i.e find the last '}' which closes the the function. Delete it all and replace with the code shown previously.

Edited by gregbaboolal

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

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello Greg

 

Thanks - I'm sure I've done it right (almost)

 

Any idear how to test it without creation another paypal account. When I use my own I get this:

 

 

You cannot email money to yourself. Please enter another user's email address if you would like to send money to someone.

 

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Cor, read through the thread you will find your answers.


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

Share this post


Link to post
Share on other sites

UPS - I didn't send 6 in 5 minutes - my answer was timed out 5 times and se what happens. Sorry sorry sorry.


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hello

 

I try to figure this out. When I enter http://cornelius-hansen.com/catalog/ipn.php in my browser I get this error message:

 

Parse error: parse error, unexpected T_IF, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /hotel/cornelius-hansen/cornelius-hansen.com/catalog/includes/classes/paypal/ipn.php on line 95

 

Fatal error: Cannot instantiate non-existent class: paypal_ipn in /hotel/cornelius-hansen/cornelius-hansen.com/catalog/ipn.php on line 22

 

I guess something is wrong - right?

 

Any help appreciated.

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Sorry - I get the last } wrong - This is like a language from a another planet to me. Thanks for your patience. Now I get a blank page.

 

Cornelius


dog1.jpg Who let the dog out ?!!! Newer trust a smiling dog!

Share this post


Link to post
Share on other sites

Hey -

 

AWESOME contribution! :D

 

I was wondering if there is a way to empty a customer's shopping cart even if they don't click that last Paypal continue button? The cart empties if they do.

 

Maybe this makes a difference, but I had to remove the lines in ipn.php that check the primary ID and the completed status, the script wouldn't work for me with them.

 

This is probably something pretty simple I'm overlooking.

Share this post


Link to post
Share on other sites

Do you need Curl installed for this contribution to work?

 

Or is there a workaround?

 

Thanks in advance

 

Dave

Share this post


Link to post
Share on other sites

Dave,

 

It will try and use curl, but so far I've only seen it supposedly working with an ssl connection at best, which it will automatically try if curl doesn't work, and if ssl doesn't it will then try tcp and if that doesn't work either the absolute fall back solution is posted earlier on in this thread.


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

Share this post


Link to post
Share on other sites

sky,

 

The problem with automatically deristering the cart is that if the customer does return to the site then they don't get redirected to checkout_success.

I haven't really looked into how long before a session expires, but I think the answer could be to set in osC admin to create a new session each time the customer logins in etc.

Haven't tested it though.

If you look at includes/modules/payment/paypal for the before process function you will see whats occuring in order to deregister the session.


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

Share this post


Link to post
Share on other sites
Dave,

 

It will try and use curl, but so far I've only seen it supposedly working with an ssl connection at best, which it will automatically try if curl doesn't work, and if ssl doesn't it will then try tcp and if that doesn't work either the absolute fall back solution is posted earlier on in this thread.

I've think its working but can't be sure

 

I used the ipn.htm to test & I get the following email

 

?COULD NOT PROCESS: You have received a payment of 0.01 USD?

 

Does this indicate that it?s working?

 

I also read about the change in the includes/classes/paypal/ipn.php file

As I read it you change the follow code from

 

 /*function authenticate($domain) {
? ?$paypal_response = '';
? ?$curl_flag = function_exists('curl_exec');
? ?if($curl_flag) {
? ? ?$ch = @curl_init();
? ? ?@curl_setopt($ch, CURLOPT_URL, "https://$domain/cgi-bin/webscr");
? ? ?@curl_setopt($ch, CURLOPT_POST, true);
? ? ?@curl_setopt($ch, CURLOPT_POSTFIELDSIZE, 0);
? ? ?@curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_response_string);
? ? ?@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
? ? ?@curl_setopt($ch, CURLOPT_TIMEOUT, 60);
? ? ?$paypal_response = @curl_exec($ch);
? ? ?@curl_close($ch);
? ? ?if($paypal_response == '') $curl_flag = false;
? ?}
? ?if(!$curl_flag) {
? ? ?$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
? ? ?$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
? ? ?$header .= "Content-Length: ".strlen($this->_response_string)."\r\n\r\n";
? ? ?$socket = 'ssl://'; $port = '443';
? ? ?$fp = @fsockopen ($socket.$domain,$port, $errno, $errstr, 30);
?	//$fp = fsockopen ($domain,rb);
? ? ?if(!$fp) {
? ? ? ?$socket = 'tcp://'; $port = '80';
? ? ? ?$fp = @fsockopen ($socket.$domain,$port, $errno, $errstr, 30);
? ?//$fp = fopen ($domain,rb);
? ? ?}
? ? ?if(!$fp) {
? ? ? ?//HTTP ERROR
? ? ? ?if($this->_debug) $this->send_email('HTTP Error',"An HTTP Error occured during authentication curl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n\r\n");
? ? ?} else {
? ? ? ?@fputs($fp, $header . $this->_response_string);
? ? ? ?while (!feof($fp)) {
? ? ? ? ?$paypal_response .= @fgets ($fp, 1024);
? ? ? ?}
? ? ? ?@fclose($log);
? ? ?}
? ? ?unset($this->_response_string);
? ?}

? ?//if($this->_debug > 1) {
? ? ?//$log = @fopen("ipn.txt", "w");
? ? ?//@fwrite($log,$paypal_response);
? ? ?//@fclose($log);
? ?//}

? ?if (strstr($paypal_response,'VERIFIED')) {
? ? ?if($this->_debug >1 ) $this->send_email('VERIFIED',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? ?return true;
? ?} else if (strstr($paypal_response,'INVALID')) {
? ? ?// log for manual investigation
? ? ?if($this->_debug > 1) $this->send_email('INVALID',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? ?return false;
? ?} else {
? ? ?if($this->_debug) $this->send_email('unkown verification occurrence',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? ?return false;
? ?}
?}*/

 

To

	
function get_paypal_response() {
? $paypal_response = file('http://www.paypal.com/cgi-bin/webscr?'.$this->_response_string);
? return $paypal_response[0];
}

function authenticate($domain) {
? $paypal_response = $this->get_paypal_response();
? if (strstr($paypal_response,'VERIFIED')) {
? ? if($this->_debug >1 ) $this->send_email('VERIFIED',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? return true;
? } else if (strstr($paypal_response,'INVALID')) {
? ? // log for manual investigation
? ? if($this->_debug > 1) $this->send_email('INVALID',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? return false;
? } else {
? ? if($this->_debug) $this->send_email('unkown verification occurrence',"Connection Type\r\ncurl=$curl_flag socket=$socket domain=$domain port=$port\r\n#####################\r\n".$paypal_response."\r\n\r\n");
? ? return false;
? }
}

 

Sorry If I've misinterpreted your post on this

 

Dave

Edited by Davee

Share this post


Link to post
Share on other sites

I received a 'Could not process' also on my only live Paypal transaction - the test one had gone through to completion without any problem. I didn't manage to investigate further as I had by then turned off the diagnostics. I'd like to know what causes this.

Share this post


Link to post
Share on other sites

Hi Davee,

 

I don't have too much time to look at the code again. But quickly though, You should of received a few more emails than just the one you showed. The email notification level is set to 2 by default.

 

Did you have it in Test Mode?

 

Probably so, ok that email occurs because the contents of your shopping cart was not the same as what you specified in the ipn_test.html. If in Test Mode (which you had to be in order to have that far) the order should of been stored in your database. So have a look in osC admin.

 

Yes you're interpretation is correct. Was it absolutely nessecary to do this, doesn't feel like you had enough time to determine that you had to use this last result. But I'm being a bit slow this morning.

 

Put it into live mode and make a real trial purchase.


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

Share this post


Link to post
Share on other sites

First of all, I'd like to thank you for your help it is appreciated

I tried the ipn.htm with email set to 2 & test mode off

 

I received these emails

 

Connection Type

 

curl= socket= domain=www.paypal.com port=

 

#####################

 

INVALID

 

& another with this in the subject - PayPal IPN: DEBUG

 

with all the submitted details etc

 

 

Forgot to add there's nothing in admin/paypal ipn ???

Edited by Davee

Share this post


Link to post
Share on other sites

Radders,

 

As said this occurs when the shopping carts contents (total_gross) differ from what the total is that PayPal is saying has been paid.

 

There are 3 tests:

 

[1] If using Method 2 (Itemized); Are the number of items in the cart matching?

[2] Is the transaction in the same currency.

[3] Is the gross amount correct.

 

These checks compare the transaction details sent from PayPal to the details of that particular shopping cart sesssion.

It is assuming that the customer has not had the time to update the shopping cart, because in theory they're supposed to be busy paying you on PayPal's site.

Doesn't mean to say that someone is not trying to mess around, i.e they have another browser open whilst on the PayPal site and in the other browser they go back and change the contents of the cart, they then finish paying PayPal and when returning to the site, if the [1, 2, and 3] do not match then there is something up and you get that email.

 

As always PayPal will send you an email.

Thinking further, it might now be clearer as to a better use for that invoice number you see in the orders section.

What could happen is that it could contain the customers osC ID, that way if any hiccups do occur when PayPal sends you their own email it should then contain this invoice number, which could help you to identify that particular customer.

But the invoice number has to be uniquely specified by you, and so more thinking and scripting is required.


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

Share this post


Link to post
Share on other sites

Dave set it to Test Mode, see an earlier thread for how to do a test, basically jsut make sure the cart total is the same as the the mc_gross you specify in the ipn_test.html, that should allow the txn to be stored.

 

You seem to still be having problems making a connection to PayPal. When successful you will have an email saying

 

curl= socket=ssl domain=www.paypal.com port=443

 

or

 

curl= socket=tcp domain=www.paypal.com port=80

 

or 'something' for that solution posted in here in this thread.

 

Basically in Test Mode you will get an email saying INVALID, but the txn will still be stored. This is correct because PayPal did not verify it.


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

Share this post


Link to post
Share on other sites

Gregory

 

Thanks again for your support

 

I completed a transaction & received PayPal IPN: VERIFIED- PayPal IPN: insert_ipn_txn :)

I checked in the paypal ipn in the section are all blank is this correct ?

 

PayPal Customer Registration Details

First Name:

Last Name:

Business Name

Address Name

Address Street

Address City

Address State

Address Zip

Address Country

E-Mail Address:

Ebay ID

Payer ID

Payer Status

Address Status

 

 

PayPal IPN Transaction Details #

Payment Type

Payment Status

Pending Reason

Invoice

Payment Date

Currency

Gross Amount

Payment Fee

Exchange Rate

No Of Cart Items

Share this post


Link to post
Share on other sites

Davee,

 

No, something is wrong. Do you see the relevant information of that order, i.e the osC info stuff? Did you do anything to the database tables?

 

Try deleting all your previous IPN related orders. And making another another another trial purchase. If I'm not mistaken, even in test mode, when the transaction is stored, you should still see some IPN (test) info in the osC orders page, but I can't remember.


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

Share this post


Link to post
Share on other sites

I'm not in test mode

 

The details are in the database - table - paypal ipn

 

But the info is not showing in the order?

Edited by Davee

Share this post


Link to post
Share on other sites
The problem with automatically deristering the cart is that if the customer does return to the site then they don't get redirected to checkout_success.

I haven't really looked into how long before a session expires, but I think the answer could be to set in osC admin to create a new session each time the customer logins in etc.

Haven't tested it though.

If you look at includes/modules/payment/paypal for the before process function you will see whats occuring in order to deregister the session.

 

Cool, thanks for your reply. I'll test this and post back if I get it working.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×