public function setUp()
 {
     parent::setUp();
     $order = new Order();
     $order->create(array('user_id' => 1, 'item' => 'New Lamp2', 'sum' => 543.21, 'tel' => '+7123', 'comment' => 'without', 'status' => 'new', 'lifetime' => date('Y-m-d H:i:s', time() + 3600 * 24 * 3)));
     $this->mock = Mockery::mock('FintechFab\\QiwiSdk\\Curl');
 }
 public function setUp()
 {
     parent::setUp();
     Order::truncate();
     $order = new Order();
     $order->create(array('user_id' => 1, 'item' => 'New Lamp', 'sum' => 150, 'tel' => '+12345', 'comment' => '', 'status' => 'payable', 'lifetime' => date('Y-m-d H:i:s', time())));
 }
 /**
  * Получить новый счёт
  *
  * @return void
  */
 public function testGetBillSuccess()
 {
     App::bind('FintechFab\\QiwiSdk\\Curl', function () {
         $bill = array('user' => 'tel:+7123', 'amount' => 543.21, 'ccy' => 'RUB', 'comment' => 'without', 'lifetime' => date('Y-m-d\\TH:i:s', time() + 3600 * 24 * 3), 'prv_name' => Gateway::getConfig('provider.name'));
         $args = array(1, 'PUT', $bill);
         $this->mock->shouldReceive('request')->withArgs($args)->andReturn((object) array('response' => (object) array('result_code' => 0, 'bill' => (object) array('bill_id' => 123))));
         return $this->mock;
     });
     $order = new Order();
     $order->create(array('user_id' => 1, 'item' => 'New Lamp2', 'sum' => 543.21, 'tel' => '+7123', 'comment' => 'without', 'status' => 'new', 'lifetime' => date('Y-m-d H:i:s', time() + 3600 * 24 * 3)));
     $resp = $this->call('POST', Config::get('ff-qiwi-shop::testConfig.testUrl') . '/action/createBill', array('order_id' => '1'));
     $this->assertContains('Счёт выставлен', $resp->original['message']);
 }
 /**
  * Проверка статуса возврата с несозданным возвратом
  */
 public function testShowStatusPayReturn()
 {
     App::bind('FintechFab\\QiwiSdk\\Curl', function () {
         $args = array(1, 'GET', null, 1);
         $this->mock->shouldReceive('request')->withArgs($args)->andReturn((object) array('response' => (object) array('result_code' => 0, 'refund' => (object) array('status' => 'processing'))));
         return $this->mock;
     });
     $order = Order::find(1);
     $order->idLastReturn = 1;
     $order->save();
     $payReturn = new PayReturn();
     $payReturn->create(array('order_id' => $order->id, 'sum' => 15, 'status' => 'onReturn'));
     $resp = $this->call('POST', Config::get('ff-qiwi-shop::testConfig.testUrl') . '/action/statusReturn', array('order_id' => '1'));
     $this->assertContains('Текущий статус возврата - на возврате', $resp->original['message']);
 }
 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');
 }
 /**
  * Обработка 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();
 }
Exemple #7
0
 /**
  * Изменяем id последнего возврата
  *
  * @param $IdPayReturn
  */
 public function changeAfterReturn($IdPayReturn)
 {
     Order::whereId($this->id)->update(array('status' => 'returning', 'idLastReturn' => $IdPayReturn));
 }