container->get('net15.payment.mode.manager')->getByPublicKey($publicKey); // We recover the transaction publicKey of the session and we inject the paymentMode $transaction = $this->container->get('net15.transaction.manager')->getByPublicKey($request->getSession()->get('transactionPK')); $transaction = $this->container->get('net15.transaction.manager')->addPaymentMode($transaction,$paymentMode); return $this->render('@Payment/Default/payment.details.html.twig',[ 'transaction'=>$transaction, 'paymentMode'=>$paymentMode, 'rout'=>'api_redsys_tunnel' ]); } public function tunnelAction(Request $request){ $transaction = $this->get('net15.transaction.manager')->getByPublicKey($request->getSession()->get('transactionPK')); $args = $this->container->get('net15.payment.redsys.manager')->init($transaction); return $this->render('@Payment/RedSys/redsys.payment.form.html.twig', $args); } /** * @param string $publicKey * @param Request $request * @return Response */ public function ipnAction(string $publicKey, Request $request){ $transaction = $this->container->get('net15.transaction.manager')->getByPublicKey($publicKey); $status = false; $amount = 0; $redSysObject = new RedsysAPI(); // Recuperate the parameters of online notification. $version = $request->get('Ds_SignatureVersion'); $parameters = $request->get('Ds_MerchantParameters'); $signatureResponse = $request->get('Ds_Signature'); // Decode the DS_MerchantParameters parameter. $decodeParams = $redSysObject->decodeMerchantParameters($parameters); // Recuperate parameters $authResult = $redSysObject->getParameter('Ds_Response'); $transactionId = $redSysObject->getParameter('Ds_AuthorisationCode'); // Validate the signature received and all the parameters sent in the notification $calculatedSignature = $redSysObject->createMerchantSignatureNotif($transaction->getPaymentMode()->getCertificate(), $parameters); if ($calculatedSignature === $signatureResponse){ if ($authResult >= '0000' && $authResult <= '0099'){ $authResult = 'Transaction autorisée pour paiements et pré-autorisations'; $amount = $redSysObject->getParameter('Ds_Amount')/100; $status = true; }elseif ($authResult == '900'){ $authResult = 'Transaction autorisée pour les retours et confirmations'; $amount = $redSysObject->getParameter('Ds_Amount')/100; $status = true; }elseif ($authResult == '400'){ $authResult = 'Transaction autorisée pour les annulations'; $amount = $redSysObject->getParameter('Ds_Amount')/100; $status = true; } } $this->container->get('net15.payment.systempay.manager')->ipn($transaction, $transactionId, $authResult, $amount,$status); return new Response(''); } public function successAction(){ return $this->render('@Payment/Default/payment.success.response.html.twig'); } public function cancelAction(){ return $this->render('@Payment/Default/payment.cancel.response.html.twig'); } }