private function callGateway($type, $input) { if (empty($input['sign'])) { Secure::sign($input, $type, $this->term->secret); } $response = $this->call('POST', URL::route('ff-mt-em-gateway'), array('type' => $type, 'input' => $input)); $json = $response->getContent(); $data = json_decode($json); return $data; }
/** * @param array $input * @param int $code * @param string $message * * @return void * * @dataProvider check */ public function testCheck($input, $code = null, $message = null) { Secure::sign($input, 'check', 'secret'); $opType = new Type('check', $input); try { $this->assertTrue($opType->validate()); if ($code) { $this->assertFalse(true, 'Exception must be there with code ' . $code); } } catch (ProcessorException $e) { $this->assertEquals($code, $e->getCode(), $e->getMessage()); $this->assertContains($message, $e->getMessage()); } }
/** * @param $input * @param $type * * @return Processor */ private function makeProcessor($input, $type) { Secure::sign($input, $type, 'secret'); $opType = new Type($type, $input); $opProcessor = App::make('FintechFab\\MoneyTransferEmulator\\Components\\Processor\\Processor', array($opType)); return $opProcessor; }
public static function responseSignFail() { $list = array(__LINE__ => array('type' => 'auth', 'input' => array('term' => '123456', 'pan' => '4024007162441306', 'year' => '16', 'month' => '06', 'cvc' => '123', 'amount' => '10.00', 'cur' => 'rub', 'order' => '234', 'name' => 'Shop Name', 'desc' => 'Excellent Shoes Boutique', 'url' => 'http://example.com', 'email' => '*****@*****.**', 'time' => self::time(), 'back' => 'http://example.com/payment/order/234', 'sign' => '123'), 'exceptionCode' => ProcessorException::INVALID_SIGN), __LINE__ => array('type' => 'auth', 'input' => array('term' => '12345', 'pan' => '4024007162441306', 'year' => '16', 'month' => '06', 'cvc' => '123', 'amount' => '10.00', 'cur' => 'rub', 'order' => '234', 'name' => 'Shop Name', 'desc' => 'Excellent Shoes Boutique', 'url' => 'http://example.com', 'email' => '*****@*****.**', 'time' => self::time(), 'back' => 'http://example.com/payment/order/234'), 'exceptionCode' => ProcessorException::INVALID_TERMINAL)); // sign4all requests foreach ($list as &$value) { if (empty($value['input']['sign'])) { Secure::sign($value['input'], $value['type'], 'secret'); } } return $list; }
/** * * 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; }
private function getResponseData() { $data = array('term' => $this->payment->item()->term, 'type' => $this->payment->item()->type, 'code' => $this->payment->item()->code, 'amount' => $this->payment->item()->amount, 'cur' => $this->payment->item()->cur, 'status' => $this->payment->item()->status, 'time' => Time::ts()); Secure::sign($data, $this->type->sid(), $this->term->secret); return $data; }
/** * @param string $secret * * @throws ProcessorException */ public function validateSign($secret) { $inputData = $this->input->all(); Secure::sign($inputData, $this->sid(), $secret); if ($inputData['sign'] !== $this->input->sign) { throw new ProcessorException(ProcessorException::INVALID_SIGN); } }