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 ...