Magento Forum

   
Paypal IPN not working in 1.7
 
cootetom
Jr. Member
 
Total Posts:  3
Joined:  2012-05-24
 

Hi, I’ve just installed Magento 1.7 on a web server. I can’t get the order status to update from pending payment when using Paypal payments standard.

I’m just using a Paypal sandbox account at the moment for testing and have switched sandbox mode on in Magento with my test seller account details. I’ve switched IPN on. I set the notification URL to http://myshop.co.uk/index.php/paypal/ipn/ I’ve also turned on auto return in Paypal.

However the IPN post back never works and therefor Magento never updates the status of the orders. The log file is below.

2012-05-24T22:18:34+00:00 DEBUG (7): Array
(
[ipn] => Array
(
[address_city] => City
[address_country] => United Kingdom
[address_country_code] => GB
[address_name] => Tom C
[address_state] => Worc.
[address_status] => confirmed
[address_street] => my road
[address_zip] => F873HF
[business] => tomc_1337892906_biz@email.com
[charset] => windows-1252
[custom] =>
[first_name] => Bob
[invoice] => 100000009
[ipn_track_id] => c8de54e334424
[item_name1] => Ball
[item_number1] => 123
[last_name] => Martin
[mc_currency] => GBP
[mc_fee] => 0.54
[mc_gross] => 10.00
[mc_gross_1] => 10.00
[mc_handling] => 0.00
[mc_handling1] => 0.00
[mc_shipping] => 0.00
[mc_shipping1] => 0.00
[notify_version] => 3.4
[num_cart_items] => 1
[payer_email] => bobm_1337892645_per@email.co.uk
[payer_id] => C4PD77UU9RKEN
[payer_status] => verified
[payment_date] => 15:18:26 May 24, 2012 PDT
[payment_fee] =>
[payment_gross] =>
[payment_status] => Completed
[payment_type] => instant
[protection_eligibility] => Eligible
[quantity1] => 1
[receiver_email] => tomc_1337892906_biz@email.com
[receiver_id] => U68FC2DCH2LLS
[residence_country] => GB
[tax] => 0.00
[tax1] => 0.00
[test_ipn] => 1
[transaction_subject] => Shopping CartBall
[txn_id] => 5K296737LM0034205
[txn_type] => cart
[verify_sign] => AiPC9BjkCyDFQXbSkoZcgqH3hpacArPUaCdSeuHxFtIJTDXcrfTz7NhO
)

[postback] => mc_gross=10.00&invoice;=100000009&protection;_eligibility=Eligible&address;_status=confirmed&item;_number1=123&payer;_id=C4PD77UU9RKEN&tax;=0.00&address;_street=my+road&payment;_date=15:18:26+May+24,+2012+PDT&payment;_status=Completed&charset;=windows-1252&address;_zip=N544FG&mc;_shipping=0.00&mc;_handling=0.00&first;_name=Bob&mc;_fee=0.54&address;_country_code=GB&address;_name=Tom+C¬ify;_version=3.4&custom;=&payer;_status=verified&business;=tomc_1337892906_biz@email.com&address;_country=United+Kingdom#_cart_items=1&mc;_handling1=0.00&address;_city=city&verify;_sign=AiPC9BjkCyDFQXbSkoZcgqH3hpacArPUaCdSeuHxFtIJTDXcrfTz7NhO&payer;_email=bobm_1337892645_per@email.co.uk&mc;_shipping1=0.00&tax1;=0.00&txn;_id=5K296737LM0034205&payment;_type=instant&last;_name=Martin&address;_state=Worc&item;_name1=Ball&receiver;_email=tomc_1337892906_biz@email.co.uk&payment;_fee=&quantity1;=1&receiver;_id=U68FC2DCH2LLS&txn;_type=cart&mc;_gross_1=10.00&mc;_currency=GBP&residence;_country=GB&test;_ipn=1&transaction;_subject=Shopping+CartBall&payment;_gross=&ipn;_track_id=c8de54e334424&cmd;=_notify-validate
[postback_to] => https://www.sandbox.paypal.com/webscr
[postback_result] =>
[exception] => PayPal IPN postback failure. See paypal_unknown_ipn.log for details.
[__pid] => 5332
)

