<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Entity\PayementMethod;
use App\Entity\Congre;
use App\Entity\ConnexionUser;
use App\Entity\PrixVariableCongre;
use App\Entity\PrixVariable;
use Symfony\Component\Validator\Constraints\DateTime;
use App\Entity\EvenementAVenir;
use App\Entity\EvenementFormulaire;
use App\Form\formulaireEvenementType;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\String\Slugger\SluggerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
class PaimentController extends AbstractController
{
private $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function virrementbancaireSend(ManagerRegistry $doctrine,Request $request,$id,$idprix, SluggerInterface $slugger)
{
if($idprix != 79 && $idprix != 80)
{
echo "évenement non disponible .<br>merci de retour a la page accueil <a href='/'>accueil</a>";exit();
}
$file = $request->files->get('receipt'); // Récupère le fichier du formulaire
$ret="";
$success="";
$session = $this->requestStack->getSession();
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix=0;
if($session->get('type')=="Adhérent")
{
$prix=0;
}else
{
$prix=0;
}
if($prix==0)
{
$prix = $p[0]->getPrix();
}else
{
$prix = $p[0]->getPrix()+20;
}
if ($file) {
$allowedExtensions = ['png', 'jpg', 'jpeg', 'pdf'];
$fileExtension = $file->guessExtension();
if (!in_array($fileExtension, $allowedExtensions)) {
$ret= "Extension non autorisée. Seuls les fichiers PNG, JPG, JPEG et PDF sont acceptés.";
return $this->render('paiment/virement.html.twig',['prix'=>$prix,'id'=>$id,'idprix'=>$idprix,'ret'=>$ret,'success'=>$success]);
}
$maxFileSize = 2097152; // 2 Mo en octets
if ($file->getSize() > $maxFileSize) {
$ret= "La taille du fichier ne doit pas dépasser 2 Mo.";
return $this->render('paiment/virement.html.twig',['prix'=>$prix,'id'=>$id,'idprix'=>$idprix,'ret'=>$ret,'success'=>$success]);
}
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$file->guessExtension();
$em = $this->getDoctrine()->getManager();
$lastOrder = $em->getRepository(PayementMethod::class)
->createQueryBuilder('o')
->orderBy('o.id', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
$lastOrder=$lastOrder->getOrdernumber();
$PayementMethod = new PayementMethod();
$PayementMethod->setOrderNumber($lastOrder+1);
$PayementMethod->setNom($session->get('nom'));
$PayementMethod->setEmail($session->get('emailSend'));
$PayementMethod->setPrenom($session->get('prenom'));
$repository = $doctrine->getRepository(Congre::class);
$congrevide = $repository->find($id);
$PayementMethod->setEvenementId($congrevide);
$PayementMethod->setPai(0);
$PayementMethod->setUrl("0");
$PayementMethod->setMontant(($prix));
$PayementMethod->setPhone($session->get('phone'));
$PayementMethod->setTotal(($prix));
$PayementMethod->setFile($newFilename);
$em->persist($PayementMethod);
$em->flush();
try {
$file->move(
$this->getParameter('receipts_directory'),
$newFilename
);
$success= "Votre inscription a été effectuée avec succès
Merci pour votre confiance
";
} catch (FileException $e) {
$ret.= "Erreur lors de l'upload : ".$e->getMessage();
}
} else {
$ret.= "Aucun fichier n'a été téléchargé.";
}
return $this->render('paiment/virement.html.twig',['prix'=>$prix,'id'=>$id,'idprix'=>$idprix,'ret'=>$ret,'success'=>$success]);
}
public function virrementbancaire(ManagerRegistry $doctrine,Request $request,$id,$idprix)
{
if($idprix != 79 && $idprix != 80)
{
echo "évenement non disponible .<br>merci de retour a la page accueil <a href='/'>accueil</a>";exit();
}
$session = $this->requestStack->getSession();
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix=0;
if($session->get('type')=="Adhérent")
{
$prix=0;
}else
{
$prix=0;
}
if($prix==0)
{
$prix = $p[0]->getPrix();
}else
{
$prix = $p[0]->getPrix()+20;
}
return $this->render('paiment/virement.html.twig',['prix'=>$prix,'id'=>$id,'idprix'=>$idprix]);
}
public function formulaire(ManagerRegistry $doctrine,Request $request,$id)
{
/*if($idprix != 79 && $idprix != 80 && $idprix != 81 && $idprix != 82)
{
echo "évenement non disponible .<br>merci de retour a la page accueil <a href='/'>accueil</a>";
exit();
}*/
if($id!=20)
{
echo "évenement non disponible .<br>merci de retour a la page accueil <a href='/'>accueil</a>";
exit();
}
$erreur="";
$verif=true;
$messageSuccess="";
$entityManager = $doctrine->getManager();
$article = new EvenementFormulaire();
$form = $this->createForm(formulaireEvenementType::class, $article);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if($article->getFonction() == "Etudiant")
{
$article->setType("Adhérent");
}
if(Empty($article->getNom()))
{
$erreur.="Nom invalide <br>";
$verif=false;
}
else if(strlen($article->getNom())<2 || strlen($article->getNom())>30)
{
$erreur.="Nom invalide <br>";
$verif=false;
}
else
{
$verif=true;
}
if(Empty($article->getPrenom()))
{
$erreur.="Prénom invalide <br>";
$verif=false;
}
else if(strlen($article->getPrenom())<2 || strlen($article->getPrenom())>30)
{
$erreur.="Prénom invalide <br>";
$verif=false;
}
/**** verif email */
if(strlen($article->getEmail())<4 || strlen($article->getEmail())>30)
{
$erreur.="Email invalide <br>";
$verif=false;
}
else
{
$verif=true;
}
/***** */
if(Empty($article->getPhone()))
{
$erreur.="Numéro de téléphone invalide <br>";
$verif=false;
}
else if(strlen($article->getPhone())<7 || strlen($article->getPhone())>11)
{
$erreur.="Numéro de téléphone invalide <br>";
$verif=false;
}
if(strlen($erreur)==0)
{
if($id!=20)
{
$erreur= "Erreur lors de l'inscription";
}else
{
$session = $this->requestStack->getSession();
$session->set('emailSend',$article->getEmail());
$session->set('fonction',$article->getFonction());
$session->set('type',$article->getType());
$session->set('nom',$article->getNom());
$session->set('prenom',$article->getPrenom());
$session->set('phone',$article->getPhone());
return $this->redirectToRoute('evenementDetail', [
'id' => $id
]);
}
}
/* $entityManager->persist($article);
$entityManager->flush();*/
}
return $this->render('formulaires/indexcongre.html.twig',['form' => $form->createView(),'erreur'=>$erreur,'message'=>$messageSuccess,'id'=>$id]);
}
public function index(ManagerRegistry $doctrine,Request $request,$id,$idprix,$supp)
{
$suppadd=0;
/*if($supp != 60 && $supp != 145 && $supp != 165 && $supp != 125 && $supp != 0)
{
echo "Erreur au niveau de prix .<br>merci de retour a la page accueil <a href='/'>accueil</a>";
exit();
}
else
{
if($supp!=0)
{
$suppadd=$supp;
}
}*/
if($supp!=0)
{
$suppadd=$supp;
}
$ret=false;
$session = $this->requestStack->getSession();
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$etape = $repository->findAll();
foreach($etape as $a)
{
/********** verification prix and paimenet congre */
if($a->getEvenementprixId()==$id && $a->getId()==$idprix)
{
$id_event=$a->getEvenementprixId();
$repository = $doctrine->getRepository(Congre::class);
$p = $repository->findBy(
['id' => $id_event,'desplay'=>true]
);
if(count($p)>0)
{
$ret=true;
}
else
{
echo "évenement non disponible .<br>merci de retour a la page accueil <a href='/'>accueil</a>";
exit();
}
}
}
if($ret)
{
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix= $p[0]->getPrix();
$session->set('prix', $prix);
$session->set('idevenement', $id);
$session->set('idprix', $idprix);
}
else
{
echo "merci de retour a la page accueil <a href='/'>accueil</a>";exit();
}
$repository = $doctrine->getRepository(ConnexionUser::class);
$px = $repository->findBy(['email' => $session->get('email')]);
if(count($px)>0)
{
}
else
{
}
/*
//Afficher le résultat
var_dump($result);*/
$repository = $doctrine->getRepository(PayementMethod::class);
$p = $repository->findAll(
array('id' => 'DESC'),
1,
0
);
$em = $doctrine->getManager();
$order_number = $em->createQueryBuilder()
->select('MAX(e.orderNumber)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
/************** */
/************** */
$repository = $doctrine->getRepository(Congre::class);
$congrevide = $repository->find($id);
$repository = $doctrine->getRepository(ConnexionUser::class);
if($px>1)
{
//$userconnexion = $repository->find($px[0]->getId());
}
/***** *addd supppp code ejay na7yyha y anis */
$cal=$prix*10;
$cal=$cal/100;
// $total = $prix-$cal;
$pourcentage=0;
$adhesion=0;
if($session->get('type')=="Adhérent")
{
$prix+=0;
}else
{
$prix+=20;
}
$total=$prix+$suppadd;
$session->set('total', $total);
$session->set('pourcentage', $pourcentage);
/**************** */
/*$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['id_user' => $userconnexion->getId(),'evenementId'=>$id,'pai'=>1]
);
if(count($connexionverif)>0)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Vous étes inscrit a la formation "
));
}*/
/******* */
/******* */
$url='https://ipay.clictopay.com/payment/rest/register.do?amount='.($total*1000).'¤cy=788&language=en&orderNumber='.$order_number.'&password=I7Vh2o1e&returnUrl=https://astp.tn/retour-paiment/&userName=0799902085';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$PayementMethod = new PayementMethod();
$PayementMethod->setOrderNumber($order_number+1);
$PayementMethod->setUrl("0");
$PayementMethod->setMontant(($prix));
$PayementMethod->setSupp(($supp));
$PayementMethod->setTotal(($total));
$PayementMethod->setAdhesion($adhesion);
$PayementMethod->setPourcentage(($pourcentage));
$PayementMethod->setEvenementId($congrevide);
$PayementMethod->setNom($session->get('nom'));
$PayementMethod->setEmail($session->get('emailSend'));
$PayementMethod->setPrenom($session->get('prenom'));
$PayementMethod->setPhone($session->get('phone'));
$ddate=date("Y-m-d h:i:s");$PayementMethod->setDateAd(\DateTime::createFromFormat("Y-m-d h:i:s",$ddate));
$PayementMethod->setPai(0);
$em->persist($PayementMethod);
$em->flush();
$result=json_decode($result);
$idorder_number = $em->createQueryBuilder()
->select('MAX(e.id)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
$session->set('idpaiment', $idorder_number);
header('Location: '.$result->formUrl);
exit();
}
public function indexautre(ManagerRegistry $doctrine,Request $request,$id,$idprix)
{
$ret=false;
$session = $this->requestStack->getSession();
$repository = $doctrine->getRepository(PrixVariable::class);
$etape = $repository->findAll();
foreach($etape as $a)
{
/********** verification prix and paimenet congre */
if($a->getEvenementprixId()==$id && $a->getId()==$idprix)
{
$id_event=$a->getEvenementprixId();
$repository = $doctrine->getRepository(EvenementAVenir::class);
$p = $repository->findBy(
['id' => $id_event,'desplay'=>true]
);
if(count($p)>0)
{
$ret=true;
}
else
{
echo "évenement non disponible .";
exit();
}
}
}
if($ret)
{
$repository = $doctrine->getRepository(PrixVariable::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix= $p[0]->getPrix();
$session->set('prix', $prix);
$session->set('idevenement', $id);
$session->set('idprix', $idprix);
}
else
{
echo "erreur";exit();
}
$repository = $doctrine->getRepository(ConnexionUser::class);
$px = $repository->findBy(['email' => $session->get('email')]);
if($id!=49)
{
if(count($px)>0)
{
}
else
{
echo "Erreur";exit();
}
}
/*
//Afficher le résultat
var_dump($result);*/
$repository = $doctrine->getRepository(PayementMethod::class);
$p = $repository->findAll(
array('id' => 'DESC'),
1,
0
);
$em = $doctrine->getManager();
$order_number = $em->createQueryBuilder()
->select('MAX(e.orderNumber)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
/************** */
$repository = $doctrine->getRepository(EvenementAVenir::class);
$congrevide = $repository->find($id);
$repository = $doctrine->getRepository(ConnexionUser::class);
if($id!=49)
{
$userconnexion = $repository->find($px[0]->getId());
}else
{
$userconnexion = null;
}
$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['id_user' => $userconnexion->getId(),'evenementautre'=>$id,'pai'=>1]
);
if(count($connexionverif)>0)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Vous étes inscrit a la formation "
));
}
/****** inscription fermé */
$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['evenementautre' => $id, 'pai' => true]
);
$connexionverifsurplace = $doctrine->getRepository(PayementMethod::class)->findBy(
['evenementautre' => $id,'surplace' => true]
);
if(count($connexionverif)+count($connexionverifsurplace)>32)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Inscription fermé"
));
}
/******* */
/******* */
$url='https://ipay.clictopay.com/payment/rest/register.do?amount='.($prix*1000).'¤cy=788&language=en&orderNumber='.$order_number.'&password=I7Vh2o1e&returnUrl=https://astp.tn/retour-paiment/&userName=0799902085';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$PayementMethod = new PayementMethod();
$PayementMethod->setOrderNumber($order_number+1);
$PayementMethod->setUrl("1");
if($id==49)
{
$PayementMethod->setPhone(($session->get('evenementspecifique')));
}
$PayementMethod->setMontant(($prix));
$PayementMethod->setEvenementautre($congrevide);
$PayementMethod->setIdUser($userconnexion);
$ddate=date("Y-m-d h:i:s");$PayementMethod->setDateAd(\DateTime::createFromFormat("Y-m-d h:i:s",$ddate));
$PayementMethod->setPai(0);
$em->persist($PayementMethod);
$em->flush();
$result=json_decode($result);
if(isset($result->errorCode))
{
if($result->errorCode!=0)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>($order_number+1)." ".$result->errorMessage
));
}
}
/* var_dump($result);
echo $result->formUrl;*/
$idorder_number = $em->createQueryBuilder()
->select('MAX(e.id)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
$session->set('idpaiment', $idorder_number);
header('Location: '.$result->formUrl);
exit();
}
public function indexsurplace(ManagerRegistry $doctrine,Request $request,$id,$idprix,$supp)
{
$suppadd=0;
if($supp != 65 && $supp != 145 && $supp != 165 && $supp != 125 && $supp != 0)
{
echo "Erreur au niveau de prix .<br>merci de retour a la page accueil <a href='/'>accueil</a>";
exit();
}
else
{
}
$ret=false;
$session = $this->requestStack->getSession();
/* if ( $session->has('idpp')){
$session->remove('idpp');
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Erreur"
));
}*/
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$etape = $repository->findAll();
foreach($etape as $a)
{
/********** verification prix and paimenet congre */
if($a->getEvenementprixId()==$id && $a->getId()==$idprix)
{
$id_event=$a->getEvenementprixId();
$repository = $doctrine->getRepository(Congre::class);
$p = $repository->findBy(
['id' => $id_event,'desplay'=>true]
);
if(count($p)>0)
{
$ret=true;
}
else
{
echo "évenement non disponible .";
exit();
}
}
}
if($ret)
{
$repository = $doctrine->getRepository(PrixVariableCongre::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix= $p[0]->getPrix();
$session->set('prix', $prix);
$session->set('idevenement', $id);
$session->set('idprix', $idprix);
}
else
{
echo "merci de retour a la page accueil <a href='/'>accueil</a>";exit();
}
$repository = $doctrine->getRepository(ConnexionUser::class);
$px = $repository->findBy(['email' => $session->get('email')]);
if(count($px)>0)
{
}
else
{
echo "Merci de connecter <a href='/connexion/'>connexion</a>";exit();
}
$repository = $doctrine->getRepository(PayementMethod::class);
$p = $repository->findAll(
array('id' => 'DESC'),
1,
0
);
/************** */
$repository = $doctrine->getRepository(Congre::class);
$congrevide = $repository->find($id);
$repository = $doctrine->getRepository(ConnexionUser::class);
$userconnexion = $repository->find($px[0]->getId());
$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['id_user' => $userconnexion->getId(),'evenementId'=>$id]
);
if(count($connexionverif)>0)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Vous étes inscrit a la formation "
));
}
/******* */
$total=$supp+$prix;
$adhesion=0;
$em = $doctrine->getManager();
$order_number = $em->createQueryBuilder()
->select('MAX(e.orderNumber)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
$PayementMethod = new PayementMethod();
$PayementMethod->setOrderNumber($order_number+1);
$PayementMethod->setUrl("00");
$PayementMethod->setMontant(($prix));
$PayementMethod->setSupp(($supp));
$PayementMethod->setTotal(($total));
$PayementMethod->setAdhesion($adhesion);
$PayementMethod->setPourcentage((0));
$PayementMethod->setEvenementId($congrevide);
$PayementMethod->setIdUser($userconnexion);
$ddate=date("Y-m-d h:i:s");$PayementMethod->setDateAd(\DateTime::createFromFormat("Y-m-d h:i:s",$ddate));
$PayementMethod->setPai(0);
$em->persist($PayementMethod);
$em->flush();
$session->set('idpp', "0");
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>-1,
'ErrorMessage'=>""
));
}
public function indexsurplaceautre(ManagerRegistry $doctrine,Request $request,$id,$idprix)
{
$ret=false;
$session = $this->requestStack->getSession();
if ( $session->has('idpp')){
$session->remove('idpp');
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Erreur"
));
}
$repository = $doctrine->getRepository(PrixVariable::class);
$etape = $repository->findAll();
foreach($etape as $a)
{
/********** verification prix and paimenet congre */
if($a->getEvenementprixId()==$id && $a->getId()==$idprix)
{
$id_event=$a->getEvenementprixId();
$repository = $doctrine->getRepository(EvenementAVenir::class);
$p = $repository->findBy(
['id' => $id_event,'desplay'=>true]
);
if(count($p)>0)
{
$ret=true;
}
else
{
echo "évenement non disponible .";
exit();
}
}
}
if($ret)
{
$repository = $doctrine->getRepository(PrixVariable::class);
$p = $repository->findBy(
['id' => $idprix]
);
$prix= $p[0]->getPrix();
$session->set('prix', $prix);
$session->set('idevenement', $id);
$session->set('idprix', $idprix);
}
else
{
echo "erreur3";exit();
}
$repository = $doctrine->getRepository(ConnexionUser::class);
$px = $repository->findBy(['email' => $session->get('email')]);
if(count($px)>0)
{
}
else
{
echo "Erreur";exit();
}
/************** */
$repository = $doctrine->getRepository(EvenementAVenir::class);
$congrevide = $repository->find($id);
$repository = $doctrine->getRepository(ConnexionUser::class);
$userconnexion = $repository->find($px[0]->getId());
/***** *addd supppp code ejay na7yyha y anis */
/**************** */
$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['id_user' => $userconnexion->getId(),'evenementautre'=>$id,'surplace'=>1]
);
if(count($connexionverif)>0)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Vous étes inscrit a la formation "
));
}
/******* */
$connexionverif = $doctrine->getRepository(PayementMethod::class)->findBy(
['evenementautre' => $id, 'pai' => true]
);
$connexionverifsurplace = $doctrine->getRepository(PayementMethod::class)->findBy(
['evenementautre' => $id,'surplace' => true]
);
if(count($connexionverif)+count($connexionverifsurplace)>32)
{
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>1,
'ErrorMessage'=>"Inscription fermé"
));
}
$repository = $doctrine->getRepository(PayementMethod::class);
$p = $repository->findAll(
array('id' => 'DESC'),
1,
0
);
$em = $doctrine->getManager();
$order_number = $em->createQueryBuilder()
->select('MAX(e.orderNumber)')
->from('App\Entity\PayementMethod', 'e')
->getQuery()
->getSingleScalarResult();
/************** */
$repository = $doctrine->getRepository(EvenementAVenir::class);
$congrevide = $repository->find($id);
$repository = $doctrine->getRepository(ConnexionUser::class);
$userconnexion = $repository->find($px[0]->getId());
/******* */
$repository = $doctrine->getRepository(PayementMethod::class);
$count = $repository->findAll();
$count= count($count);
$PayementMethod = new PayementMethod();
$PayementMethod->setOrderNumber($order_number+1);
$PayementMethod->setUrl("01");
$PayementMethod->setMontant(($prix));
$PayementMethod->setEvenementautre($congrevide);
$PayementMethod->setIdUser($userconnexion);
$ddate=date("Y-m-d h:i:s");$PayementMethod->setDateAd(\DateTime::createFromFormat("Y-m-d h:i:s",$ddate));
$PayementMethod->setPai(0);
$PayementMethod->setSurPlace(1);
$em->persist($PayementMethod);
$em->flush();
$session->set('idpp', "0");
return $this->render('paiment/retour.html.twig', array(
'name'=>"",'depositAmount'=>"",
'ErrorCode'=>-1,
'ErrorMessage'=>""
));
}
public function retourPaiment(ManagerRegistry $doctrine,Request $request)
{
$session = $this->requestStack->getSession();
$session->remove('evenementspecifique');
$session = $this->requestStack->getSession();
$orderId= $_GET['orderId'];
$em = $this->getDoctrine()->getManager();
$product = $em->getRepository(PayementMethod::class)->find($session->get('idpaiment'));
if (!$product) {
throw $this->createNotFoundException(
'Erreur '
);
}
$product->setOrdernumberid($orderId);
$em->flush();
$session->set('idppt', "0");
$url='https://ipay.clictopay.com/payment/rest/getOrderStatus.do?orderId='.$orderId.'&language=en&password=I7Vh2o1e&userName=0799902085';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result=json_decode($result);
$name=$result->cardholderName;
$depositAmount=$result->depositAmount;
$ErrorCode=$result->ErrorCode;
$ErrorMessage=$result->ErrorMessage;
if($ErrorCode==0)
{
$em = $this->getDoctrine()->getManager();
$product = $em->getRepository(PayementMethod::class)->find($session->get('idpaiment'));
if (!$product) {
throw $this->createNotFoundException(
'Erreur '
);
}
$product->setPai(1);
$em->flush();
$session->set('idppt', "0");
}
return $this->render('paiment/retour.html.twig', array(
'name'=>$name,'depositAmount'=>$depositAmount,
'ErrorCode'=>$ErrorCode,
'ErrorMessage'=>$ErrorMessage
));
}
public function testanis()
{
/*$orderId= '59a7c903-5260-4dae-b769-322208e295d7';
$url='https://ipay.clictopay.com/payment/rest/getOrderStatus.do?orderId='.$orderId.'&language=en&password=I7Vh2o1e&userName=0799902085';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result=json_decode($result);
print_r($result);*/
exit();
}
public function omar()
{
$em = $this->getDoctrine()->getManager();
$productRepository = $em->getRepository(EvenementFormulaire::class);
// Utilisez la méthode findAll() pour récupérer toutes les données
$products = $productRepository->findAll();
// Affichez les données pour déboguer
return $this->render('omar/liste.html.twig', array(
'product'=>$products
));
}
}