public function __construct()
 {
     $args = func_get_args();
     $previous = null;
     switch (count($args)) {
         case 2:
         case 3:
             $message = $args[0];
             $code = (int) $args[1];
             break;
         default:
             $message = $this->getFromCode($args[0]);
             $code = (int) $args[0];
             break;
     }
     foreach ($args as $key => $value) {
         if ($value instanceof Exception) {
             $previous = $value;
         }
     }
     parent::__construct($message, $code, $previous);
 }
 /**
  * Cancels an existing transaction using the CancelTransaction JSON service
  * 
  * @param string $transactionId The transaction number which should be cancelled
  * @return array API response
  */
 public function cancelTransaction($transactionId)
 {
     $params = array("merchantId" => $this->config['merchant_id'], "transactionId" => $transactionId);
     $result_params = $this->postToDIBS("CancelTransaction", $params);
     //Error code/string handling, thx dibs...
     //Dibs docs says that a string is returned but it seemts to be just a code
     if (!isset($result_params["declineReason"]) || $result_params["declineReason"] === "") {
         $decline_reason = "-";
     } elseif (preg_match('/[0-9]+/', $result_params["declineReason"])) {
         $decline_reason = DibsErrorException::getPaymentHandlingErrorDesc($result_params["declineReason"]);
     } else {
         $decline_reason = $result_params["declineReason"];
     }
     if ($result_params['status'] == "ACCEPT") {
         //Accept
     } elseif ($result_params["status"] == "DECLINE") {
         throw new DibsErrorException("CancelTransaction: DECLINE (" . $decline_reason . ")");
     } elseif ($result_params["status"] == "ERROR") {
         throw new DibsErrorException("CancelTransaction: ERROR (" . $decline_reason . ")");
     }
     return $result_params;
 }