<?php
// src/Controller/typeproduit
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use App\Entity\Commande;
use App\Entity\ParentSejour;
use App\Entity\Ref;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use App\Service\EmailsCmdService;
use App\Service\PayementService;
use App\Service\SejourService;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
/**
* @Route("/Payement")
*/
class PayementController extends AbstractController
{
private $em;
private $session;
private $EmailServie;
private $params;
private $sejourService;
private $PayementService;
public function __construct(ManagerRegistry $em, SessionInterface $session, EmailsCmdService $EmailCommandeService, \Swift_Mailer $mailer, ParameterBagInterface $params, SejourService $sejourService, PayementService $PayementService)
{
$this->em = $em;
$this->session = $session;
$this->EmailServie = $EmailCommandeService;
$this->params = $params;
$this->sejourService = $sejourService;
$this->PayementService = $PayementService;
}
/**
* @Route("/", name="payementTest", methods={"GET"})
*/
public function analyticsBloc(): Response
{
$identifiant = $this->params->get('analytics');
return $this->render('Payement/PayementForm.html.twig', [
'identifiant' => $identifiant,
]);
}
/**
* @Route("/accept_url/{id}", name="moneticoAcceptUrl")
*/
function moneticoAcceptUrl($id)
{
ini_set("max_execution_time", -1);
ini_set('memory_limit', '-1');
$em = $this->container->get('doctrine')->getManager();
//generate Num Facture
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$sats = $this->em->getRepository(Ref::class)->find(33);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$session->set('paymentup2pay', 'succses');
$Products = $session->get("Panier_Acompa");
$sejour = $comande->getIdSejour();
foreach ($Products as $com) {
if (array_key_exists('statut', $com)) {
if ($com["statut"] == "saved") {
$nrbconnx = $this->em->getRepository(ParentSejour::class)->findBy(["idSejour" => $sejour->getId(), "payment" => 1]);
if (sizeof($nrbconnx) >= 5) {
$sejour->setAlbumgratuie(1);
$this->em->getManager()->persist($sejour);
$this->em->getManager()->flush();
}
}
}
}
$comande->setStatut($sats);
$comande->setStatut($sats);
$comande->setNumfacture($valx1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$comande->setNumfacture(substr($comande->getNumfacture(), '0', 6) . $comande->getId());
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
$lengthPanier = $session->get('Panier_Acompa');
$session->set('Panierlength', $lengthPanier);
$Products = [];
$session->set('Panier_Acompa', $Products);
//send mail
$this->EmailServie->MailValiderCommandeAccomp($comande->getIdUser()->getEmail(), $comande);
if ($comande->getMontanenv() == 6 || $comande->getMontanenv() == 1) {
// $this->EmailServie->MailCommandeSuivieAccomp($comande->getIdUser()->getEmail(),$comande);
} else {
// $this->EmailServie->MailExpCommandeSansSuivieAccomp($comande->getIdUser()->getEmail());
}
return $this->redirectToRoute('Commander_Acompa');
}
/**
* @Route("/error_url/{id}", name="moneticoExceptionUrl")
*/
function moneticoExceptionUrl($id)
{
$em = $this->container->get('doctrine')->getManager();
$sats = $this->em->getRepository(Ref::class)->find(34);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'echec');
$session->set('paymentup2pay', 'echec');
$comande->setStatut($sats);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$Products = $session->get("Panier_Acompa");
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
return $this->redirectToRoute('Commander_Acompa');
}
/**
* @Route("/error_url_comande_parent/{id}", name="moneticoExceptionUrl_parent_comande")
*/
function moneticoExceptionUrl_comande($id)
{
$em = $this->container->get('doctrine')->getManager();
$sats = $this->em->getRepository(Ref::class)->find(34);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'echec');
$comande->setStatut($sats);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$Products = $session->get("Panier_Acompa");
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
return $this->redirectToRoute('SuiviCommandeparent');
}
/**
* @Route("/accept_url_comande_parent/{id}", name="moneticoAcceptUrl_parent_comande")
*/
function moneticoAcceptUrl_comande($id)
{
$em = $this->container->get('doctrine')->getManager();
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$sats = $this->em->getRepository(Ref::class)->find(33);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$comande->setStatut($sats);
$comande->setNumfacture($valx1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$comande->setNumfacture(substr($comande->getNumfacture(), '0', 6) . $comande->getId());
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
//log promotion
if (!is_null($comande->getIdPromotion())) {
$sejourService = $this->sejourService;
$logPromotion = $sejourService->createLogPromotion($comande->getIdPromotion(), $comande, $comande->getIdUser());
$comande->setLogPromo($logPromotion);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
}
//
$Products = $session->get("Panier_Acompa");
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
$Products = [];
$session->set('Panier', $Products);
//sendmail
$sendTo = $comande->getIdUser()->getEmail();
$sendmail = $this->EmailServie->MailValiderCommandeParent($sendTo, $comande);
return $this->redirectToRoute('SuiviCommandeparent');
}
/**
* @Route("/error_url_comande_Acompa/{id}", name="moneticoExceptionUrl_comande_Acompa_V")
*/
function moneticoExceptionUrl_comande_Acompa_V($id)
{
$em = $this->container->get('doctrine')->getManager();
$sats = $this->em->getRepository(Ref::class)->find(34);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'echec');
$comande->setStatut($sats);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$Products = $session->get("Panier_Acompa");
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
return $this->redirectToRoute('SuiviCommand', ['id' => $comande->getIdSejour()->getId()]);
}
/**
* @Route("/accept_url_comande_ACOMPA/{id}", name="moneticoAcceptUrl_comande_Acompa_V")
*/
function moneticoExceptionUrl_comande_AcompaV($id)
{
$em = $this->container->get('doctrine')->getManager();
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$sats = $this->em->getRepository(Ref::class)->find(33);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$Products = $session->get("Panier_Acompa");
$sejour = $comande->getIdSejour();
//eliminate panier offer
$comande->setStatut($sats);
$comande->setNumfacture($valx1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$comande->setNumfacture(substr($comande->getNumfacture(), '0', 6) . $comande->getId());
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$Products = $session->get("Panier_Acompa");
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
$Products = [];
$session->set('Panier_Acompa', $Products);
return $this->redirectToRoute('SuiviCommand', ['id' => $comande->getIdSejour()->getId()]);
}
/**
* @Route("/accept_url_parent/{id}", name="moneticoAcceptUrl_parent")
*/
function moneticoAcceptUrl_parent($id)
{
ini_set("max_execution_time", -1);
ini_set('memory_limit', '-1');
$em = $this->container->get('doctrine')->getManager();
$sats = $this->em->getRepository(Ref::class)->find(33);
$comande = $this->em->getRepository(Commande::class)->find($id);
if ($comande->getStatut()->getId() != 33) {
$dateSJoue = new \Datetime();
$annes = $dateSJoue->format('y');
$moi = $dateSJoue->format('m');
$val = $this->em->getRepository(Commande::class)->serachNombreFacture();
$val = $val + 1;
$valx = sprintf('%04d', $val);
$valx1 = "20" . $annes . $moi . $valx;
$comande->setStatut($sats);
$comande->setNumfacture($valx1);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$comande->setNumfacture(substr($comande->getNumfacture(), '0', 6) . $comande->getId());
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
}
$session = $this->session;
$session->set('paymentmoniteco', 'succses');
$session->set('paymentup2pay', 'succses');
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
$lengthPanier = $session->get('Panier');
$session->set('Panierlength', $lengthPanier);
$Products = [];
$session->set('Panier', $Products);
$this->EmailServie->MailValiderCommandeParent($comande->getIdUser()->getEmail(), $comande);
if ($comande->getMontanenv() == 6 || $comande->getMontanenv() == 1) {
// $this->EmailServie->MailCommandeSuivieParent($comande->getIdUser()->getEmail(),$comande);
} else {
// $this->EmailServie->MailExpCommandeSansSuivieParent($comande->getIdUser()->getEmail());
}
return $this->redirectToRoute('Commander');
}
/**
* @Route("/error_url_parent/{id}", name="moneticoExceptionUrl_parent")
*/
function moneticoExceptionUrl_parent($id)
{
$em = $this->container->get('doctrine')->getManager();
$sats = $this->em->getRepository(Ref::class)->find(34);
$comande = $this->em->getRepository(Commande::class)->find($id);
$session = $this->session;
$session->set('paymentmoniteco', 'echec');
$session->set('paymentup2pay', 'echec');
$session->set('referenceup2pay', $id);
$comande->setStatut($sats);
$this->em->getManager()->persist($comande);
$this->em->getManager()->flush();
$resulat = $session->get("paymentmoniteco");
$montanttotalcomande = $comande->getMontantrth();
$session->set('montanttotalcomande', $montanttotalcomande);
//dd($montanttotalcomande);
return $this->redirectToRoute('Commander');
}
/**
* @Route("/chargement_form_up2pay", name="chargement_form_up2pay")
*/
function chargeFormUp2payAction(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
$comandeId = $request->get('id');
$comande = $this->em->getRepository(Commande::class)->findOneBy(['id' => $comandeId]);
$PayementService = $this->PayementService;
$type = $request->get('type');
$firstName = $comande->getIdUser()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdUser()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim";
$postalCode = "68150";
$pbx_site = '6062073'; //variable de test 9999999
$pbx_rang = '001'; //variable de test 95
$pbx_identifiant = '38027616'; //variable de test 123456789
$pbx_cmd = $comande->getNumComande(); //variable de test cmd_test1
if ($type == "parent") {
$pbx_effectue = $this->generateUrl("moneticoAcceptUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_annule = $this->generateUrl("moneticoExceptionUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_refuse = $this->generateUrl("moneticoExceptionUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getEmail();
}
if ($type == "Acompa") {
$pbx_effectue = $this->generateUrl("moneticoAcceptUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_annule = $this->generateUrl("moneticoExceptionUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$pbx_refuse = $this->generateUrl("moneticoExceptionUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getReponseemail();
if (($mail == null) || ($mail == "") || ($mail == " ")) {
$mail = "contact@5sur5sejour.com";
}
}
$pbx_porteur = $mail; //variable de test test@test.fr
// Paramétrage de l'url de retour back office site (notification de paiement IPN) :
$pbx_repondre_a = '';
//$pbx_repondre_a = $this->generateUrl("moneticoExceptionUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
// Paramétrage des données retournées via l'IPN :
$pbx_retour = 'Mt:M;Ref:R;Auto:A;Erreur:E';
// On récupére la date au format ISO-8601 :
$dateTime = date("c");
//$montant = $comande->getMontantrth() . "EUR";
$pbx_total = $comande->getMontantrth();
$pbx_total = (int)((string)($pbx_total * 100));
// Suppression des points ou virgules dans le montant
$pbx_total = str_replace(",", "", $pbx_total);
$pbx_total = str_replace(".", "", $pbx_total);
// Nombre de produit envoyé dans PBX_SHOPPINGCART :
$pbx_nb_produit = '1'; //variable de test 5
// Construction de PBX_SHOPPINGCART :
$pbx_shoppingcart = "<?xml version=\"1.0\" encoding=\"utf-8\"?><shoppingcart><total><totalQuantity>".$pbx_nb_produit."</totalQuantity></total></shoppingcart>";
// Choix de l'authentification dans PBX_SOUHAITAUTHENT
$pbx_souhaitauthent = '01'; //variable de test authentification 3DS (1 par défaut, 2 pour exemption 3DS)
// Valeurs envoyes dans PBX_BILLING :
$pbx_prenom_fact = $firstName; //variable de test Jean-Marie
$pbx_nom_fact = $lastName; //variable de test Thomson
$pbx_adresse1_fact = $addressLine1; //variable de test 1 rue de Paris
$pbx_adresse2_fact = ''; //variable de test <vide>
$pbx_zipcode_fact = $postalCode; //variable de test 75001
$pbx_city_fact = $city; //variable de test Paris
$pbx_country_fact = '250'; //variable de test 250 (pour la France)
// Construction de PBX_BILLING :
$pbx_billing = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Billing><Address><FirstName>".$pbx_prenom_fact."</FirstName>".
"<LastName>".$pbx_nom_fact."</LastName><Address1>".$pbx_adresse1_fact."</Address1>".
"<Address2>".$pbx_adresse2_fact."</Address2><ZipCode>".$pbx_zipcode_fact."</ZipCode>".
"<City>".$pbx_city_fact."</City><CountryCode>".$pbx_country_fact."</CountryCode>".
"</Address></Billing>";
// Recette (paiements de test) :
//$urletrans ="https://recette-tpeweb.e-transactions.fr/php/";
// Production (paiements réels) :
// URL principale :
$urletrans ="https://tpeweb.e-transactions.fr/php/";
// URL secondaire :
//$urletrans ="https://tpeweb1.e-transactions.fr/php/";
// $hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
$hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
$pbx_prenom_fact = strtoupper($pbx_prenom_fact);
$pbx_nom_fact = strtoupper($pbx_nom_fact);
$pbx_adresse1_fact = strtoupper($pbx_adresse1_fact);
$pbx_adresse2_fact = strtoupper($pbx_adresse2_fact);
$pbx_city_fact = strtoupper($pbx_city_fact);
$pbx_country_fact = strtoupper($pbx_country_fact);
// --------------- TRAITEMENT DES VARIABLES ---------------
// On crée la chaéne a hacher sans URLencodage
$msg = "PBX_SITE=" . $pbx_site .
"&PBX_RANG=" . $pbx_rang .
"&PBX_IDENTIFIANT=" . $pbx_identifiant .
"&PBX_SOURCE=RWD" .
"&PBX_TOTAL=" . $pbx_total .
"&PBX_DEVISE=978" .
"&PBX_CMD=" . $pbx_cmd .
"&PBX_PORTEUR=" . $pbx_porteur .
"&PBX_REPONDRE_A=" . $pbx_repondre_a .
"&PBX_RETOUR=" . $pbx_retour .
"&PBX_EFFECTUE=" . $pbx_effectue .
"&PBX_ANNULE=" . $pbx_annule .
"&PBX_REFUSE=" . $pbx_refuse .
"&PBX_HASH=SHA512" .
"&PBX_TIME=" . $dateTime .
"&PBX_SHOPPINGCART=" . $pbx_shoppingcart .
"&PBX_BILLING=" . $pbx_billing .
"&PBX_SOUHAITAUTHENT=" . $pbx_souhaitauthent;
$binKey = pack("H*", $hmackey);
$hmac = strtoupper(hash_hmac('sha512', $msg, $binKey));
return new JsonResponse(array(
'urletrans' => $urletrans,
'pbx_site' => $pbx_site,
'pbx_rang' => $pbx_rang,
'pbx_identifiant' => $pbx_identifiant,
'pbx_total' => $pbx_total,
'pbx_cmd' => $pbx_cmd,
'pbx_porteur' => $pbx_porteur,
'pbx_repondre_a' => $pbx_repondre_a,
'pbx_retour' => $pbx_retour,
'pbx_effectue' => $pbx_effectue,
'pbx_annule' => $pbx_annule,
'pbx_refuse' => $pbx_refuse,
'dateTime' => $dateTime,
'pbx_shoppingcart' => $pbx_shoppingcart,
'pbx_billing' => $pbx_billing,
'pbx_souhaitauthent' => $pbx_souhaitauthent,
'hmac' => $hmac
));
}
/**
* @Route("/chargement_form", name="chargement_form")
*/
function chargeFormOgoneAction(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
$comandeId = $request->get('id');
$type = $request->get('type');
$comande = $this->em->getRepository(Commande::class)->find($comandeId);
$firstName = $comande->getIdUser()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdUser()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
// $addressLine1 =$comande->getIdUser()->getAdresslivraison()->getRuevoi();if($addressLine1 == null ||$addressLine1 == '' ){ $addressLine1="3 rue de l'église";}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim"; // habib modified pour des raison Bug
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->PayementService;
$version = $this->params->get('version'); //done
$TPE = $this->params->get('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getMontantrth() . "EUR";
$reference = $comande->getNumComande();
if ($type == "parent") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getEmail();
}
if ($type == "Acompa") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getReponseemail();
if (($mail == null) || ($mail == "") || ($mail == " ")) {
$mail = "contact@5sur5sejour.com";
}
}
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$desactivemoyenpaiement = "paypal";
$textelibre = "5sur5sejour"; //
//$mail = "youssef.saad29@gmail.com";//
$SHAIN = $this->params->get('shain');
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'desactivemoyenpaiement' => $desactivemoyenpaiement
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => utf8_encode($mail),
'desactivemoyenpaiement' => $desactivemoyenpaiement
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/chargement_form_paypal", name="chargement_form_paypal")
*/
function chargeFormOgoneActionPaypal(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
$comandeId = $request->get('id');
$type = $request->get('type');
$comande = $this->em->getRepository(Commande::class)->find($comandeId);
$firstName = $comande->getIdUser()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdUser()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
// $addressLine1 =$comande->getIdUser()->getAdresslivraison()->getRuevoi();if($addressLine1 == null ||$addressLine1 == '' ){ $addressLine1="3 rue de l'église";}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim"; // habib modified pour des raison Bug
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->PayementService;
$version = $this->params->get('version'); //done
$TPE = $this->params->get('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getMontantrth() . "EUR";
$reference = $comande->getNumComande();
if ($type == "parent") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parent", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getEmail();
}
if ($type == "Acompa") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getReponseemail();
if (($mail == null) || ($mail == "") || ($mail == " ")) {
$mail = "contact@5sur5sejour.com";
}
}
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$protocole = "paypal";
$textelibre = "5sur5sejour"; //
//$mail = "youssef.saad29@gmail.com";//
$SHAIN = $this->params->get('shain');
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'protocole' => $protocole
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => utf8_encode($mail),
'protocole' => $protocole
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/chargement_form_comande", name="chargement_form_creation_comand")
*/
function chargeFormOgoneActionfromcomandecre(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
$comandeId = $request->get('id');
$type = $request->get('type');
$comande = $this->em->getRepository(Commande::class)->find($comandeId);
$firstName = $comande->getIdUser()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdUser()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
// $addressLine1 =$comande->getIdUser()->getAdresslivraison()->getRuevoi();if($addressLine1 == null ||$addressLine1 == '' ){ $addressLine1="3 rue de l'église";}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim"; // habib modified pour des raison Bug
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->PayementService;
$version = $this->params->get('version'); //done
$TPE = $this->params->get('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getMontantrth() . "EUR";
$reference = $comande->getNumComande();
if ($type == "parent") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parent_comande", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parent_comande", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getEmail();
}
if ($type == "Acompa") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_comande_Acompa_V", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_comande_Acompa_V", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getReponseemail();
if (($mail == null) || ($mail == "") || ($mail == " ")) {
$mail = "contact@5sur5sejour.com";
}
}
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$textelibre = "5sur5sejour"; //
//$mail = "youssef.saad29@gmail.com";//
$desactivemoyenpaiement = "paypal";
$SHAIN = $this->params->get('shain');
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'desactivemoyenpaiement' => $desactivemoyenpaiement
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => utf8_encode($mail),
'desactivemoyenpaiement' => $desactivemoyenpaiement
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
/**
* @Route("/chargement_form_comande_Paypal", name="chargement_form_creation_comand_Paypal")
*/
function chargeFormOgoneActionfromcomandecre_Paypal(Request $request)
{
$em = $this->container->get('doctrine')->getManager();
$comandeId = $request->get('id');
$type = $request->get('type');
$comande = $this->em->getRepository(Commande::class)->find($comandeId);
$firstName = $comande->getIdUser()->getNom();
if ($firstName == null || $firstName == '') {
$firstName = "john";
}
$lastName = $comande->getIdUser()->getPrenom();
if ($lastName == null || $lastName == '') {
$lastName = "Doe";
}
// $addressLine1 =$comande->getIdUser()->getAdresslivraison()->getRuevoi();if($addressLine1 == null ||$addressLine1 == '' ){ $addressLine1="3 rue de l'église";}
$addressLine1 = "3 rue de l'église";
$city = "Ostheim"; // habib modified pour des raison Bug
$postalCode = "68150";
// $postalCode= trim ($postalCode) ;
$country = "FR";
$contexte = array("billing" => array("firstName" => $firstName, "lastName" => $lastName, "addressLine1" => $addressLine1, "city" => $city, "postalCode" => $postalCode, "country" => $country));
//param de payement
$contexte_commande = base64_encode(json_encode($contexte));
$PayementService = $this->PayementService;
$version = $this->params->get('version'); //done
$TPE = $this->params->get('TPE'); //done
$dateTime = $dateNow = new \DateTime();
$date = $dateTime->format("d/m/Y:H:i:s");
//"05/05/2019:11:55:23" ;
$montant = $comande->getMontantrth() . "EUR";
$reference = $comande->getNumComande();
if ($type == "parent") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_parent_comande", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_parent_comande", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getEmail();
}
if ($type == "Acompa") {
$url_retour_ok = $this->generateUrl("moneticoAcceptUrl_comande_Acompa_V", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$url_retour_err = $this->generateUrl("moneticoExceptionUrl_comande_Acompa_V", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$mail = $comande->getIdUser()->getReponseemail();
if (($mail == null) || ($mail == "") || ($mail == " ")) {
$mail = "contact@5sur5sejour.com";
}
}
$lgue = "FR"; //done
$societe = "5sur5sejou"; //done
$textelibre = "5sur5sejour"; //
//$mail = "youssef.saad29@gmail.com";//
$SHAIN = $this->params->get('shain');
$protocole = "paypal";
$param = array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'url_retour_ok' => $url_retour_ok,
'url_retour_err' => $url_retour_err,
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => $contexte_commande,
'texte-libre' => $textelibre,
'mail' => $mail,
'protocole' => $protocole
);
$MAC = $PayementService->monetico_hash_parameters('sha1', $param, $SHAIN);
//utf8_encode
return new JsonResponse(array(
'version' => $version,
'TPE' => $TPE,
'date' => $date,
'montant' => $montant,
'reference' => $reference,
'MAC' => $MAC,
'url_retour_ok' => utf8_encode($url_retour_ok),
'url_retour_err' => utf8_encode($url_retour_err),
'lgue' => $lgue,
'societe' => $societe,
'contexte_commande' => utf8_encode($contexte_commande),
'textelibre' => utf8_encode($textelibre),
'mail' => utf8_encode($mail),
'protocole' => $protocole
));
// return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
}
//for connextion payeent
}