Skip to content

Instantly share code, notes, and snippets.

@timrogers
Created April 25, 2013 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timrogers/5458428 to your computer and use it in GitHub Desktop.
Save timrogers/5458428 to your computer and use it in GitHub Desktop.
An exposé of the additional methods available on the GoCardless_ApiException class
<?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