PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Solution to an Issue I had with HTTP Posts to PayPal

  1. I thought I'd share my experience with the community with an issue I had when sending test transactions to PayPal using the GF PayPal Add-on.

    I was struggling earlier today when my HTTP posts to PayPal (via GravityForms PayPal Add-on) were not loading the PayPal Checkout Page. After stepping through my code with a debugger, I was able to capture the following validation exception when sending the HTTP request to PayPal:

    SSL certificate problem, verify that the CA cert is OK

    Typically, this is an indication that a CA (Certificate Authority) cert cannot be located on the webserver sending the HTTP Post. The CA cert is needed to verify the issuer of a SSL Certificate is from a trusted source.

    After much troubleshooting and research, I was able to download a copy of a CA cert and verify I could send HTTP Posts via SSL using the CURL API in some test code. Sadly though, I was still receiving this "SSL certificate problem" exception when testing via the PayPal Plugin.

    I then realized the PayPal plugin was using the WP_HTTP class to send HTTP Requests as seen in gravityformspaypal/paypal.php on LINE 2096:

    $request = new WP_Http();
    $response = $request->post($url, array("ssl" => true, "body" => $req));

    I then modified the lines as follows.

    //NOTE: Change WP_Http() to WP_Http_Curl()
    $request = new WP_Http_Curl();  
    //NOTE: Changed $request->post to $request->request
    $response = $request->request($url, array("ssl" => true, "body" => $req));

    I was FINALLY able to access the PayPal checkout page via GravityForms PayPal Add-on after applying the changes and retesting my form submission.

    This issue was isolated only to WordPress running on my Windows Development Machine and XAMPP. I had no issues on my production linux server. The new code works on both servers.

    I hope this was helpful.

    Posted 11 years ago on Tuesday March 29, 2011 | Permalink
  2. We do use the WP_HTTP API for the interaction because this is the standard way of doing it with a WordPress plugin. WP_HTTP uses whatever methods are available on the server from a variety, so that servers that don't have CURL can still use WP_HTTP and it will pick the available method. This is why we don't rely strictly on CURL as it's not always present.

    Unfortunately interaction with services like PayPal and other API's always introduces complexities that can't always be accounted for.

    Glad you figured it out, and we'll note this information in case other users encounter the same issue. We can also look into how we can handle this in the future. Maybe have a settings option or a hook to force wp_http_curl instead of wp_http.

    Posted 11 years ago on Tuesday March 29, 2011 | Permalink
  3. I am glad you figured this out, but I am a little confused when you say the plugin "was not loading the PayPal Checkout Page". Your changes above were actually related to the IPN, which happens after you go through PayPal's checkout process.

    Posted 11 years ago on Tuesday March 29, 2011 | Permalink
  4. @Carl - My issue definitely falls under the category of "Exception to the Rule" and is most likely not the norm for majority of production environments. I too was surprised that WP_Http did not resolve the most appropriate protocol for the HTTP Request. So far, I've only encountered this strange issue on my Windows dev machine. This is not an issue on my Linux Production Server.

    Posted 11 years ago on Tuesday March 29, 2011 | Permalink
  5. @Alex - You make a good point. I just realized I made an incorrect assessment of what I was observing. Prior to changing WP_Http, I never saw a PayPal checkout page appear. In fact, I never received an error message indicating there was a problem when filling out a test payment page or testing the IPN link from PayPal. After I changed to WP_Http_Curl, tested the IPN link, and then completed a test GF PayPal form, I finally saw the PayPal Checkout page. At the time, I was not able to discern the actual sequence of steps that resolved the issue.

    I'm now assuming either PayPal or the GF Paypal Add-on may not enable the checkout page to appear until the IPN link has been validated once. The SSL issue encountered in verify_paypal_ipn() may have prevented the message: cmd=_notify-validate from being sent to PayPal and and GF Paypal never received a Validated response from PayPal. I can't locate any documentation that would confirm this either way.

    However, I am very certain it wasn't until after making the change to WP_Http_Curl, that I was able to receive an actual response from PayPal and view the checkout page when completing the test payment form.


    David Carroll

    Posted 11 years ago on Tuesday March 29, 2011 | Permalink