Magento PayPal Payments Advanced: Not tested code slipped in release?

magento, paypal, php

Solution

Magento is known for setting variables/constants and never using them.

With that said look into `app/code/core/Mage/Paypal/Model/Payflowpro.php` look for the `_postRequest()` method, I would add some debugging around the `$client` and `$result` objects.

Also below on the `catch (Exception $e)` you'll notice the source of your original error message, since this is the case your exception is occurring within the `Varien_Http_Client` :

    try {
       /**
        * we are sending request to payflow pro without url encoding
        * so we set up _urlEncodeBody flag to false
        */
        $response = $client->setUrlEncodeBody(false)->request();
    }
    catch (Exception $e) {
        $result->setResponseCode(-1) 
            ->setResponseReasonCode($e->getCode())
            ->setResponseReasonText($e->getMessage());

        $debugData['result'] = $result->getData();
        $this->_debug($debugData);
        throw $e;
    }

With the above code, your problem most likely is coming from Curl itself, or a mis-configuration on either magento's or the servers end. I would validate Curl is installed and working properly via methods outside of Magento completely, for example:

- http://php.net/manual/en/curl.examples-basic.php

Before the `$response` in the try catch block, I would add a log (`mage::log`) or dump (`zend_debug::dump`) on the `$client` object to get more details on how the request is being formed and sent.

You should be able to find further info within `/lib/Varien/Http/Client.php` and `Adapter/Curl.php` by dumping or logging.

Feel free to post the results of any debugging mentioned above.

Hope this helps!

Problem

I'm setting up Magento installation (using bitnami magento image 1.7.0) and can't get PayPal payments to work. I've set up everything as shown in this video, but after trying to complete order, in payment_payflow_advanced.log I see following: [result] => Array ( [response_code] => -1 [response_reason_code] => 0 [response_reason_text] => Unable to read response, or response is empty ) I've browsed through forums and tried this: 1) DNS issue - I've tried `wget https://payflowlink.paypal.com/` - it works. 2) Curl has SSL enabled What else I could check? Update: I've added url to zend exception, that throws message logged in log, so it tries to access `https://payflowpro.paypal.com:443/transaction`. If I'm trying to open this link in browser, I get 324net::ERR_EMPTY_RESPONSE. Update 2: I've also tried PayFlowLink method, the same issue. Update 3: I’ve noticed something strange. In ``` \magento\htdocs\app\code\core\Mage\Paypal\Model\Payflowlink.php ``` there’s a line: ``` const TRANSACTION_PAYFLOW_URL = 'https://payflowlink.paypal.com/'; ``` Which I think should tell magento where to send data for secure id generation. Thing is, that this constant is not used anywhere in magento code, also this link isn’t used anywhere else, that's why I think it logs request to payflowpro, not payflowlink and I'm wondering if this code was tested by anybody. Update 4: In version 1.7.0.1 looks like same problem as mentioned in Update 3 I’m wondering if anybody had any success setting up PayPal Payments Advanced in Magento, if yes, which version of Magento was there? Update 6: I've made a curl test like this: ``` <?php $ch = curl_init("https://www.google.com/"); $fp = fopen("example_homepage.txt", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); ?> ``` And it wrote file as expected, had no trouble with https. Update 7: ``` Request log: [request] => Array ( [user] => **** [vendor] => me**** [partner] => PayPal [pwd] => **** [verbosity] => HIGH [tender] => C [cancelurl] => http://mydomain.com/index.php/paypal/payflow/cancelPayment [errorurl] => http://mydomain.com/index.php/paypal/payflow/returnUrl [silentpost] => TRUE [silentposturl] => http://mydomain.com/index.php/paypal/payflow/silentPost [returnurl] => http://mydomain.com/index.php/paypal/payflow/returnUrl [template] => minLayout [disablereceipt] => TRUE [cscrequired] => TRUE [cscedit] => TRUE [emailcustomer] => FALSE [urlmethod] => GET [createsecuretoken] => Y [securetokenid] => 7ebabf98872aee2ff84be75d1483e453 [trxtype] => S [amt] => 150.00 [currency] => USD [invnum] => 100000006 [custref] => 100000006 [ponum] => 39 [firstname] => Gxxx [lastname] => Bxxx [street] => Vxxx [city] => Kxxx [state] => Lxxx [zip] => 4xxx [country] => LT [email] => gxxx@xxx.com [shiptofirstname] => Gxxx [shiptolastname] => Bxxx [shiptostreet] => Vxxx [shiptocity] => Kxxx [shiptostate] => Lxxx [shiptozip] => 4xxx [shiptocountry] => LT [user1] => 1 [user2] => 48a9896a17493d6b97de838c4b40026d ) [result] => Array ( [response_code] => -1 [response_reason_code] => 0 [response_reason_text] => Unable to read response, or response is empty. Uri:https://payflowpro.paypal.com:443/transaction ) [__pid] => 31628 ``` As long as have no suggestions, that work, may be someone could suggest easiest way to ensure, that with paypal payments advanced account is everything ok?

Original source