Question

I'm using coinbase-php to generate payment pages and process orders on my website. I'm able to create buttons and payment pages without any problems, but when I attempt to check an order's status, I get a 401 error. The code I'm using is:

$coinbase = Coinbase::withApiKey($coinbase_key, $coinbase_secret);
$data = json_decode($coinbase->get('/orders/'.$order_id));

And this is the relevant error message:

Notice: exception 'Coinbase_ApiException' with message 'Status code 401' in lib\Coinbase\Requestor.php:22  
Stack trace:  
#0 lib\Coinbase\Rpc.php(95): Coinbase_Requestor->doCurlRequest(Resource id #50)  
#1 lib\Coinbase\Coinbase.php(64): Coinbase_Rpc->request('GET', '/orders/6c00ec5...', Array)  
#2 inc\admin\orders.inc.php(214): Coinbase->get('/orders/N1263OA...')  

I tested several other functions from the library and createButton() seems to be the only one that works.

Was it helpful?

Solution 2

I found that there is a getOrder() function included in coinbase-php, it's just not in the documentation. This code is working:

$coinbase = Coinbase::withApiKey($coinbase_key, $coinbase_secret);
$status = $coinbase->getOrder($order_id)->status;

I'm still not sure exactly why my original code failed, but at least I have a solution.

OTHER TIPS

I see that you have answered your own question, but let me extend on why you got the 401 error.

As @r3wt mentioned, 401 means unauthorized error. Coinbase recently introduced a new feature that can allow you to manage permissions for any api key pair. You can see the permissions here: http://i.imgur.com/ZKoGpz2.png

Your issue may have been caused by incorrect permissions. Coinbase also did have an outage and also updated their API and UI. You might have made your api call then and it might have failed. I hope this explained any questions you might have had.

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