/** * List all created customers * * @return array list of customers * @throws White_Error_Parameters if any of the parameters is invalid * @throws White_Error_Authentication if the API Key is invalid * @throws White_Error if there is a general error in the API endpoint * @throws Exception for any other errors */ public static function all() { $url = White::getEndPoint('customer_list'); $ch = curl_init(); curl_setopt($ch, CURLOPT_CAINFO, White::getCaPath()); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, White::getApiKey() . ':'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = json_decode(curl_exec($ch), true); // Check for errors and such. $info = curl_getinfo($ch); $errno = curl_errno($ch); if ($result === false || $errno != 0) { // Do error checking throw new Exception(curl_error($ch)); } else { if ($info['http_code'] != 200) { // Got a non-200 error code. White::handleErrors($result, $info['http_code']); } } curl_close($ch); return $result; }
function testApiKey() { $testKey = 'sk_test_1234567890abcdefghijklmnopq'; White::setApiKey($testKey); $this->assertEquals($testKey, White::getApiKey()); }