<?php
namespace App\Controller;
use App\Entity\Bloc;
use App\Entity\Categorie;
use App\Entity\Contact;
use App\Entity\Lait;
use App\Entity\Origine;
use App\Entity\Presentation;
use App\Entity\Produit;
use App\Data\FilterProduitData;
use App\Entity\Client;
use App\Entity\Commande;
use App\Entity\Drive;
use App\Entity\Livraison;
use App\Entity\Montant;
use App\Entity\Panier;
use App\Entity\PanierProduits;
use App\Form\FilterProduit;
use App\Repository\ProduitRepository;
use App\Entity\Selection;
use App\Entity\Slider;
use App\Entity\Statut;
use App\Entity\Type;
use App\Form\ClientType;
use App\Form\DateCommandeType;
use App\Service\RecaptchaService;
use App\Form\ContactType;
use App\Repository\CommandeRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Security;
class PagesController extends AbstractController
{
/**
* @Route("/", name="accueil")
*/
public function index(EntityManagerInterface $em, Security $security): Response
{
$sliders = $this->getDoctrine()->getRepository(Slider::class)->findByActif(true);
$selections = $this->getDoctrine()->getRepository(Selection::class)->findByDisplay(true);
$produits = $this->getDoctrine()->getRepository(Produit::class)->threeRandom($em);
$photoProduits = $this->getDoctrine()->getRepository(Produit::class)->findAll();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$connected = $security->getUser();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
return $this->render('pages/accueil.html.twig', [
'sliders' => $sliders,
'selections' => $selections,
'produits' => $produits,
'photoProduits' => $photoProduits,
'drive' => $drive,
'connected' => $connected,
'panier' => $panier,
]);
}
/**
* @Route("/presentation", name="presentation")
*/
public function presentation(Security $security): Response
{
$page = [
'id' => "presentation",
'titre' => "Votre fromager à Rennes et Cesson-Sévigné",
];
$presentation = $this->getDoctrine()->getRepository(Presentation::class)->findOneById(1);
$blocs = $this->getDoctrine()->getRepository(Bloc::class)->findByDisplay(true);
$connected = $security->getUser();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
return $this->render('pages/presentation.html.twig', [
'page' => $page,
'presentation' => $presentation,
'blocs' => $blocs,
'panier' => $panier
]);
}
/**
* @Route("/contact", name="contact")
*/
public function contact(Request $request, MailerInterface $mailer, RecaptchaService $recaptchaService, Security $security): Response
{
$page = [
'id' => "contact",
'titre' => "Contactez-nous pour toutes questions",
];
$etat = "danger";
$message = "Une erreur s'est produite. Veuillez réessayer ultérieurement.";
$connected = $security->getUser();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
$contact = new Contact();
$contactType = $this->createForm(ContactType::class, $contact);
$contactType->handleRequest($request);
if($contactType->isSubmitted() && $contactType->isValid()) {
$captchaToken = $request->get('g-recaptcha-response');
if(!$recaptchaService->verifyCaptcha($captchaToken)) {
$message = "Erreur de captcha";
$etat = "error";
} else {
// Envoi du mail de contact
$email = new TemplatedEmail();
$email->from($contact->getEmail())
->to($this->getParameter('mailer_user'))
->subject('Demande de contact - Koaven Fromagerie')
->htmlTemplate('emails/mailContact.html.twig')
->context(array(
'contact' => $contact
))
;
$emailUser = new TemplatedEmail();
$emailUser->from($this->getParameter('mailer_user'))
->to($contact->getEmail())
->subject('Confirmation réception formulaire de contact - Koaven Fromagerie')
->htmlTemplate('emails/mailContactUser.html.twig')
->context(array(
'contact' => $contact
))
;
$message = "Votre demande de contact a bien été envoyée.";
$etat = "success";
try{
$mailer->send($email);
$mailer->send($emailUser);
} catch (TransportExceptionInterface $e)
{
$etat = "danger";
$message = "Une erreur s'est produite. Veuillez réessayer ultérieurement.";
}
}
$this->addFlash($etat, $message);
return $this->redirectToRoute('contact');
}
return $this->render('pages/contact.html.twig', [
'page' => $page,
'formContact' => $contactType->createView(),
'panier' => $panier
]);
}
/**
* @Route("/mentions-legales", name="mentions")
*/
public function mentions(Security $security): Response
{
$page = [
'id' => "mentions",
'titre' => "Mentions légales",
];
$connected = $security->getUser();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
return $this->render('pages/mentions.html.twig', [
'page' => $page,
'panier' => $panier
]);
}
/**
* @Route("/cgv", name="cgv")
*/
public function cgv(Security $security): Response
{
$montant = $this->getDoctrine()->getRepository(Montant::class)->findOneBy(['id' => 1]);
$page = [
'id' => "cgv",
'titre' => "Conditions générales de vente",
];
$connected = $security->getUser();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
return $this->render('pages/cgv.html.twig', [
'page' => $page,
'security' => $security,
'panier' => $panier,
'montant' => $montant
]);
}
/**
* @Route("/boutique", name="boutique")
*/
public function boutique(ProduitRepository $repository, Request $request, Security $security): Response
{
$page = [
'id' => "fromage",
'titre' => "Votre fromager à Rennes et Cesson-Sévigné",
];
$connected = $security->getUser();
$data = new FilterProduitData();
$data->page = $request->query->get('page', 1) - 1;
$form = $this->createForm(FilterProduit::class, $data);
$form->handleRequest($request);
$produits = $repository->findSearch($data);
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$fromage = $this->getDoctrine()->getRepository(Categorie::class)->findOneBy(['nom' => 'Fromages']);
$cremerie = $this->getDoctrine()->getRepository(Categorie::class)->findOneBy(['nom' => 'Crémerie']);
$cidre = $this->getDoctrine()->getRepository(Categorie::class)->findOneBy(['nom' => 'Cidres']);
$plateau = $this->getDoctrine()->getRepository(Categorie::class)->findOneBy(['nom' => 'Plateaux']);
$nbPersonne = $this->getDoctrine()->getRepository(Produit::class)->findNbPersonneDisplay();
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
$nbMax = 12;
$nbProduit = count($repository->findSearchForNbPage($data));
$nbPages = intdiv($nbProduit, $nbMax);
if($nbProduit % $nbMax){
$nbPages = $nbPages + 1;
}
$currentPage = $request->query->get('page', 1) - 1;
return $this->render('pages/boutique.html.twig', [
'page' => $page,
'produits' => $produits,
'form' => $form->createView(),
'drive' => $drive,
'connected' => $connected,
'panier' => $panier,
'nbPages' => $nbPages,
'currentPage' => $currentPage,
'fromageDisplay' => !empty($fromage) && $fromage->getDisplay(),
'cremerieDisplay' => !empty($cremerie) && $cremerie->getDisplay(),
'cidreDisplay' => !empty($cidre) && $cidre->getDisplay(),
'plateauDisplay' => !empty($plateau) && $plateau->getDisplay(),
'nbPersonnesDisplay' => $nbPersonne,
]);
}
/**
* @Route("/boutique/{slug}", name="produit")
*/
public function produit(string $slug, EntityManagerInterface $em, Security $security): Response
{
$produit = $this->getDoctrine()->getRepository(Produit::class)->findOneBy(['slug' => $slug]);
$produits = $this->getDoctrine()->getRepository(Produit::class)->sixRandomWithCategorie($em, $produit->getCategorie(), $produit->getId());
$photoProduits = $this->getDoctrine()->getRepository(Produit::class)->findAll();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$connected = $security->getUser();
$page = [
'id' => "fromage",
'titre' => $produit->getNom(),
];
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
if ($produit->getDisplay() == false){
return $this->redirectToRoute('boutique');
}
return $this->render('pages/produit.html.twig', [
'page' => $page,
'produit' => $produit,
'produits' => $produits,
'photoProduits' => $photoProduits,
'drive' => $drive,
'connected' => $connected,
'panier' => $panier
]);
}
/**
* @Route("/panier", name="panier")
*/
public function panier(Request $request, Security $security): Response
{
$connected = $security->getUser();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$montant = $this->getDoctrine()->getRepository(Montant::class)->findOneBy(['id' => 1]);
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
if ($panier){
foreach($panier->getPanierProduits() as $produit){
if ($produit->getIdProduit()->getDisplay() == false){
$panierProduit = $this->getDoctrine()->getRepository(PanierProduits::class)->findOneBy(['idPanier' => $produit->getIdPanier(), 'idProduit' => $produit->getIdProduit()]);
$em = $this->getDoctrine()->getManager();
$em->remove($panierProduit);
$em->flush();
$panierProduits = $this->getDoctrine()->getRepository(PanierProduits::class)->findBy(['idPanier' => $panier->getId()]);
$nbProduit = 0;
$prixTotal = 0;
foreach ($panierProduits as $panierProduit){
$nbProduit += $panierProduit->getNbProduit();
$prixTotal += $panierProduit->getPrixTotal();
}
if($panier->getCodeId()){
$panier->setCodeId(null);
}
$panier->setNbProduit($nbProduit);
$panier->setPrixTotal($prixTotal);
$em = $this->getDoctrine()->getManager();
$em->persist($panier);
$em->flush();
}
}
}
}
$page = [
'id' => "fromage",
'titre' => "Panier - Étape 1",
];
return $this->render('pages/panier.html.twig', [
'page' => $page,
'drive' => $drive,
'panier' => $panier,
'connected' => $connected,
'montant' => $montant
]);
}
/**
* @Route("/panier/suivant", name="panier_suivant")
*/
public function panierSuivant(Request $request, Security $security): Response
{
$connected = $security->getUser();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$jours = $this->getDoctrine()->getRepository(Livraison::class)->findBy(['actif' => 1]);
if(!$connected || $drive->getActive() == false){
return $this->redirectToRoute('profil');
}
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
foreach($panier->getPanierProduits() as $produit){
if ($produit->getIdProduit()->getDisplay() == false){
$panierProduit = $this->getDoctrine()->getRepository(PanierProduits::class)->findOneBy(['idPanier' => $produit->getIdPanier(), 'idProduit' => $produit->getIdProduit()]);
$em = $this->getDoctrine()->getManager();
$em->remove($panierProduit);
$em->flush();
$panierProduits = $this->getDoctrine()->getRepository(PanierProduits::class)->findBy(['idPanier' => $panier->getId()]);
$nbProduit = 0;
$prixTotal = 0;
foreach ($panierProduits as $panierProduit){
$nbProduit += $panierProduit->getNbProduit();
$prixTotal += $panierProduit->getPrixTotal();
}
if($panier->getCodeId()){
$panier->setCodeId(null);
}
$panier->setNbProduit($nbProduit);
$panier->setPrixTotal($prixTotal);
$em = $this->getDoctrine()->getManager();
$em->persist($panier);
$em->flush();
}
}
if($panier == ""){
return $this->redirectToRoute('profil');
}
$page = [
'id' => "fromage",
'titre' => "Panier - Étape 2",
];
$commande = new Commande();
$form = $this->createForm(DateCommandeType::class, $commande);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$nbPanier = count($this->getDoctrine()->getRepository(Panier::class)->findAll());
$panier->setDateLivraison(new \DateTime($form->get('date_livraison')->getViewData()));
$panier->setNom('KOA00' . $nbPanier);
$em = $this->getDoctrine()->getManager();
$em->persist($panier);
$em->flush();
$urlAxepta = $this->module_bancaire_axepta($panier->getPrixTotal(), $panier->getNom());
return $this->redirect($urlAxepta);
}
return $this->render('pages/panier_suivant.html.twig', [
'page' => $page,
'drive' => $drive,
'jours' => $jours,
'panier' => $panier,
'connected' => $connected,
'form' => $form->createView(),
]);
}
/**
* @Route("/panier/erreur", name="panier_erreur")
*/
public function commandeErreur(Request $request, Security $security)
{
$connected = $security->getUser();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
if(!$connected || $drive->getActive() == false){
return $this->redirectToRoute('profil');
}
$etat = "danger";
$message = "Une erreur s'est produite avec le paiement. Veuillez réessayer ultérieurement.";
$this->addFlash($etat, $message);
return $this->redirectToRoute('panier_suivant');
}
/**
* @Route("/panier/valide", name="panier_valide")
*/
public function commandeSuccess(Request $request, Security $security, MailerInterface $mailer): Response
{
$page = [
'id' => "fromage",
'titre' => "Récapitulatif de votre commande",
];
$connected = $security->getUser();
$drive = $this->getDoctrine()->getRepository(Drive::class)->findOneBy(['id' => 1]);
$data = $request->query->get('Data');
if(!$connected || $drive->getActive() == false || !$data){
return $this->redirectToRoute('profil');
}
$blowfish = $_ENV["BLOWFISH"];
$data = hex2bin($data);
$decrypte = openssl_decrypt($data, 'BF-ECB', $blowfish, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING | OPENSSL_DONT_ZERO_PAD_KEY);
$description = $this->get_string_between($decrypte, 'Description=', '&');
$refnr = $this->get_string_between($decrypte, 'refnr=', '&');
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['nom' => $refnr]);
if($panier == "" || $description != 'success'){
return $this->redirectToRoute('profil');
}
$commande = new Commande();
$statut = $this->getDoctrine()->getRepository(Statut::class)->findOneBy(['id' => 1]);
$commande->setDateLivraison($panier->getDateLivraison());
$commande->setStatutId($statut);
$commande->setCodeId($panier->getCodeId());
$commande->setPrixTotal($panier->getPrixTotal());
$commande->setClientId($panier->getClientId());
$commande->setPanierId($panier);
$commande->setNom($refnr);
$em = $this->getDoctrine()->getManager();
$em->persist($commande);
$panier->setCommande(1);
$em->persist($panier);
$em->flush();
$email = new TemplatedEmail();
$email->from($this->getParameter('mailer_noreply'))
->to($this->getParameter('mailer_cmd'))
->subject('Commande - Koaven Fromagerie')
->htmlTemplate('emails/mailCommandeKoaven.html.twig')
->context(array(
'client' => $connected,
'commande' => $commande
))
;
$emailUser = new TemplatedEmail();
$emailUser->from($this->getParameter('mailer_cmd'))
->to($connected->getUserIdentifier())
->subject('Confirmation de commande - Koaven Fromagerie')
->htmlTemplate('emails/mailCommandeClient.html.twig')
->context(array(
'client' => $connected,
'commande' => $commande
))
;
$message = "Votre commande a bien été pris en compte, vous allez recevoir un email.";
$etat = "success";
try{
$mailer->send($email);
$mailer->send($emailUser);
} catch (TransportExceptionInterface $e)
{
$etat = "danger";
$message = "Une erreur s'est produite. Veuillez réessayer ultérieurement.";
}
$this->addFlash($etat, $message);
return $this->render('pages/panier_valide.html.twig', [
'page' => $page,
'connected' => $connected,
'commande' => $commande,
'panier' => $panier
]);
}
/**
* @Route("/profil", name="profil")
*/
public function profil(Security $security): Response
{
$page = [
'id' => "presentation",
'titre' => "Profil",
];
$connected = $security->getUser();
$panier = "";
$user = null;
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
$user = $this->getDoctrine()->getRepository(Client::class)->findOneBy(['id' => $connected->getId()]);
}
return $this->render('pages/profil.html.twig', [
'page' => $page,
'connected' => $connected,
'panier' => $panier,
'user' => $user
]);
}
/**
* @Route("/commande", name="commande")
*/
public function commande(CommandeRepository $repository, Security $security): Response
{
$page = [
'id' => "presentation",
'titre' => "Commande",
];
$connected = $security->getUser();
if(!$connected){
return $this->redirectToRoute('profil');
}
$commandes = $repository->findBy(['clientId' => $connected->getId()]);
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
return $this->render('pages/commande.html.twig', [
'page' => $page,
'commandes' => $commandes,
'panier' => $panier
]);
}
/**
* @Route("/commande/{id}", name="commande_detail")
*/
public function commandeDetail(int $id,CommandeRepository $repository, Security $security): Response
{
$connected = $security->getUser();
if(!$connected){
return $this->redirectToRoute('profil');
}
$commande = $this->getDoctrine()->getRepository(Commande::class)->findOneBy(['id' => $id]);
if($commande->getClientId()->getId() != $connected->getId()){
return $this->redirectToRoute('profil');
}
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
$page = [
'id' => "presentation",
'titre' => $commande->getDateCreation(),
];
return $this->render('pages/commande_detail.html.twig', [
'page' => $page,
'commande' => $commande,
'panier' => $panier
]);
}
/**
* @Route("/commande/repasser/{id}", name="commande_repasser")
*/
public function commandeRepasser(int $id,CommandeRepository $repository, Security $security): Response
{
$connected = $security->getUser();
if(!$connected){
return $this->redirectToRoute('profil');
}
$commande = $this->getDoctrine()->getRepository(Commande::class)->findOneBy(['id' => $id]);
if($commande->getClientId()->getId() != $connected->getId()){
return $this->redirectToRoute('profil');
}
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
$panierCmd = $commande->getPanierId();
if(!$panier){
$panier = new Panier();
$panier->setClientId($connected);
$panier->setNbProduit(0);
$panier->setPrixTotal(0);
$panier->setCommande(0);
}
$em = $this->getDoctrine()->getManager();
$em->persist($panier);
$em->flush();
$nbTotal = 0;
$prixTotal = 0;
foreach($panierCmd->getPanierProduits() as $ancienPanierProduit){
$panierProduit = $this->getDoctrine()->getRepository(PanierProduits::class)->findOneBy(['idPanier' => $panier->getId(), 'idProduit' => $ancienPanierProduit->getIdProduit()->getId()]);
if ($ancienPanierProduit->getIdProduit()->getDisplay()){
if(!$panierProduit){
$panierProduit = new PanierProduits();
$panierProduit->setIdPanier($panier);
$panierProduit->setIdProduit($ancienPanierProduit->getIdProduit());
$panierProduit->setNbProduit($ancienPanierProduit->getNbProduit());
$panierProduit->setPrixTotal($ancienPanierProduit->getPrixTotal());
$nbTotal = $nbTotal + $ancienPanierProduit->getNbProduit();
$prixTotal = $prixTotal + $ancienPanierProduit->getPrixTotal();
} else {
$nb = $panierProduit->getNbProduit() + $ancienPanierProduit->getNbProduit();
$prix = $panierProduit->getIdProduit()->getPrixUnitaire() * $nb;
$panierProduit->setNbProduit($nb);
$panierProduit->setPrixTotal($prix);
$nbTotal = $nbTotal + $nb;
$prixTotal = $prixTotal + $prix;
}
$em = $this->getDoctrine()->getManager();
$em->persist($panierProduit);
$em->flush();
}
}
$nb = $panier->getNbProduit() + $nbTotal;
$prix = $panier->getPrixTotal() + $prixTotal;
$panier->setNbProduit($nb);
$panier->setPrixTotal($prix);
$em = $this->getDoctrine()->getManager();
$em->persist($panier);
$em->flush();
}
return $this->redirectToRoute('commande_detail', array('id' => $id));
}
/**
* @Route("/edit", name="edit")
*/
public function edit(Security $security, Request $request, UserPasswordEncoderInterface $passwordEncoder): Response
{
$page = [
'id' => "presentation",
'titre' => "Modification du profil",
];
$connected = $security->getUser();
if(!$connected){
return $this->redirectToRoute('profil');
}
$panier = "";
if($connected){
$panier = $this->getDoctrine()->getRepository(Panier::class)->findOneBy(['clientId' => $connected->getId(), 'commande' => 0]);
}
$user = $this->getDoctrine()->getRepository(Client::class)->findOneBy(['id' => $connected->getId()]);
$form = $this->createForm(ClientType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user->setPassword(
$passwordEncoder->encodePassword(
$user,
$form->get('plainPassword')->getData()
)
);
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$etat = "success";
$message = "Le profil a bien été modifié";
$this->addFlash($etat, $message);
return $this->redirectToRoute('profil');
}
return $this->render('pages/edit_profil.html.twig', [
'page' => $page,
'connected' => $connected,
'form' => $form->createView(),
'panier' => $panier
]);
}
function get_string_between($string, $start, $end){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
function module_bancaire_axepta($prix, $nom){
$merchantId = $_ENV["MERCHANT_ID"];;
$hmac = $_ENV["HMAC"];
$urlSuccess = $_ENV["URL_SUCCESS"];
$urlFailure = $_ENV["URL_FAILURE"];
$urlNotify = $_ENV["URL_NOTIFY"];
$blowfish = $_ENV["BLOWFISH"];
$prixFormat = number_format($prix, 2, ',', ' ');
$formatAxepta = str_replace(',', '', $prixFormat);
$formatAxepta = str_replace(' ', '', $formatAxepta);
$stringForHmac = "**". $merchantId ."*". $formatAxepta . "*EUR";
$mac = hash_hmac('sha256', $stringForHmac, $hmac);
$info = "MerchantID=". $merchantId ."&RefNr=". $nom."&Amount=". $formatAxepta ."&Currency=EUR&URLSuccess=". $urlSuccess ."&URLFailure=". $urlFailure ."&URLNotify=". $urlNotify ."&Response=encrypt&MAC=". $mac;
$len = strlen($info);
$encrypt = openssl_encrypt($info, 'BF-ECB', $blowfish, OPENSSL_RAW_DATA);
$data = bin2hex($encrypt);
$url = "https://paymentpage.axepta.bnpparibas/payssl.aspx?MerchantID=". $merchantId."&Data=". $data ."&Len=". $len ."&Template=Cards_BNP_v1&Language=fr&CCTemplate=Cards_v1&SDDTemplate=DirectDebit_v1&URLBack=https%3A%2F%2Fwww.koaven.bzh%2Fboutique&CustomField1=". $prixFormat ."€&PayType=0";
return $url;
}
}