/**
  * Возврат средств
  *
  * @param int    $provider_id
  * @param string $bill_id
  * @param int    $refund_id
  *
  * @internal param int $id
  *
  * @return Response
  */
 public function update($provider_id, $bill_id, $refund_id)
 {
     $bill = Bill::getBill($bill_id, $provider_id);
     //Проверяем наличие счёта
     if (!$bill) {
         $data['error'] = Catalog::C_BILL_NOT_FOUND;
         return $this->responseFromGate($data);
     }
     //Проверяем refund_id на уникальность в этом счёте
     if (Refund::isRefundExist($bill_id, $refund_id)) {
         $data['error'] = Catalog::C_BILL_ALREADY_EXIST;
         return $this->responseFromGate($data);
     }
     //Проверяем статус
     if (!$bill->isPaid()) {
         $data['error'] = Catalog::C_BILL_NOT_FOUND;
         return $this->responseFromGate($data);
     }
     //Проверяем запрошенную сумму для отмены
     $amountQuery = Input::get('amount');
     $validator = Validator::make(array('amount' => $amountQuery), Validators::rulesForRefundBill());
     if (!$validator->passes()) {
         $data['error'] = Catalog::C_WRONG_FORMAT;
         return $this->responseFromGate($data);
     }
     //Вычисляем сууму для возврата
     $refundAmount = Refunds::calculateAmount($bill, $amountQuery);
     $data = array('bill_id' => $bill_id, 'refund_id' => $refund_id, 'amount' => $refundAmount, 'status' => 'processing');
     Refunds::NewRefund($data);
     $data['user'] = $bill->user;
     $data['error'] = Catalog::C_WITHOUT_ERRORS;
     return $this->responseFromGate($data);
 }