Created
December 21, 2012 10:33
-
-
Save pkdavies/4352021 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git app/code/core/Mage/Paypal/Model/Ipn.php app/code/core/Mage/Paypal/Model/Ipn.php | |
index 730d09b..eb5f0e0 100644 | |
--- app/code/core/Mage/Paypal/Model/Ipn.php | |
+++ app/code/core/Mage/Paypal/Model/Ipn.php | |
@@ -139,8 +139,20 @@ class Mage_Paypal_Model_Ipn | |
$this->_debugData['postback'] = $sReq; | |
$this->_debugData['postback_to'] = $this->_config->getPaypalUrl(); | |
+ /** | |
+ * Array of http headers required by PayPal | |
+ * | |
+ * @link https://www.x.com/node/320404 | |
+ * @var array $httpHeaders | |
+ */ | |
+ $httpHeaders = array( | |
+ 'Content-Type: application/x-www-form-urlencoded', | |
+ 'Host: ' . Zend_Uri::factory($this->_config->getPaypalUrl())->getHost(), | |
+ 'Connection: close' | |
+ ); | |
+ | |
$httpAdapter->setConfig(array('verifypeer' => $this->_config->verifyPeer)); | |
- $httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', array(), $sReq); | |
+ $httpAdapter->write(Zend_Http_Client::POST, $this->_config->getPaypalUrl(), '1.1', $httpHeaders, $sReq); | |
try { | |
$response = $httpAdapter->read(); | |
} catch (Exception $e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update your IPN/PDT Scripts on ALL Magento's
Dear XXXXX,
It has come to our attention that some merchants were experiencing issues getting their IPN scripts updated to use HTTP 1.1 because the scripts would get "hung" or take a long time to get a ‘VERIFIED’ response. We are including instructions on how to remedy this issue by adding a "Connection: close" header in the HTTP request.
In a bulletin dated October 18, 2011, we announced that we were going to expand the number of IP addresses for www.paypal.com to improve our site’s performance, scalability and availability. As part of this transition, we planned to discontinue support for the HTTP 1.0 protocol starting February 1, 2013.
We have recently identified that this change may impact the ability of some of our merchants to perform IPN (Instant Payment Notification) post-back validation or PDT (Payment Data Transfer) posts to www.paypal.com. This happens when the IPN or PDT scripts use the HTTP 1.0 protocol and do not include the “Host: www.paypal.com” header in the HTTP request.
Additional Details Starting February 1, 2013, we will require all incoming requests to have a “Host” header which complies with HTTP 1.1 Specifications. This header was not required under HTTP 1.0. IPN and PDT scripts using HTTP 1.0 may start failing with “HTTP/1.1 400 Bad Request” errors after February 1, 2013, which will result in IPN messages not being validated successfully, or PDT scripts not being able to retrieve transaction information.
Your Action Required before February 1, 2013 You will need to update your IPN and/or PDT scripts to use HTTP 1.1, and include the "Host: www.paypal.com" and "Connection: close" HTTP headers in the IPN and PDT scripts.
For examples, please refer to https://www.x.com/node/320404.
The PayPal Sandbox has been configured to reject any HTTP requests without the "Host" header with a HTTP 400 error. Merchants can use the Sandbox environment to certify the changes to their IPN and PDT scripts.
For more information on PDT and IPN, please refer to https://www.paypal.com/pdt and https://www.paypal.com/ipn. For additional information or questions about this change, please contact PayPal's Merchant Technical Support team via https://www.paypal.com/mts.
Sincerely,
PayPal