Exceptions
When you male a server-side library call, in case of certain problems an Exception will be raised by the library. You can catch this exception and act upon it as appropriate.
Each exception has an code
and message
properties, while some have additional properties as well.
You can handle exceptions in an usual way.
try {
$customer = Pencepay_Customer::create(
Pencepay_Request_Customer::build()
->description("test customer")
);
// Do stuff with the created Customer object
$customer->uid;
} catch (Pencepay_Exception $e) {
// Handle exception here
$e->getMessage();
$e->getCode();
}
ApiAuthenticationException
This means that PencepayContext
has not been initialized properly, or that the credentials provided were invalid.
ApiConnectionException
This is a low-level problem in communicating with Pencepay. This usually means that there is an internet connection problem, our servers are down or that you have a firewall blocking the calls.
ItemNotFoundException
The UID you provided (e.g. Transaction UID, or Customer UID) does not point to a valid item, therefore the item was not found.
InvalidRequestException
One or more request parameters you provided are invalid. For example providing an invalid UID will trigger this exception.
ProcessingException
There is a problem in the logic of the action itself. Assume that retrying the action will not help.
ServerSideException
Occurs when there is an configuration or execution problem at Pencepay for this merchant. Either the configuration for the action requested does not allow this action, or the configuration is invalid. You should inspect the message
for full details about the issue.
UnexpectedException
Something unexpected happened, probably inside the library itself, or having to do with the transport format, e.g. invalid JSON was received. Assume that this is a serious error and if possible contact our Support so that we can sort out the issue.