Created
April 25, 2013 08:55
-
-
Save timrogers/5458428 to your computer and use it in GitHub Desktop.
An exposé of the additional methods available on the GoCardless_ApiException class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('lib/GoCardless.php'); | |
$account_details = array( | |
"app_id" => "XXX", | |
"app_secret" => "XXX", | |
"access_token" => "XXX" | |
); | |
GoCardless::set_account_details($account_details); | |
try { | |
GoCardless_PreAuthorization::find("non-existent ID"); | |
} catch (GoCardless_ApiException $e) { | |
print($e->getMessage()); // Returns the result of calling print_r with the JSON (not very useful...) | |
print($e->getJson()); // Returns the raw JSON returned by GoCardless representing the error | |
$response = $e->getResponse(); // Returns an array representing the JSON, generated using json_decode() | |
print($e->getError()); // Returns a string of the "real" error message e.g. "The pre-authorization does not exist" | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment