public function handle($headers, $body, $outputClass = null)
 {
     if ($outputClass !== null) {
         $this->getUnmarshaller()->setOutputClass($outputClass);
     }
     Logger::info('Handling callback');
     Logger::trace('Headers: {0}', $headers);
     Logger::trace('Body: {0}', $body);
     if (!$this->isSignatureCheckDisabled()) {
         $securityHelper = new SecurityHelper($this->apiKey, $this->signatureKey, $this->partnerApiKey, $this->partnerSignatureKey);
         $signature = $securityHelper->getSignature($headers);
         //var_dump($headers);
         $securityHelper->checkSignature($signature, $body);
     }
     return $this->getUnmarshaller()->unmarshall($body);
 }
Пример #2
0
 public function index()
 {
     SecurityHelper::isLogin();
     $data = Input::all();
     // VALIDACIONES
     $rules = array('name' => 'required', 'lastname' => 'required', 'email' => 'required|email', 'password' => 'required|min:8', 'file' => 'mimes:jpeg,bmp,png|max:1000|min:1');
     $messages = array('required' => 'El campo :attribute debe ser completado.', 'email' => 'El mail es incorrecto.', 'min' => 'La clave debe tener al menos 8 caracteres.', 'mimes' => 'El archivo debe ser de un formato de imágen ( jpeg, bmp, png)', 'max' => 'La imágen no puede ser superior a 1Mega');
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->fails()) {
         $user = new User();
         $user->setName = Input::get('name');
         $user->setLastname = Input::get('lastname');
         $user->setEmail = Input::get('email');
         $user->setPassword = Crypt::encrypt(Input::get('password'));
         return Redirect::route('perfil_post', array('user' => $user))->withInput()->withErrors($validator);
     }
     // FIN VALIDACIONES
     // Controlo si subió o NO una imágen.
     if (Input::hasFile('file')) {
         $update_perfil = $this->_updatePerfil('with_new_image');
     } else {
         $update_perfil = $this->_updatePerfil('no_image');
     }
     // Controlo si pude hacer el update correctamente.
     if ($update_perfil) {
         $id = Auth::id();
         $user = User::find($id);
         $image_name = $user->image;
         Session::put('image_user', $image_name);
         return Redirect::to('homepage')->with('success', 'Su perfil fue editado correctamente.');
     } else {
         return Redirect::to('homepage')->with('error', 'No se pudo subir la imágen seleccionada.');
     }
 }
 public function call()
 {
     $queryString = !empty($this->getQuery()) ? http_build_query($this->getQuery()) : null;
     $targetUrl = $this->url . $this->getMethodPath() . ($queryString !== null ? '?' . $queryString : '');
     Logger::trace('Call target URL: ' . $targetUrl);
     $bodyContent = $this->getBody() !== null ? $this->getRequestMarshaller()->marshall($this->getBody()) : null;
     Logger::trace('Call body: ' . $bodyContent);
     $securityHelper = new SecurityHelper($this->apiKey, $this->signatureKey, $this->partnerApiKey, $this->partnerSignatureKey);
     $signature = $securityHelper->calculateSignature($queryString, $bodyContent);
     Logger::trace('Signature: ' . $signature);
     $headers = $this->getHeaders($signature);
     Logger::trace('Headers: {0}', $headers);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $targetUrl);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     if ($bodyContent !== null) {
         curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyContent);
     }
     switch ($this->getHttpMethod()) {
         case self::HTTP_GET:
             curl_setopt($ch, CURLOPT_HTTPGET, true);
             break;
         case self::HTTP_POST:
             curl_setopt($ch, CURLOPT_POST, true);
             break;
         case self::HTTP_PUT:
             curl_setopt($ch, CURLOPT_PUT, true);
             break;
         case self::HTTP_DELETE:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         default:
             break;
     }
     Logger::trace("Calling {0} with http method {1}, body content: {2}", $targetUrl, $this->getHttpMethod(), $bodyContent);
     $response = curl_exec($ch);
     if ($response === false) {
         throw new Exception('Connection error: ' . curl_error($ch));
     }
     $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $responseHeaderSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     curl_close($ch);
     Logger::trace("Response status: {0}, header size: {1}", $responseStatus, $responseHeaderSize);
     $responseHeader = trim(substr($response, 0, $responseHeaderSize));
     $responseBody = trim(substr($response, $responseHeaderSize));
     Logger::trace("Response header: {0}", $responseHeader);
     Logger::trace("Response body: {0}", $responseBody);
     if ($responseStatus != '200') {
         $this->setIsResponseSignatureCheckDisabled(true);
         $this->getResponseUnmarshaller()->setOutputClass(new ApiOperationException());
         $this->getResponseUnmarshaller()->setOutputClassResolveFunction(array('Unmarshaller', 'ResolveExceptionClass'));
         $this->getResponseUnmarshaller()->setIsOutputAnArray(false);
         $this->getResponseUnmarshaller()->setPropertyClassResolveFunctions(array());
     }
     if (!$this->isResponseSignatureCheckDisabled()) {
         $responseSignature = $securityHelper->getSignature($responseHeader);
         $securityHelper->checkSignature($responseSignature, $responseBody);
     }
     $output = $this->getResponseUnmarshaller()->unmarshall($responseBody);
     if ($output instanceof Exception) {
         throw $output;
     }
     return $output;
 }
 public function toExport()
 {
     try {
         SecurityHelper::isLogin();
         $data = Input::all();
         // VALIDACION
         $messages = array('validate_file_cobranzas' => 'El archivo de cobranzas es incorrecto.', 'required' => 'El campo :attribute debe ser completado');
         $rules = array('file' => array('validate_file_cobranzas', 'required'));
         $validator = Validator::make($data, $rules, $messages);
         if ($validator->fails()) {
             return Redirect::to('pmc_export_excel')->withErrors($validator);
         }
         // FIN DE VALIDACION
         $data_array = $this->_createArray();
         $create_excel = $this->_createExcel($data_array);
         if ($create_excel != NULL) {
             $insert_file_db = $this->_insertFile($create_excel, 'cobranzas');
             //$send_email = $this->_sendEmailExcelCobranzas($create_excel);
             if ($insert_file_db) {
                 return Redirect::to('homepage')->with('success', 'El excel generado de cobranzas de Pagomiscuentas fue insertado en la base.');
             }
         } else {
             return Redirect::to('homepage')->with('error', 'No se pudo generar el excel de cobranzas de Pagomiscuentas. . . .');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }