/** * Makes a new authorization on an existing ticket using the AuthorizeTicket JSON service * * @param int $amount The amount of the purchase in smallest unit * @param string $orderId The shops order ID for the purchase * @param string $ticketId The ticket number on which the authorization should be done * @return array API response */ public function authorizeTicket($amount, $orderId, $ticketId) { $params = array("amount" => $amount, "currency" => $this->config['currency'], "merchantId" => $this->config['merchant_id'], "orderId" => $orderId, "ticketId" => $ticketId); $result_params = $this->postToDIBS("AuthorizeTicket", $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::getPaymentAuthorizationErrorDesc($result_params["declineReason"]); } else { $decline_reason = $result_params["declineReason"]; } if ($result_params['status'] == "ACCEPT") { //Accept } elseif ($result_params["status"] == "DECLINE") { throw new DibsErrorException("AuthorizeTicket: DECLINE (" . $decline_reason . ")"); } elseif ($result_params["status"] == "ERROR") { throw new DibsErrorException("AuthorizeTicket: ERROR (" . $decline_reason . ")"); } return $result_params; }