public function postSettings()
 {
     $data = Input::only('name', 'gateId', 'password', 'key', 'lifetime', 'gateUrl', 'payUrl');
     $validate = Validator::make($data, Validators::rulesForSetting(), Validators::messagesForErrors());
     $userMessages = $validate->messages();
     if ($validate->fails()) {
         $result['errors'] = array('name' => $userMessages->first('name'), 'gateId' => $userMessages->first('gateId'), 'password' => $userMessages->first('password'), 'key' => $userMessages->first('key'), 'lifetime' => $userMessages->first('lifetime'), 'gateUrl' => $userMessages->first('gateUrl'), 'payUrl' => $userMessages->first('payUrl'));
         return $result;
     }
     $data['user_id'] = Config::get('ff-qiwi-shop::user_id');
     $setting = Setting::find($data['user_id']) != null ? Setting::find($data['user_id']) : new Setting();
     $setting->newSettings($data);
     return array('message' => 'Настройки сохранены');
 }
Esempio n. 2
0
 public function setUp()
 {
     parent::setUp();
     /**
      * @var UserInterface|Mockery\MockInterface $mock
      */
     $mock = Mockery::mock('Illuminate\\Auth\\UserInterface');
     $mock->shouldReceive('getAuthIdentifier')->andReturn(5);
     Auth::login($mock);
     Order::truncate();
     Setting::truncate();
     Setting::create(array('id' => 1, 'name' => 'Fintech-fab', 'lifetime' => 3, 'gate_id' => 1, 'gate_password' => 1234, 'gate_key' => 'key', 'gate_url' => 'http://fintech-fab.dev/qiwi/gate/api/v2/prv/', 'pay_url' => 'http://fintech-fab.dev:8000/qiwi/gate/order/external/main.action'));
     Config::set('ff-qiwi-shop::user_id', 1);
     Config::set('gateUrl', 'http://fintech-fab.dev/qiwi/gate/api/v2/prv/');
     Config::set('ff-qiwi-shop::provider.id', 1);
     Config::set('ff-qiwi-shop::provider.password', 1234);
     Config::set('ff-qiwi-shop::provider.name', 'Fintech-fab');
     Config::set('ff-qiwi-shop::provider.key', 'key');
     Config::set('ff-qiwi-shop::testConfig.testUrl', 'http://fintech-fab-test.dev:8080/qiwi/shop/orders');
 }
Esempio n. 3
0
 /**
  * Обработка callback запроса
  *
  * @return string
  */
 public function processCallback()
 {
     $request = Request::header();
     Log::info('Пришёл запрос callback с такими заголовками ', $request);
     $provider = $this->getProvider();
     $oSettings = Setting::whereGateId($provider['login'])->first();
     $this->setConfigForGateway($oSettings);
     $requestParams = Input::all();
     Log::info('Получены параметры в qiwi-shop для обработки callback:', array('$requestParams' => $requestParams, '$provider' => $provider));
     $gate = new Gateway($this->makeCurl());
     if ($gate->doParseCallback($requestParams)) {
         $order = Order::find($gate->getCallbackOrderId());
         if (!$order) {
             $gate->createCallbackResponse(Gateway::C_BILL_NOT_FOUND);
             return $gate->doCallbackResponse();
         }
         $newStatus = $gate->getValueBillStatus();
         Log::info('Статусы заказов после обработки callback:', array('oldStatus' => $order->status, 'newStatus' => $newStatus));
         if ($order->status != $newStatus) {
             $order->status = $newStatus;
             $order->save();
         }
     }
     return $gate->doCallbackResponse();
 }