public function fetchMerchants(array $params = []) { if (Yii::$app->user->getIsGuest()) { return []; // todo show merchants for logged out users } $merchants = []; $params = array_merge(['sum' => $params['amount'] ?: 1, 'site' => Yii::$app->request->getHostInfo(), 'username' => Yii::$app->user->identity->username], (array) $params); try { $merchants = Merchant::perform('PrepareInfo', $params, true); } catch (ErrorResponseException $e) { if ($e->response === null) { Yii::info('No available payment methods found', 'hipanel:finance'); $merchants = []; } else { throw $e; } } foreach ($merchants as $name => $merchant) { if (!static::$supportedSystems[$merchant['system']]) { unset($merchants[$name]); continue; } $merchants[$name] = $this->convertMerchant($merchant); } return $merchants; }
public function checkNotify() { $transactionId = Yii::$app->request->get('transactionId') ?: Yii::$app->request->post('transactionId'); $history = $this->getMerchantModule()->readHistory($transactionId); $data = array_merge(['username' => $history['username'], 'merchant' => $history['merchant'], 'transactionId' => $transactionId], $_REQUEST); Yii::info(http_build_query($data), 'merchant'); Yii::$app->get('hiart')->disableAuth(); try { $result = Merchant::perform('Pay', $data); } catch (HiArtException $e) { $result['_error'] = $e->getMessage(); } Yii::$app->get('hiart')->enableAuth(); return $this->getMerchantModule()->completeHistory(array_merge(compact('transactionId'), $result)); }