From ac791cfae6f32a46de246ef0c5aa5f77f38ebc3c Mon Sep 17 00:00:00 2001 From: Sarahshr <51380592+Sarahshr@users.noreply.github.com> Date: Wed, 31 Jul 2024 18:05:06 +0200 Subject: [PATCH] add missing info on redirect to payment page (#729) --- .../Payment/PlatformMembership/PrepareAction.php | 7 +++++-- src/Repository/PlatformOfferRepository.php | 16 ++++++++++++++++ templates/pages/redirect_to_payment.html.twig | 12 +++++++++++- translations/templates/pages/messages.fr.xlf | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Controller/Payment/PlatformMembership/PrepareAction.php b/src/Controller/Payment/PlatformMembership/PrepareAction.php index 332a808..6147de9 100644 --- a/src/Controller/Payment/PlatformMembership/PrepareAction.php +++ b/src/Controller/Payment/PlatformMembership/PrepareAction.php @@ -7,6 +7,7 @@ namespace App\Controller\Payment\PlatformMembership; use App\Entity\PlatformOffer; use App\Entity\User; use App\Payment\PayumManager; +use App\Repository\ConfigurationRepository; use App\Repository\PlatformOfferRepository; use Symfony\Bridge\Doctrine\Attribute\MapEntity; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -57,10 +58,12 @@ final class PrepareAction extends AbstractController 'en' => '/en/subcription', 'fr' => '/fr/abonnement', ], name: 'redirect_to_payment')] - public function redirectToPayment(PlatformOfferRepository $platformOfferRepository): Response + public function redirectToPayment(PlatformOfferRepository $platformOfferRepository, ConfigurationRepository $configurationRepository): Response { $offers = $platformOfferRepository->findBy(['active' => true]); + $lowOffer = $platformOfferRepository->findLowOffer(); + $platformName = $configurationRepository->getInstanceConfigurationOrCreate()->getPlatformName(); - return $this->render('pages/redirect_to_payment.html.twig', compact('offers')); + return $this->render('pages/redirect_to_payment.html.twig', compact('offers', 'lowOffer', 'platformName')); } } diff --git a/src/Repository/PlatformOfferRepository.php b/src/Repository/PlatformOfferRepository.php index af8b4ce..9f19744 100644 --- a/src/Repository/PlatformOfferRepository.php +++ b/src/Repository/PlatformOfferRepository.php @@ -6,6 +6,7 @@ namespace App\Repository; use App\Entity\PlatformOffer; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\NonUniqueResultException; use Doctrine\Persistence\ManagerRegistry; /** @@ -37,4 +38,19 @@ class PlatformOfferRepository extends ServiceEntityRepository { return $this->findOneBy(['id' => $id, 'active' => true]); } + + /** + * @throws NonUniqueResultException + */ + public function findLowOffer(): ?PlatformOffer + { + /** @var ?PlatformOffer */ + return $this + ->createQueryBuilder('o') + ->andWhere('o.active = true') + ->orderBy('o.price', 'ASC') + ->getQuery() + ->setMaxResults(1) + ->getOneOrNullResult(); + } } diff --git a/templates/pages/redirect_to_payment.html.twig b/templates/pages/redirect_to_payment.html.twig index 1d0eeb4..7ac3c7a 100644 --- a/templates/pages/redirect_to_payment.html.twig +++ b/templates/pages/redirect_to_payment.html.twig @@ -5,11 +5,21 @@ {% block body %}
+ {{ (i18n_prefix ~ '.membership')|trans }} + + {{ (i18n_prefix ~ '.membership.start')|trans }} + {{ lowOffer.actualPrice|format_currency(lowOffer.currency) }} + +
+