Question

I want to use recurly for billing. I just have a very simple example like this for testing in my indexController:

public function init() {
    require_once APPLICATION_PATH . '/../library/Recurly/recurly.php';
    Recurly_Client::$apiKey = Zend_Registry::get('config')->get('recurly')->get('apikey');
    Recurly_js::$privateKey = Zend_Registry::get('config')->get('recurly')->get('jskey');
    Recurly_Client::$subdomain = 'mysubdomain';
}

My recurlyAction:

public function recurlyAction(){
    try{
        $invoices = Recurly_InvoiceList::get();
        foreach ($invoices as $invoice) {
            print "Invoice: $invoice\n";
        }
    }
    catch (Recurly_NotFoundError $e) {
        print 'Record could not be found';
    }
    catch (Recurly_ValidationError $e) {
        // If there are multiple errors, they are comma delimited:
        $messages = explode(',', $e->getMessage());
        print 'Validation problems: ' . implode("\n", $messages);
    }
    catch (Recurly_ServerError $e) {
        print 'Problem communicating with Recurly';
    }
    catch (Exception $e) {
        // You could use send these messages to a log for later analysis.
        print get_class($e) . ': ' . $e->getMessage();
    }
}

I'm trying to show all the invoices, just for testing. The problem is I always get an exception like this:

Recurly_ConnectionError: Failed to connect to Recurly.

I've checked all my keys with var_dump in my Action and they all show up correctly. I don't get any response as you can see:

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:4853
Content-Type:text/html
Date:Tue, 01 Oct 2013 06:54:36 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.2.22 (Debian)
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.3-1~dotdeb.1

I'm working with a vagrant box, could that be the problem? Can anybody help me with this? I'm stuck with it for a couple of days now ...

UPDATE:
Sometimes I get the invoices, sometimes not ...

Was it helpful?

Solution 2

Created a support ticket on recurly and got this answer:

Are you getting any errors like this connecting to other services? In the client.php file, the connection timeout is set to 10 (which should be more than enough). You could try adjusting that.

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

Normally, you shouldn't have to edit this but I changed it to 30 and now it works fine ..

OTHER TIPS

As @karthikr said, it sounds like a timeout or networking issue. Are you able to use CURL on the console to access it?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top