readConfig(); } public function readConfig() { foreach ($this->config as $key => $value) { $this->$key = $value; } } public function getEssoxOrderUrl() { return $this->getRequestUrl('NewContract', $this->order->total_price->asInteger(), ['OrderId' => $this->order->order_no]); } protected function base64_url_encode($input) { return strtr(base64_encode($input), '+/', '-_'); } protected function getRequestUrl($method, $price, $customData) { $Timestamp = date('YmdHis', time()); // aktualni cas $UserName = $this->userName; // vase prihlasovaci jmeno $Password = $this->encryptKey; // vase heslo $HashKey = $UserName.'#'.$Password.'#'.$price.'#'.$Timestamp; $HashKey = sha1($HashKey); $extendedParameters = join('', array_map(function ($key, $value) { return "<{$key}>{$value}"; }, array_keys($customData), $customData)); $xml = " 1.0 {$method} {$UserName} {$price} {$Timestamp} {$HashKey} {$extendedParameters} "; return $this->url.'?ESXCode=5&ESXAuth='.$this->base64_url_encode(trim($xml)); } public function accept($totalPrice, $freeDelivery) { $totalPrice = $totalPrice->getPriceWithVat()->asFloat(); if ($totalPrice <= 0 && $this->order) { $totalPrice = $this->order->total_price; } return parent::accept($totalPrice, $freeDelivery) && $totalPrice >= 2000; } public function getEssoxCalcUrl(Decimal $price) { $price = roundPrice($price, -1, 'DB', 0)->asInteger(); if ($price < 2000) { return null; } return path('kupshop_ordering_payment_legacypayment', [ 'step' => 5, 'class' => $this->class, 'price' => $price, ]); } public function processStep_1() { redirection($this->getEssoxOrderUrl()); } public function processStep_5() { $price = roundPrice(getVal('price'), -1, 'DB', 0)->asInteger(); if ($price < 2000) { return null; } redirection($this->getRequestUrl('Calculation', $price, [])); } public function startPayment() { // Zakázat automatický redirect na bránu, už se z ní nikdy nevrátí return false; } public function hasOnlinePayment() { return true; } public static function isEnabled($className) { $cfg = Config::get(); if (empty($cfg['Modules']['payments'][$className])) { return false; } return true; } }