display_column_left = false; $this->display_column_right = false; $this->display_footer = false; $this->display_header = false; parent::init(); } /** * Send request for activated payment methods */ public function process() { $imojePaymentMethods = json_decode(Configuration::get('IMOJE_PAYMENT_METHODS'), true); if(!function_exists('curl_init')) { $imojePaymentMethods['errorCurl'] = true; Configuration::updateValue('IMOJE_PAYMENT_METHODS', json_encode($imojePaymentMethods)); Tools::redirect($_SERVER['HTTP_REFERER']); return; } $algoHash = 'sha256'; $postData = json_encode([]); $curlInit = curl_init(\Imoje\Payment\Configuration::getServiceUrl(Configuration::get('IMOJE_SANDBOX') ? Util::ENVIRONMENT_SANDBOX : Util::ENVIRONMENT_PRODUCTION) . \Imoje\Payment\Configuration::ROUTE_CHECK_PAYMENT_METHODS); curl_setopt($curlInit, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($curlInit, CURLOPT_POSTFIELDS, $postData); curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlInit, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curlInit, CURLOPT_TIMEOUT, 10); curl_setopt($curlInit, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'X-Imoje-Signature: merchantid=' . Configuration::get('IMOJE_MERCHANT_ID') . ';serviceid=' . Configuration::get('IMOJE_SERVICE_ID') . ';signature=' . Util::hashSignature($algoHash, $postData, Configuration::get('IMOJE_SERVICE_KEY')) . ';alg=' . $algoHash, ]); $resultCurl = curl_exec($curlInit); if(!$resultCurl || curl_getinfo($curlInit, CURLINFO_HTTP_CODE) !== 200 || !Util::isJson($resultCurl)) { $imojePaymentMethods['errorTmp'] = true; Configuration::updateValue('IMOJE_PAYMENT_METHODS', json_encode($imojePaymentMethods)); Tools::redirect($_SERVER['HTTP_REFERER']); return; } $receivedPaymentMethods = json_decode($resultCurl, true); if(isset($receivedPaymentMethods['status']) && $receivedPaymentMethods['status'] !== 'ok') { $imojePaymentMethods['errorTmp'] = true; Configuration::updateValue('IMOJE_PAYMENT_METHODS', json_encode($imojePaymentMethods)); Tools::redirect($_SERVER['HTTP_REFERER']); return; } $paymentMethods = [ 'successTmp' => true, ]; if(isset($receivedPaymentMethods['data']['twisto']) && $receivedPaymentMethods['data']['twisto']['enable']) { $paymentMethods['twisto'] = [ 'sk' => $receivedPaymentMethods['data']['twisto']['sk'], 'pk' => $receivedPaymentMethods['data']['twisto']['pk'], 'timeout' => $receivedPaymentMethods['data']['twisto']['timeout'], ]; if(Configuration::get('IMOJE_TWISTO_ENABLED') === false) { Configuration::updateValue('IMOJE_TWISTO_ENABLED', 1); } } else { $paymentMethods['noTwisto'] = true; } Configuration::updateValue('IMOJE_PAYMENT_METHODS', json_encode($paymentMethods)); Tools::redirect($_SERVER['HTTP_REFERER']); return; } }