public function __construct(PayqrInvoice $invoice) { $this->invoice = $invoice; $this->invoiceId = $this->invoice->getInvoiceId(); $marketObj = new Market(); $this->market = $marketObj->getMarket(PayqrConfig::$merchantID); $this->settings = json_decode($this->market->getSettings(), true); }
/** * @param null $x_api_key * @return bool */ private function _checkAuth($x_api_key = null) { $marketObj = new Market(); $this->market = $marketObj->getMarket(Yii::$app->request->get('merchant_id')); if (Yii::$app->request->get('HTTP_X_API_KEY') || !empty($x_api_key) || !$this->market) { $apiKey = Yii::$app->request->get('HTTP_X_API_KEY') ? Yii::$app->request->get('HTTP_X_API_KEY') : $x_api_key; if ($apiKey == "EW5ERdsfwref23") { return true; } else { $this->_sendResponse(401, "Wrong API key"); } } else { $this->_sendResponse(401, "Please, send X-API-KEY header" . serialize($_SERVER)); } return false; }