/** * @dataProvider callbacks */ public function testCallback($post, $error, $xml, $message = null) { $connector = new Gateway($this->mock); $result = $connector->doParseCallback($post); if ($error) { $this->assertFalse($result, print_r($post, true)); } else { $this->assertTrue($result, print_r($post, true)); $this->assertEquals($post['bill_id'], $connector->getCallbackOrderId()); $this->assertEquals($post['amount'], $connector->getCallbackAmount()); $this->assertEquals($post['status'], $connector->getValueBillStatus()); $this->assertEquals($message, $connector->getError()); } $this->assertEquals($xml, $connector->getCallbackResponse()); }
/** * Обработка 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(); }