/**
  * Payment reponse
  *
  * @param Request $request Request element
  *
  * @return RedirectResponse
  *
  *
  */
 public function confirmationAction(Request $request)
 {
     $paymentMethod = new PagosonlineGatewayMethod();
     $paymentBridge = $this->get('payment.bridge');
     $signature = $request->request->get('firma');
     $statusPol = $request->request->get('estado_pol');
     $currency = $request->request->get('moneda');
     $value = $request->request->get('valor');
     $orderRef = $request->request->get('ref_venta');
     $userId = $request->request->get('usuario_id');
     $key = $this->container->getParameter('pagosonline_gateway.key');
     $signatureHash = md5($key . '~' . $userId . '~' . $orderRef . '~' . $value . '~' . $currency . '~' . $statusPol);
     $referencePol = $request->request->get('ref_pol');
     $infoLog = array('firma' => $signature, 'estado_pol' => $statusPol, 'moneda' => $currency, 'valor' => $value, 'ref_venda' => $orderRef, 'usuario_id' => $userId, 'hash' => $signatureHash, 'ref_pol' => $referencePol, 'action' => 'confirmationAction');
     $this->get('logger')->addInfo($paymentMethod->getPaymentName(), $infoLog);
     //@TODO use notifyPaymentOrderLoad for check order
     $orderRefPol = explode("#", $orderRef);
     $orderId = $orderRefPol[0];
     $paymentMethod->setPagosonlineGatewayTransactionId($referencePol);
     $paymentMethod->setPagosonlineGatewayReference($referencePol);
     $paymentMethod->setReference($orderRef);
     $paymentMethod->setStatus($statusPol);
     $order = $paymentBridge->findOrder($orderId);
     $paymentBridge->setOrder($order);
     $orderPaidStatus = 4;
     if (strtoupper($signatureHash) == $signature) {
         if ($statusPol == $orderPaidStatus) {
             $this->get('payment.event.dispatcher')->notifyPaymentOrderSuccess($paymentBridge, $paymentMethod);
         } else {
             $this->get('payment.event.dispatcher')->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         }
     }
     return new Response();
 }
 public function checkTransactionStatus($transactionId)
 {
     //All information of transaction response
     $statusTransactionWS = $this->pagosonlineComm->consultarEstadoTransaccion($this->accountId, $transactionId);
     $paymentMethod = new PagosonlineGatewayMethod();
     $paymentMethod->setPagosonlineGatewayTransactionId($statusTransactionWS->transaccionId);
     $paymentMethod->setStatus($statusTransactionWS->estadoId);
     $paymentMethod->setReference($statusTransactionWS->referencia);
     $paymentMethod->setAmount($statusTransactionWS->valor);
     $this->logger->addInfo($paymentMethod->getPaymentName() . 'processTransactionCheck', get_object_vars($statusTransactionWS));
     /**
      * if pagosonline return code 15 o 9994 the order status is pending
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
     if ($statusTransactionWS->codigoRespuesta == 1) {
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     } elseif (!in_array($statusTransactionWS->codigoRespuesta, array(15, 9994))) {
         //status 15 or 9994 payment is still in pending nothing to do
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
     }
 }