private function initTerm() { $term = $this->term->newInstance(); $this->term = $term->find($this->type->termId()); if (!$this->term) { throw new ProcessorException(ProcessorException::INVALID_TERMINAL); } }
public function setUp() { parent::setUp(); Terminal::truncate(); Payment::truncate(); $this->term = new Terminal(); $this->term->id = 123; $this->term->secret = 'secret'; $this->term->save(); $this->makeCity(); $this->makeFee(); }
/** * * Check, clear and verify input params * * @param $action * @param $type * @param $input * * @throws ProcessorException * @return array */ private function getVerifiedInput($action, $type, $input) { $input = Type::clearInput($type, $input); $baseInput = $input; $termId = $input['term']; $term = Terminal::find($termId); $sign = $input['sign']; Secure::sign($input, $type, $term->secret); $isCorrect = $sign === $input['sign']; if (!$isCorrect) { Log::warning($action . 'pull', array('message' => 'Invalid signature', 'sign' => $input['sign'], 'input' => Input::all())); throw new ProcessorException(ProcessorException::INVALID_SIGN); } Log::info($action . 'pull', array('message' => 'Correct signature', 'input' => Input::all())); return $baseInput; }
<?php use FintechFab\MoneyTransferEmulator\Models\Terminal; Route::filter('ff-mt-em-term', function () { $terminal = Terminal::whereUserId(Config::get('ff-mt-em::user_id'))->first(); if (!$terminal) { return Redirect::route('ff-mt-em-term'); } return null; }); Route::filter('ff-mt-em-auth', function () { $user_id = Config::get('ff-mt-em::user_id'); $user_id = (int) $user_id; if ($user_id <= 0) { return Redirect::to(URL::route('ff-mt-em-error', array(), false))->with('errorMessage', 'Чтобы пользоваться шлюзом, необходима авторизация на сайте. Или, если вы установили шлюз к себе на сервер, настройте значение user_id в локальной конфигурации вашего проекта.'); } return null; });