I can’t see what I’ve done wrong? I also can’t find the log file “paypal_unknown_ipn.log”. It doesn’t appear to exist. I’ve read a few articles now on setting this up and it seems really straight forward but it’s just not working. Any advice would be appreciated?

Regards,
- Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
cootetom
Jr. Member
 
Total Posts:  3
Joined:  2012-05-24
 

I’ve been looking into this some more. I found the PHP method which fails to verify the Paypal transaction which is the last step of the IPN process. This code is in /app/code/code/Mage/Paypal/Model/Ipn.php.

/**
     * Post back to PayPal to check whether this request is a valid one
     *
     * @param Zend_Http_Client_Adapter_Interface $httpAdapter
     */
    protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter)
    
{
            $sReq 
'';
            foreach (
$this->_request as $k => $v{
                $sReq 
.= '&'.$k.'='.urlencode($v);
            
}
            $sReq 
.= "&cmd;=_notify-validate";
            
$sReq substr($sReq1);
            
$this->_debugData['postback'$sReq;
            
$this->_debugData['postback_to'$this->_config->getPaypalUrl();

            
$httpAdapter->write(Zend_Http_Client::POST$this->_config->getPaypalUrl(), '1.1', array(), $sReq);
            try 
{
                $response 
$httpAdapter->read();
            
catch (Exception $e{
                $this
->_debugData['http_error'= array('error' => $e->getMessage(), 'code' => $e->getCode());
                throw 
$e;
            
}
            $this
->_debugData['postback_result'$response;

            
$response preg_split('/^\r?$/m'$response2);
            
$response trim($response[1]);
            if (
$response != 'VERIFIED'{
                
throw new Exception('PayPal IPN postback failure. See ' self::DEFAULT_LOG_FILE ' for details.');
            
}
            
unset($this->_debugData['postback']$this->_debugData['postback_result']);
    
}

All it is doing is sending a request to Paypal to verify the transaction. Paypal should return just the word ‘VERIFIED’ in the response. When I capture what is being sent to Paypal in this code and do the request myself in a web browser I get the expected ‘VERIFIED’ response. However, when it’s doing this in code the response is blank?

I’m a bit confused?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Extendware
Sr. Member
 
Avatar
Total Posts:  220
Joined:  2011-08-04
 

What does the logs say?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cootetom
Jr. Member
 
Total Posts:  3
Joined:  2012-05-24
 

I posted the logs for the transactions in the first post. I moved the discussion into a bug report that already exists for the IPN verification not working. It\’s here http://www.magentocommerce.com/bug-tracking/issue?issue=13515

I\’m hoping someone will look at it because after I re-wrote the function without using Zend then it worked.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bbpro
Jr. Member
 
Total Posts:  6
Joined:  2011-11-21
 

I had exactly the same symptoms and have been banging my head against this problem for days. It was odd because IPN was not working with PayPal ‘Website Payment Standards’ but it was working with PayPal ‘Express Checkout’. Thats another test worth trying.

Anyway, I’ve worked out the cause of my problem, but am yet to get it fixed. It was a 3rd Party Shipping extension that retrieves quotes automatically based on the address postcode and suburb. After I uninstalled this extension IPN begun to work. So I advise that you check any 3rd party extension you have installed that manipulate any address forms or add additional attributes to products etc.

Regards

 
Magento Community Magento Community
Magento Community
Magento Community
 
tecnostep
Jr. Member
 
Total Posts:  8
Joined:  2011-05-10
 

Hi cootetom
could I please ask you to PM contact me? I need to fix the paypal troble, too, and would like to ask you a courtesy about the function you rewrite. Waiting for you kindly reply

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top