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(
            ->description("test customer")

    // Do stuff with the created Customer object

} catch (Pencepay_Exception $e) {
    // Handle exception here


This means that PencepayContext has not been initialized properly, or that the credentials provided were invalid.


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.


The UID you provided (e.g. Transaction UID, or Customer UID) does not point to a valid item, therefore the item was not found.


One or more request parameters you provided are invalid. For example providing an invalid UID will trigger this exception.


There is a problem in the logic of the action itself. Assume that retrying the action will not help.


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.


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.