/** * @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); } }
private function callGateway($type, $input) { Secure::sign($input, $type, $this->term->secret); $response = $this->call('POST', URL::route('ff-bank-em-gateway'), array('type' => $type, 'input' => $input)); $json = $response->getContent(); $data = json_decode($json); return $data; }
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; }
/** * @param array $input * @param int $code * @param string $message * * @return void * * @dataProvider auth */ public function testAuth($input, $code = null, $message = null) { Secure::sign($input, 'auth', 'secret'); $opType = new Type('auth', $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()); } }
private function getResponseData() { $data = array('term' => $this->payment->item()->term, 'type' => $this->payment->item()->type, 'order' => $this->payment->item()->order, 'amount' => $this->payment->item()->amount, 'cur' => $this->payment->item()->cur, 'rc' => $this->payment->item()->rc, 'approval' => $this->payment->item()->approval, 'irn' => $this->payment->item()->irn, 'rrn' => $this->payment->item()->rrn, 'status' => $this->payment->item()->status, 'time' => Time::ts()); $rc = $this->payment->item()->rc; $pan = $this->payment->item()->pan; if ($pan) { $data['pan'] = $pan; } if ($rc !== '00') { if (isset(ProcessorException::$errors[$rc])) { $data['message'] = ProcessorException::$errors[$rc]; } } Secure::sign($data, $this->type->sid(), $this->term->secret); return $data; }
/** * * Generate params for payment shop form * * @param $terminal * * @return array */ private function getEndpointFields($terminal) { $fields = Type::$fields[Type::ENDPOINT]; $params = array(); foreach ($fields as $name) { $value = ''; switch ($name) { case 'term': $value = $terminal->id; break; case 'amount': $value = '123.45'; break; case 'cur': $value = 'RUB'; break; case 'order': $value = '123456'; break; case 'name': $value = 'Boogie-Woogie Shopping'; break; case 'desc': $value = 'Beauty Dress & Smart Phone'; break; case 'url': $value = URL::route('ff-bank-em-shop'); break; case 'back': $value = URL::route('ff-bank-em-shop'); break; case 'time': $value = Time::ts(); break; } $params[$name] = $value; } Secure::sign($params, Type::ENDPOINT, $terminal->secret); return $params; }
/** * @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\\BankEmulator\\Components\\Processor\\Processor', array($opType)); return $opProcessor; }